Documentation
¶
Index ¶
- Constants
- func Env(key string, value ...interface{}) interface{}
- func EnvBool(key string, value ...interface{}) bool
- func EnvInt(key string, value ...interface{}) int
- func EnvString(key string, value ...interface{}) string
- func EnvStringSlice(key string, value ...interface{}) []string
- type CacheConfig
- type ConfigEntity
- func (c *ConfigEntity) Get(key string, defaultValue ...interface{}) interface{}
- func (c *ConfigEntity) GetBool(key string, defaultValue ...bool) bool
- func (c *ConfigEntity) GetConfig() *viper.Viper
- func (c *ConfigEntity) GetDuration(key string, defaultValue ...time.Duration) time.Duration
- func (c *ConfigEntity) GetFloat64(key string, defaultValue ...float64) float64
- func (c *ConfigEntity) GetInt(key string, defaultValue ...int) int
- func (c *ConfigEntity) GetIntSlice(key string, defaultValue ...[]int) []int
- func (c *ConfigEntity) GetString(key string, defaultValue ...string) string
- func (c *ConfigEntity) GetStringMap(key string, defaultValue ...map[string]interface{}) map[string]interface{}
- func (c *ConfigEntity) GetStringMapString(key string, defaultValue ...map[string]string) map[string]string
- func (c *ConfigEntity) GetStringSlice(key string, defaultValue ...[]string) []string
- func (c *ConfigEntity) GetTime(key string, defaultValue ...time.Time) time.Time
- type Local
- type LogConfig
- type LogRotate
- type ModCaptcha
- type ModGormDb
- type ModJwt
- type ModRedis
- type ModSwaConfig
- type ModSystem
- type MqttConfig
- type QueueConfig
- type RedisConfig
- type TokenConfig
- type WebSocketConfig
Constants ¶
View Source
const ( RedisMode = "redis.mode" RedisSentinelMasterName = "redis.sentinelMasterName" RedisAddr = "redis.addr" RedisAuth = "redis.auth" RedisDb = "redis.db" RedisMaxActive = "redis.maxActive" RedisMaxIdle = "redis.maxIdle" RedisIdleTimeout = "redis.idleTimeout" RedisPrefix = "redis.prefix" )
redis配置
View Source
const ( DatabaseDriver = "database.driver" DatabaseHost = "database.host" DatabasePort = "database.port" DatabaseUserName = "database.username" DatabasePassword = "database.password" DatabaseDbName = "database.dbName" DatabaseConfig = "database.config" DatabaseMaxIdleConns = "database.maxIdleConns" DatabaseMaxOpenConns = "database.maxOpenConns" DatabaseShowSQL = "database.showSql" )
数据库配置
View Source
const ( LogLevel = "log.level" LogPattern = "log.pattern" LogOutput = "log.output" LogRotateFile = "log.rotate.file" LogRotateMaxSize = "log.rotate.max_size" LogRotateMaxBackups = "log.rotate.max_backups" LogRotateMaxAge = "log.rotate.max_age" LogRotateCompress = "log.rotate.compress" )
日志配置
View Source
const ( MqttHost = "mqtt.host" MattUsername = "mqtt.username" MqttPassword = "mqtt.password" MqttClientID = "mqtt.client_id" MqttParallel = "mqtt.parallel" MqttSubscribeQos = "mqtt.subscribe_qos" MqttPublishQos = "mqtt.publish_qos" )
View Source
const ( QueueInterval = "queue.interval" QueuePrefix = "queue.prefix" QueueListen = "queue.listen" QueueConcurrency = "queue.concurrency" )
View Source
const (
CacheRedisMemoryCacheSize = "redis.memoryCacheSize"
)
缓存配置
Variables ¶
This section is empty.
Functions ¶
func EnvStringSlice ¶
Types ¶
type CacheConfig ¶
type CacheConfig struct {
MemoryCacheSize int // 内存缓存大小(字节)
RedisConfig
}
CacheConfig 结构体用于存储缓存系统的配置
func LoadCacheConfig ¶
func LoadCacheConfig() *CacheConfig
type ConfigEntity ¶
type ConfigEntity struct {
// contains filtered or unexported fields
}
ConfigEntity 表示需要全局调用的实体对象
func (*ConfigEntity) Get ¶
func (c *ConfigEntity) Get(key string, defaultValue ...interface{}) interface{}
Get 获取interface{}类型配置
func (*ConfigEntity) GetBool ¶
func (c *ConfigEntity) GetBool(key string, defaultValue ...bool) bool
GetBool 获取bool类型配置
func (*ConfigEntity) GetConfig ¶
func (c *ConfigEntity) GetConfig() *viper.Viper
func (*ConfigEntity) GetDuration ¶
GetDuration 获取time.Duration类型配置
func (*ConfigEntity) GetFloat64 ¶
func (c *ConfigEntity) GetFloat64(key string, defaultValue ...float64) float64
GetFloat64 获取float64类型配置
func (*ConfigEntity) GetInt ¶
func (c *ConfigEntity) GetInt(key string, defaultValue ...int) int
GetInt 获取int类型配置
func (*ConfigEntity) GetIntSlice ¶
func (c *ConfigEntity) GetIntSlice(key string, defaultValue ...[]int) []int
GetIntSlice 获取[]int类型配置
func (*ConfigEntity) GetString ¶
func (c *ConfigEntity) GetString(key string, defaultValue ...string) string
GetString 获取string类型配置
func (*ConfigEntity) GetStringMap ¶
func (c *ConfigEntity) GetStringMap(key string, defaultValue ...map[string]interface{}) map[string]interface{}
GetStringMap 获取map[string]interface{}类型配置
func (*ConfigEntity) GetStringMapString ¶
func (c *ConfigEntity) GetStringMapString(key string, defaultValue ...map[string]string) map[string]string
GetStringMapString 获取map[string]string类型配置
func (*ConfigEntity) GetStringSlice ¶
func (c *ConfigEntity) GetStringSlice(key string, defaultValue ...[]string) []string
GetStringSlice 获取[]string类型配置
type Local ¶
type Local struct {
Path string `mapstructure:"path" json:"path" yaml:"path"`
StorePath string `mapstructure:"storePath" json:"storePath" yaml:"storePath"`
}
func (Local) WeaverMarshal ¶
func (Local) WeaverUnmarshal ¶
type LogConfig ¶
type LogConfig struct {
Level string `mapstructure:"level" json:"level" yaml:"level"`
Pattern string `mapstructure:"pattern" json:"pattern" yaml:"pattern"`
Output string `mapstructure:"output" json:"output" yaml:"output"`
LogRotate LogRotate `mapstructure:"logRotate" json:"logRotate" yaml:"logRotate"`
}
func LoadLogConfig ¶
func LoadLogConfig() LogConfig
func (LogConfig) WeaverMarshal ¶
func (LogConfig) WeaverUnmarshal ¶
type LogRotate ¶
type LogRotate struct {
Filename string `mapstructure:"filename" json:"filename" yaml:"filename"`
MaxSize int `mapstructure:"maxSize" json:"maxSize" yaml:"maxSize"`
MaxBackups int `mapstructure:"maxBackups" json:"maxBackups" yaml:"maxBackups"`
MaxAge int `mapstructure:"maxAge" json:"maxAge" yaml:"maxAge"`
Compress bool `mapstructure:"compress" json:"compress" yaml:"compress"`
}
type ModCaptcha ¶
type ModCaptcha struct {
KeyLong int `mapstructure:"keyLong" json:"keyLong" yaml:"keyLong"`
ImgWidth int `mapstructure:"imgWidth" json:"imgWidth" yaml:"imgWidth"`
ImgHeight int `mapstructure:"imgHeight" json:"imgHeight" yaml:"imgHeight"`
OpenCaptcha int `mapstructure:"openCaptcha" json:"openCaptcha" yaml:"openCaptcha"`
OpenCaptchaTimeOut int `mapstructure:"openCaptchaTimeout" json:"openCaptchaTimeout" yaml:"openCaptchaTimeout"`
}
func (ModCaptcha) WeaverMarshal ¶
func (ModCaptcha) WeaverMarshal(*codegen.Encoder)
func (ModCaptcha) WeaverUnmarshal ¶
func (ModCaptcha) WeaverUnmarshal(*codegen.Decoder)
type ModGormDb ¶
type ModGormDb struct {
Driver string `mapstructure:"driver" json:"driver" yaml:"driver"`
Host string `mapstructure:"host" json:"host" yaml:"host"`
Port string `mapstructure:"port" json:"port" yaml:"port"`
Username string `mapstructure:"username" json:"username" yaml:"username"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
Dbname string `mapstructure:"dbName" json:"dbName" yaml:"dbName"`
Config string `mapstructure:"config" json:"config" yaml:"config"`
Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"`
Singular bool `mapstructure:"singular" json:"singular" yaml:"singular"`
Engine string `mapstructure:"engine" json:"engine" yaml:"engine" default:"InnoDB"`
MaxIdleConns int `mapstructure:"maxIdleConns" json:"maxIdleConns" yaml:"maxIdleConns"`
MaxOpenConns int `mapstructure:"maxOpenConns" json:"maxOpenConns" yaml:"maxOpenConns"`
LogMode string `mapstructure:"logMode" json:"logMode" yaml:"logMode"`
LogZap bool `mapstructure:"logZap" json:"logZap" yaml:"logZap"`
Dsn string
ShowSQL bool
}
func LoadDatabaseConfig ¶
func LoadDatabaseConfig() *ModGormDb
func (ModGormDb) WeaverMarshal ¶
func (ModGormDb) WeaverUnmarshal ¶
type ModJwt ¶
type ModJwt struct {
SigningKey string `mapstructure:"signingKey" json:"signingKey" yaml:"signingKey"` // --jwt签名
ExpiresTime string `mapstructure:"expiresTime" json:"expiresTime" yaml:"expiresTime"` // --过期时间
BufferTime string `mapstructure:"bufferTime" json:"bufferTime" yaml:"bufferTime"` // --缓冲时间
Issuer string `mapstructure:"issuer" json:"issuer" yaml:"issuer"` // --签发者
}
func (ModJwt) WeaverMarshal ¶
func (ModJwt) WeaverUnmarshal ¶
type ModRedis ¶
type ModRedis struct {
DB int `mapstructure:"db" json:"db" yaml:"db"`
Addr string `mapstructure:"addr" json:"addr" yaml:"addr"`
Password string `mapstructure:"password" json:"password" yaml:"password"`
}
func (ModRedis) WeaverMarshal ¶
func (ModRedis) WeaverUnmarshal ¶
type ModSwaConfig ¶
type ModSwaConfig struct {
Jwt ModJwt `mapstructure:"jwt" json:"jwt" toml:"jwt"`
Redis ModRedis `mapstructure:"redis" json:"redis" toml:"redis"`
Captcha ModCaptcha `mapstructure:"captcha" json:"captcha" toml:"captcha"`
GormDB ModGormDb `mapstructure:"gormDB" json:"gormDB" toml:"gormDB"`
System ModSystem `mapstructure:"system" json:"system" toml:"system"`
Local Local `mapstructure:"local" json:"local" toml:"local"`
Log LogConfig `mapstructure:"log" json:"log" toml:"log"`
}
func (ModSwaConfig) WeaverMarshal ¶
func (ModSwaConfig) WeaverMarshal(*codegen.Encoder)
func (ModSwaConfig) WeaverUnmarshal ¶
func (ModSwaConfig) WeaverUnmarshal(*codegen.Decoder)
type ModSystem ¶
type ModSystem struct {
Debug bool `mapstructure:"debug" json:"debug" yaml:"debug"`
EnablePProf bool `mapstructure:"enablePProf" json:"enablePProf" yaml:"enablePProf"`
PprofPort string `mapstructure:"pprofPort" json:"pprofPort" yaml:"pprofPort"`
Env string `mapstructure:"env" json:"env" yaml:"env"`
Addr int `mapstructure:"addr" json:"addr" yaml:"addr"`
DbType string `mapstructure:"dbType" json:"dbType" yaml:"dbType"`
OssType string `mapstructure:"ossType" json:"ossType" yaml:"ossType"`
UseMultipoint bool `mapstructure:"useMultipoint" json:"useMultipoint" yaml:"useMultipoint"`
UseRedis bool `mapstructure:"useRedis" json:"useRedis" yaml:"useRedis"`
LimitCountIP int `mapstructure:"ipLimitCount" json:"ipLimitCount" yaml:"ipLimitCount"`
LimitTimeIP int `mapstructure:"ipLimitTime" json:"ipLimitTime" yaml:"ipLimitTime"`
RouterPrefix string `mapstructure:"routerPrefix" json:"routerPrefix" yaml:"routerPrefix"`
ResourceCachingEnabled bool `mapstructure:"resourceCachingEnabled" json:"resourceCachingEnabled" yaml:"resourceCachingEnabled"`
}
func (ModSystem) WeaverMarshal ¶
func (ModSystem) WeaverUnmarshal ¶
type MqttConfig ¶
type MqttConfig struct {
Host string `json:"host"`
UserName string `json:"user_name"`
PassWord string `json:"pass_word"`
ClientID string `json:"client_id"`
Parallel bool `json:"parallel"`
SubscribeQos uint8 `json:"subscribe_qos"`
PublishQos uint8 `json:"publish_qos"`
}
func LoadMqttConfig ¶
func LoadMqttConfig() *MqttConfig
type QueueConfig ¶
func LoadQueueConfig ¶
func LoadQueueConfig() *QueueConfig
type RedisConfig ¶
type RedisConfig struct {
Mode string
SentinelMasterName string
Addr string
Auth string
Db int
MaxActive int
MaxIdle int
IdleTimeout time.Duration
RedisPrefix string
}
func LoadRedisConfig ¶
func LoadRedisConfig() *RedisConfig
type TokenConfig ¶
func LoadTokenConfig ¶
func LoadTokenConfig() *TokenConfig
type WebSocketConfig ¶
type WebSocketConfig struct {
WebSocketHost string `json:"webSocketHost"`
WebSocketPort string `json:"webSocketPort"`
Path string
}
func LoadWebSocketConfig ¶
func LoadWebSocketConfig() *WebSocketConfig
Click to show internal directories.
Click to hide internal directories.