db

package
v0.0.0-...-f6ca644 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotFound variable
	ErrNotFound = mgo.ErrNotFound
	// ErrCursor variable
	ErrCursor = mgo.ErrCursor
)

AllConnection variable

View Source
var AllSqlConnection = SqlConnectionBuffers{
	Connections: make(map[string]*SqlConnections),
}

AllSqlConnection variable

Functions

func Close

func Close(resourceName string)

Close function

func GenerateDSN

func GenerateDSN(resource *Resource, includeDb bool) string

GenerateDSN function

func GenerateURI

func GenerateURI(option *Resource, db bool) string

GenerateURI function

func MgoParseURI

func MgoParseURI(url string, rootCAs *x509.CertPool) (*mgo.DialInfo, error)

MgoParseURI function

Types

type ConnectionBuffers

type ConnectionBuffers struct {
	sync.RWMutex
	Connections map[string]*Connections
}

ConnectionBuffers struct

type Connections

type Connections struct {
	sync.RWMutex
	Session    *mgo.Session
	Database   *mgo.Database
	Collection *mgo.Collection
	Indexed    bool
	Option     *Resource
	URI        string
}

Connections struct

func NewConnection

func NewConnection(resourceName string) (*Connections, error)

NewConnection function

func NewConnectionURI

func NewConnectionURI(uri string) (*Connections, error)

NewConnectionURI function

func (*Connections) C

func (c *Connections) C(name string)

C method

func (*Connections) Close

func (c *Connections) Close()

Close method

func (*Connections) CloseAll

func (c *Connections) CloseAll()

CloseAll method

func (*Connections) Copy

func (c *Connections) Copy() *mgo.Session

Copy method

func (*Connections) CopyAll

func (c *Connections) CopyAll() (*Connections, error)

CopyAll method

func (*Connections) DB

func (c *Connections) DB(name string)

DB method

func (*Connections) Refresh

func (c *Connections) Refresh()

Refresh method

type DBResources

type DBResources struct {
	Resources []*Resource `json:"dbResources" bson:"dbResources"`
}

DBResources struct

type Map

type Map map[string]interface{}

Map type map

type Resource

type Resource struct {
	Name     string `json:"name" bson:"name"`
	Engine   string `json:"engine" bson:"engine"`
	Host     string `json:"host" bson:"host"`
	Port     string `json:"port" bson:"port"`
	Username string `json:"username" bson:"username"`
	Password string `json:"password" bson:"password"`
	Db       string `json:"db" bson:"db"`
	Ssl      bool   `json:"ssl" bson:"ssl"`
}

Resource struct

func GetResource

func GetResource(resources []*Resource, resourceName string) *Resource

GetResource function

type SqlConnectionBuffers

type SqlConnectionBuffers struct {
	sync.RWMutex
	Connections map[string]*SqlConnections
}

SqlConnectionBuffers struct

type SqlConnections

type SqlConnections struct {
	sync.RWMutex
	Database *sql.DB
	Indexed  bool
	Option   *Resource
	URI      string
}

SqlConnections struct

func NewSqlConnection

func NewSqlConnection(resourceName string) (*SqlConnections, error)

NewSqlConnection function

func NewSqlConnectionURI

func NewSqlConnectionURI(uri string) (*SqlConnections, error)

NewSqlConnectionURI function

func (*SqlConnections) CheckConnection

func (c *SqlConnections) CheckConnection() error

CheckConnection method

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL