cDB

package module
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DB_DRIVER_MYSQL string = "mysql"
)

Variables

This section is empty.

Functions

func Connection added in v0.0.52

func Connection(name string) *gorm.DB

func InjectConf added in v0.0.52

func InjectConf(conf interface{})

func Load

func Load()

func WithConnectionModel added in v0.0.52

func WithConnectionModel(ctx *gin.Context, model ModelInterface, driver string) *gorm.DB

func WithContextModel added in v0.0.52

func WithContextModel(ctx *gin.Context, model ModelInterface) *gorm.DB

Types

type ConnectorInterface

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

type DatabaseConf

type DatabaseConf struct {
	MysqlConnections map[string]*DatabaseConf_MySql `json:"mysql_connections"`
}

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 {
	// contains filtered or unexported fields
}

func (*DbContainer) GetConnection added in v0.0.52

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

func (*DbContainer) SaveConnection added in v0.0.52

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

func (*DbContainer) SaveDriver added in v0.0.52

func (c *DbContainer) SaveDriver(name string, instance DatabaseConfDriverInterface)

func (*DbContainer) SetDebug

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

type ModelInterface

type ModelInterface interface {
	Connection(ctx *gin.Context) string
}

type MysqlConnector

type MysqlConnector struct{}

func (*MysqlConnector) Connect

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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