capsule

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Query

func Query() query.Query

Query Get a fluent query builder instance.

func Schema

func Schema() schema.Schema

Schema Get a schema builder instance.

Types

type Connection

type Connection struct {
	sqlx.DB
	Config *dbal.Config
}

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

var Global *Manager = nil

Global The global manager

func AddConn

func AddConn(name string, driver string, datasource string, timeout ...time.Duration) *Manager

AddConn Register a connection with the manager.

func AddReadConn

func AddReadConn(name string, driver string, datasource string, timeout ...time.Duration) *Manager

AddReadConn Register a readonly connection with the manager.

func New

func New() *Manager

New Create a database manager instance.

func NewWithOption added in v0.0.3

func NewWithOption(option dbal.Option) *Manager

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) Query

func (manager *Manager) Query() query.Query

Query Get a fluent query builder instance.

func (*Manager) Schema

func (manager *Manager) Schema() schema.Schema

Schema Get a schema builder instance.

func (*Manager) SetAsGlobal

func (manager *Manager) SetAsGlobal()

SetAsGlobal Make this connetion instance available globally.

func (*Manager) SetOption added in v0.0.3

func (manager *Manager) SetOption(option dbal.Option)

SetOption set the database manager as the given value

type Pool

type Pool struct {
	Primary  []*Connection
	Readonly []*Connection
}

Pool the connection pool

Jump to

Keyboard shortcuts

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