Documentation
¶
Index ¶
- Constants
- Variables
- func Connection(name string) *gorm.DB
- func InjectConf(conf any)
- func InjectDriver(name string, driver DatabaseConfDriverInterface)
- func ListenConf(instance any)
- func Load()
- func WithConnectionModel(ctx *gin.Context, model ModelInterface, driver string) *gorm.DB
- func WithContextModel(ctx *gin.Context, model ModelInterface) *gorm.DB
- type ConnectorInterface
- type DBComponent
- type DatabaseConf
- type DatabaseConfDriverInterface
- type DatabaseConf_MySql
- type DatabaseConf_MySql_HealthCheck
- type DatabaseConf_MySql_Pool
- type DbContainer
- type ModelInterface
- type MysqlConnector
Constants ¶
View Source
const ( ConfigName = "DatabaseConf" DB_DRIVER_MYSQL string = "mysql" )
Variables ¶
View Source
var Component = &DBComponent{}
Functions ¶
func Connection ¶ added in v0.0.52
func InjectConf ¶ added in v0.0.52
func InjectConf(conf any)
func InjectDriver ¶ added in v0.0.52
func InjectDriver(name string, driver DatabaseConfDriverInterface)
func ListenConf ¶ added in v0.3.2
func ListenConf(instance any)
func WithConnectionModel ¶ added in v0.0.52
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 DBComponent ¶ added in v0.3.2
type DBComponent struct{}
func (*DBComponent) Inject ¶ added in v0.3.2
func (c *DBComponent) Inject(instance any)
func (*DBComponent) ListenConf ¶ added in v0.3.2
func (c *DBComponent) ListenConf() map[string]cComponents.ListenConfigFunc
func (*DBComponent) Load ¶ added in v0.3.2
func (c *DBComponent) Load()
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_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 MysqlConnector ¶
type MysqlConnector struct{}
func (*MysqlConnector) Connect ¶
func (i *MysqlConnector) Connect(conf DatabaseConfDriverInterface) *gorm.DB
Source Files
¶
Click to show internal directories.
Click to hide internal directories.