cDB

package module
v0.0.120 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2022 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DB_DRIVER_MYSQL string = "mysql"
)

Variables

This section is empty.

Functions

func InjectConf added in v0.0.52

func InjectConf(conf interface{})

func Load

func Load()

func Query

func Query(model ModelInterface) *gorm.DB

Types

type ConnectorInterface

type ConnectorInterface interface {
	Connect(DatabaseConfDriverInterface) *gorm.DB
}

type DatabaseConf

type DatabaseConf struct {
	MysqlConnections map[string]*DatabaseConf_MySql
}

func GetDatabaseConf added in v0.0.52

func GetDatabaseConf() *DatabaseConf

func (*DatabaseConf) ConfigName

func (i *DatabaseConf) ConfigName() string

type DatabaseConfDriverInterface

type DatabaseConfDriverInterface interface {
	GetDriver() string
}

type DatabaseConf_MySql

type DatabaseConf_MySql struct {
	Driver      string                          `json:"driver"`
	Host        string                          `json:"host"`
	Port        int                             `json:"port"`
	Database    string                          `json:"database"`
	Username    string                          `json:"username"`
	Password    string                          `json:"password"`
	Charset     string                          `json:"charset"`
	Collation   string                          `json:"collation"`
	Prefix      string                          `json:"prefix"`
	Debug       bool                            `json:"debug"`
	Pool        *DatabaseConf_MySql_Pool        `json:"pool"`
	HealthCheck *DatabaseConf_MySql_HealthCheck `json:"health_check"`
}

func (*DatabaseConf_MySql) GetDriver

func (i *DatabaseConf_MySql) GetDriver() string

type DatabaseConf_MySql_HealthCheck

type DatabaseConf_MySql_HealthCheck struct {
	TableName string `json:"table_name"`
	Key       string `json:"key"`
}

type DatabaseConf_MySql_Pool

type DatabaseConf_MySql_Pool struct {
	MaxIdleConnections int `json:"max_idle_connections"`
	//MinConnections     int `json:"min_connections"`
	MaxConnections int `json:"max_connections"`
	ConnectTimeout int `json:"connect_timeout"`
	//WaitTimeout        int `json:"wait_timeout"`
	//Heartbeat          int `json:"heartbeat"`
	MaxIdleTime int `json:"max_idle_time"`
}

type DbContainer

type DbContainer struct {
	Lock        *sync.Mutex
	Connections map[string]*gorm.DB
	Debug       map[string]bool
}

func (*DbContainer) Get

func (c *DbContainer) Get(name string) *gorm.DB

func (*DbContainer) Save

func (c *DbContainer) Save(name string, instance *gorm.DB)

func (*DbContainer) SetDebug

func (c *DbContainer) SetDebug(name string, isDebug bool)

type ModelInterface

type ModelInterface interface {
	Connection() string
}

type MysqlConnector

type MysqlConnector struct{}

func (*MysqlConnector) Connect

Jump to

Keyboard shortcuts

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