Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DB *gorm.DB
DB gorm db
View Source
var Enforcer casbin.IEnforcer
Enforcer casbin enforcer
Functions ¶
This section is empty.
Types ¶
type Configure ¶
Configure db config
func NewConfigure ¶
func NewConfigure( dsn string, maxIdleConns, maxOpenConns, connMaxIdleTime, connMaxLifetime int, registers []ResolverConfigure) Configure
NewConfigure 初始化 Configure
type DBConfig ¶
type DBConfig struct {
// contains filtered or unexported fields
}
DBConfig db config
type DBResolverConfig ¶
type DBResolverConfig struct { // Sources db sources Sources []string `yaml:"sources"` // Replicas db replicas Replicas []string `yaml:"replicas"` // Policy db policy Policy string `yaml:"policy"` // Tables db tables Tables []string `yaml:"tables"` }
DBResolverConfig db resolver config
type Database ¶
type Database struct { // Driver db type Driver string `yaml:"driver"` // Source db source Source string `yaml:"source"` // ConnMaxIdleTime conn max idle time ConnMaxIdleTime int `yaml:"connMaxIdleTime"` // ConnMaxLifeTime conn max lifetime ConnMaxLifeTime int `yaml:"connMaxLifeTime"` // MaxIdleConns max idle conns MaxIdleConns int `yaml:"maxIdleConns"` // MaxOpenConns max open conns MaxOpenConns int `yaml:"maxOpenConns"` // Registers db registers Registers []DBResolverConfig `yaml:"registers"` // CasbinModel casbin model CasbinModel string `yaml:"casbinModel"` // Config gorm config Config GORMConfig `yaml:"config"` }
Database database config
type GORMConfig ¶ added in v0.1.3
type GORMConfig struct { // GORM perform single create, update, delete operations in transactions by default to ensure database data integrity // You can disable it by setting `SkipDefaultTransaction` to true SkipDefaultTransaction bool `yaml:"skipDefaultTransaction" json:"skipDefaultTransaction"` // FullSaveAssociations full save associations FullSaveAssociations bool `yaml:"fullSaveAssociations" json:"fullSaveAssociations"` // DryRun generate sql without execute DryRun bool `yaml:"dryRun" json:"dryRun"` // PrepareStmt executes the given query in cached statement PrepareStmt bool `yaml:"prepareStmt" json:"prepareStmt"` // DisableAutomaticPing DisableAutomaticPing bool `yaml:"disableAutomaticPing" json:"disableAutomaticPing"` // DisableForeignKeyConstraintWhenMigrating DisableForeignKeyConstraintWhenMigrating bool `yaml:"disableForeignKeyConstraintWhenMigrating" json:"disableForeignKeyConstraintWhenMigrating"` // IgnoreRelationshipsWhenMigrating IgnoreRelationshipsWhenMigrating bool `yaml:"ignoreRelationshipsWhenMigrating" json:"ignoreRelationshipsWhenMigrating"` // DisableNestedTransaction disable nested transaction DisableNestedTransaction bool `yaml:"disableNestedTransaction" json:"disableNestedTransaction"` // AllowGlobalUpdate allow global update AllowGlobalUpdate bool `yaml:"allowGlobalUpdate" json:"allowGlobalUpdate"` // QueryFields executes the SQL query with all fields of the table QueryFields bool `yaml:"queryFields" json:"queryFields"` // CreateBatchSize default create batch size CreateBatchSize int `yaml:"createBatchSize" json:"createBatchSize"` // TranslateError enabling error translation TranslateError bool `yaml:"translateError" json:"translateError"` }
type ResolverConfigure ¶
type ResolverConfigure interface {
Init(*dbresolver.DBResolver, func(string) gorm.Dialector) *dbresolver.DBResolver
}
ResolverConfigure db resolver config
func NewResolverConfigure ¶
func NewResolverConfigure(sources, replicas []string, policy string, tables []string) ResolverConfigure
NewResolverConfigure 初始化 ResolverConfigure
Click to show internal directories.
Click to hide internal directories.