Documentation ¶
Index ¶
- type CasbinConf
- func (l CasbinConf) MustNewCasbin(dbType, dsn string) *casbin.Enforcer
- func (l CasbinConf) MustNewCasbinWithRedisWatcher(dbType, dsn string, c redis.RedisConf) *casbin.Enforcer
- func (l CasbinConf) MustNewRedisWatcher(c redis.RedisConf, f func(string2 string)) persist.Watcher
- func (l CasbinConf) NewCasbin(dbType, dsn string) (*casbin.Enforcer, error)
- type DatabaseConf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CasbinConf ¶
type CasbinConf struct {
ModelText string `json:"ModelText,optional"`
}
func (CasbinConf) MustNewCasbin ¶ added in v0.2.4
func (l CasbinConf) MustNewCasbin(dbType, dsn string) *casbin.Enforcer
MustNewCasbin returns Casbin enforcer. If there are errors, it will exist.
func (CasbinConf) MustNewCasbinWithRedisWatcher ¶ added in v0.2.6
func (l CasbinConf) MustNewCasbinWithRedisWatcher(dbType, dsn string, c redis.RedisConf) *casbin.Enforcer
MustNewCasbinWithRedisWatcher returns Casbin Enforcer with Redis watcher.
func (CasbinConf) MustNewRedisWatcher ¶ added in v0.2.6
MustNewRedisWatcher returns redis watcher. If there are errors, it will exist. f function will be called if the policies are updated.
func (CasbinConf) NewCasbin ¶
func (l CasbinConf) NewCasbin(dbType, dsn string) (*casbin.Enforcer, error)
NewCasbin returns Casbin enforcer.
type DatabaseConf ¶
type DatabaseConf struct { Host string Port int Username string `json:",optional"` Password string `json:",optional"` DBName string `json:",optional"` SSLMode string `json:",optional"` Type string `json:",default=mysql,options=[mysql,postgres]"` MaxOpenConns *int `json:",optional,default=100"` Debug bool `json:",optional,default=false"` CacheTime int `json:",optional,default=10"` }
DatabaseConf stores database configurations.
func (DatabaseConf) GetDSN ¶ added in v0.1.6
func (c DatabaseConf) GetDSN() string
GetDSN returns DSN according to the database type.
func (DatabaseConf) NewCacheDriver ¶ added in v0.1.9
func (c DatabaseConf) NewCacheDriver(redisConf redis2.RedisConf) *entcache.Driver
NewCacheDriver returns a ent driver with cache.
func (DatabaseConf) NewNoCacheDriver ¶ added in v0.1.9
func (c DatabaseConf) NewNoCacheDriver() *entsql.Driver
NewNoCacheDriver returns a ent driver without cache.
func (DatabaseConf) PostgresDSN ¶
func (c DatabaseConf) PostgresDSN() string
PostgresDSN returns Postgres DSN.
Click to show internal directories.
Click to hide internal directories.