Documentation ¶
Index ¶
- func Query() query.Query
- func Schema() schema.Schema
- type Connection
- type Manager
- func (manager *Manager) AddConn(name string, driver string, datasource string, timeout ...time.Duration) *Manager
- func (manager *Manager) AddConnection(name string, driver string, datasource string, readonly bool, ...) *Manager
- func (manager *Manager) AddReadConn(name string, driver string, datasource string, timeout ...time.Duration) *Manager
- func (manager *Manager) GetConnection(name string) *Connection
- func (manager *Manager) GetPrimary() *Connection
- func (manager *Manager) GetRead() *Connection
- func (manager *Manager) Query() query.Query
- func (manager *Manager) Schema() schema.Schema
- func (manager *Manager) SetAsGlobal()
- func (manager *Manager) SetOption(option dbal.Option)
- type Pool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Connection ¶
Connection The database connection
func GetRand ¶
func GetRand(connections []*Connection) *Connection
GetRand Get a registered connection instance.
type Manager ¶
type Manager struct { Pool *Pool Connections *sync.Map // map[string]*Connection Option *dbal.Option }
Manager The database manager
func AddReadConn ¶
AddReadConn Register a readonly connection with the manager.
func NewWithOption ¶ added in v0.0.3
NewWithOption Create a database manager instance using the given option.
func (*Manager) AddConn ¶
func (manager *Manager) AddConn(name string, driver string, datasource string, timeout ...time.Duration) *Manager
AddConn Register a connection with the manager.
func (*Manager) AddConnection ¶
func (manager *Manager) AddConnection(name string, driver string, datasource string, readonly bool, timeouts ...time.Duration) *Manager
AddConnection Register a connection with the manager.
func (*Manager) AddReadConn ¶
func (manager *Manager) AddReadConn(name string, driver string, datasource string, timeout ...time.Duration) *Manager
AddReadConn Register a readonly with the manager.
func (*Manager) GetConnection ¶
func (manager *Manager) GetConnection(name string) *Connection
GetConnection Get a registered connection instance.
func (*Manager) GetPrimary ¶
func (manager *Manager) GetPrimary() *Connection
GetPrimary Get a registered primary connection instance.
func (*Manager) GetRead ¶
func (manager *Manager) GetRead() *Connection
GetRead Get a registered read only connection instance.
func (*Manager) SetAsGlobal ¶
func (manager *Manager) SetAsGlobal()
SetAsGlobal Make this connetion instance available globally.
type Pool ¶
type Pool struct { Primary []*Connection Readonly []*Connection }
Pool the connection pool
Click to show internal directories.
Click to hide internal directories.