Documentation
¶
Index ¶
- Constants
- func NewConnection(config *Config) *gorm.DB
- type AppChangeFunc
- type AppConfig
- type AppConfigFunc
- type AppDB
- type AppDBMessage
- type ChangeType
- type Config
- type Logger
- func (logger *Logger) Error(ctx context.Context, s string, i ...interface{})
- func (logger *Logger) Info(ctx context.Context, s string, i ...interface{})
- func (logger *Logger) LogMode(level glogger.LogLevel) glogger.Interface
- func (logger *Logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)
- func (logger *Logger) Warn(ctx context.Context, s string, i ...interface{})
- type Master
- type Slave
Constants ¶
View Source
const ( Mysql = "mysql" Postgres = "postgres" )
View Source
const (
GoDandelionConnChange = "go_dandelion_conn_change"
)
Variables ¶
This section is empty.
Functions ¶
func NewConnection ¶
Types ¶
type AppChangeFunc ¶
type AppChangeFunc func(appKey string, changeType ChangeType) (err error)
AppChangeFunc 数据连接变更监听触发方法
type AppConfigFunc ¶
AppConfigFunc 用于获取需要初始化的应用库 初始化时,不会传递参数。应用数据库变更时, 会传递 appKey
type AppDB ¶
type AppDB struct {
// contains filtered or unexported fields
}
func InitAppDB ¶
func InitAppDB(configFunc AppConfigFunc, changeFunc AppChangeFunc, redis *redigo.Client) *AppDB
func (*AppDB) Connection ¶
type AppDBMessage ¶
type AppDBMessage struct { AppKey string ChangeType ChangeType }
type Config ¶
type Config struct { DBType string `json:"db_type"` MaxOpenConn int `json:"max_open_conn"` MaxIdleConn int `json:"max_idle_conn"` MaxLifeTime int `json:"max_life_time"` MaxIdleTime int `json:"max_idle_time"` Level int `json:"level"` SlowThreshold time.Duration `json:"slow_threshold"` Master *Master `json:"master"` Slaves []*Slave `json:"slaves"` }
type Logger ¶
type Logger struct { Level glogger.LogLevel SlowThreshold time.Duration IgnoreRecordNotFoundError bool }
Click to show internal directories.
Click to hide internal directories.