config

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 15 Imported by: 10

Documentation

Index

Constants

View Source
const (
	RedisModeSingle  = "single"
	RedisModeCluster = "cluster"
)
View Source
const RedisApiPermissionCountPrefix = "API:PERMISSION:"

RedisApiPermissionCountPrefix is the prefix of api permission access times left in redis

View Source
const RedisCaptchaPrefix = "CAPTCHA:"

RedisCaptchaPrefix is the prefix of captcha key in redis

View Source
const RedisCasbinChannel = "/casbin"

RedisCasbinChannel is the channel of captcha key in redis

View Source
const RedisDataPermissionPrefix = "DATAPERM:"

RedisDataPermissionPrefix is the prefix of data permission in redis

View Source
const RedisDynamicConfigurationPrefix = "CONFIGURATION:"

RedisDynamicConfigurationPrefix is the prefix of dynamic configuration in redis

View Source
const RedisTenantBlacklistPrefix = "BLACKLIST:TENANT:"

RedisTenantBlacklistPrefix is the prefix of tenant blacklist key in redis

View Source
const RedisTokenPrefix = "BLACKLIST:TOKEN:"

RedisTokenPrefix is the prefix of blacklist token key in redis

Variables

This section is empty.

Functions

This section is empty.

Types

type CROSConf added in v1.0.10

type CROSConf struct {
	Address string `json:",env=CROS_ADDRESS"`
}

CROSConf stores the configuration for cross domain

type DatabaseConf

type DatabaseConf struct {
	Host         string `json:",env=DATABASE_HOST"`
	Port         int    `json:",env=DATABASE_PORT"`
	Username     string `json:",default=root,env=DATABASE_USERNAME"`
	Password     string `json:",optional,env=DATABASE_PASSWORD"`
	DBName       string `json:",default=simple_admin,env=DATABASE_DBNAME"`
	SSLMode      string `json:",optional,env=DATABASE_SSL_MODE"`
	Type         string `json:",default=mysql,options=[mysql,postgres,sqlite3],env=DATABASE_TYPE"`
	MaxOpenConn  int    `json:",optional,default=100,env=DATABASE_MAX_OPEN_CONN"`
	CacheTime    int    `json:",optional,default=10,env=DATABASE_CACHE_TIME"`
	DBPath       string `json:",optional,env=DATABASE_DBPATH"`
	MysqlConfig  string `json:",optional,env=DATABASE_MYSQL_CONFIG"`
	PGConfig     string `json:",optional,env=DATABASE_PG_CONFIG"`
	SqliteConfig string `json:",optional,env=DATABASE_SQLITE_CONFIG"`
	Debug        bool   `json:",optional,env=DATABASE_DEBUG"`
}

DatabaseConf stores database configurations.

func (DatabaseConf) GetDSN

func (c DatabaseConf) GetDSN() string

GetDSN returns DSN according to the database type.

func (DatabaseConf) MysqlDSN

func (c DatabaseConf) MysqlDSN() string

MysqlDSN returns mysql DSN.

func (DatabaseConf) NewNoCacheDriver

func (c DatabaseConf) NewNoCacheDriver() *entsql.Driver

NewNoCacheDriver returns an Ent driver without cache.

func (DatabaseConf) PostgresDSN

func (c DatabaseConf) PostgresDSN() string

PostgresDSN returns Postgres DSN.

func (DatabaseConf) SqliteDSN added in v0.2.9

func (c DatabaseConf) SqliteDSN() string

SqliteDSN returns Sqlite DSN.

type RedisConf added in v1.2.6

type RedisConf struct {
	Host         string `json:",env=REDIS_HOST"`
	Db           int    `json:",default=0,env=REDIS_DB"`
	Mode         string `json:",optional,default=single,env=REDIS_MODE"`
	Username     string `json:",optional,env=REDIS_USERNAME"`
	Pass         string `json:",optional,env=REDIS_PASSWORD"`
	Tls          bool   `json:",optional,env=REDIS_TLS"`
	Master       string `json:",optional,env=REDIS_MASTER"`
	PoolSize     int    `json:",optional,default=48,env=REDIS_POOL_SIZE"`
	MaxIdleConns int    `json:",optional,default=12,env=REDIS_MAX_IDLE_CONNS"`
}

A RedisConf is a redis config.

func (RedisConf) EffectiveMode added in v1.8.5

func (r RedisConf) EffectiveMode() string

EffectiveMode returns the redis mode resolved by config. Rule priority: 1) If Host contains ',', force cluster mode. 2) If Mode is "cluster", use cluster mode. 3) Default to single mode.

func (RedisConf) IsClusterMode added in v1.8.5

func (r RedisConf) IsClusterMode() bool

func (RedisConf) MustNewUniversalRedis added in v1.2.9

func (r RedisConf) MustNewUniversalRedis() redis.UniversalClient

func (RedisConf) NewUniversalRedis added in v1.2.9

func (r RedisConf) NewUniversalRedis() (redis.UniversalClient, error)

func (RedisConf) Validate added in v1.2.6

func (r RedisConf) Validate() error

Jump to

Keyboard shortcuts

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