Documentation
¶
Index ¶
- Constants
- func ClearData(slices ...[]byte)
- func CopyData(b []byte) []byte
- type AmqpConfig
- type FileConfig
- type JwtConfig
- type KeyPair
- type MGOConfig
- type MysqlConfig
- type RedisConfig
- type ServerConfig
- type YamlConfig
- func (c *YamlConfig) CheckReady() bool
- func (c *YamlConfig) GetAllJwtConfigs() map[string]*JwtConfig
- func (c *YamlConfig) GetAllLoggerConfigs() map[string]*ZapConfig
- func (c *YamlConfig) GetAllMongoDBConfigs() map[string]*MGOConfig
- func (c *YamlConfig) GetAllMySQLConfigs() map[string]*MysqlConfig
- func (c *YamlConfig) GetAllRabbitMQConfigs() map[string]*AmqpConfig
- func (c *YamlConfig) GetAllRedisConfigs() map[string]*RedisConfig
- func (c *YamlConfig) GetAllServerConfigs() map[string]*ServerConfig
- func (c *YamlConfig) GetDefaultProject() string
- func (c *YamlConfig) GetJwtConfig(name string) *JwtConfig
- func (c *YamlConfig) GetLoggerConfig(name string) *ZapConfig
- func (c *YamlConfig) GetMongoDBConfig(name string) *MGOConfig
- func (c *YamlConfig) GetMySQLConfig(name string) *MysqlConfig
- func (c *YamlConfig) GetRabbitMQConfig(name string) *AmqpConfig
- func (c *YamlConfig) GetRedisConfig(name string) *RedisConfig
- func (c *YamlConfig) GetServerConfig(name string) *ServerConfig
- func (c *YamlConfig) InitDefaults()
- func (c *YamlConfig) SetDefaultProject(name string)
- type ZapConfig
Constants ¶
const ( MASTER = "master" SEP = "|" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AmqpConfig ¶ added in v1.1.0
type AmqpConfig struct {
DsName string `yaml:"ds_name" json:"DsName"`
Host string `yaml:"host" json:"Host"`
Username string `yaml:"username" json:"Username"`
Password string `yaml:"password" json:"Password"`
Port int `yaml:"port" json:"Port"`
Vhost string `yaml:"vhost" json:"Vhost"`
SecretKey string `yaml:"secret_key" json:"SecretKey"`
}
AmqpConfig RabbitMQ配置 - 与amqp.AmqpConfig字段兼容
type FileConfig ¶ added in v1.1.0
type FileConfig struct {
Filename string `yaml:"filename"`
MaxSize int `yaml:"max_size"`
MaxBackups int `yaml:"max_backups"`
MaxAge int `yaml:"max_age"`
Compress bool `yaml:"compress"`
}
FileConfig 日志文件配置 - 与zlog.FileConfig字段兼容
type JwtConfig ¶ added in v1.1.0
type JwtConfig struct {
// JWT相关字段
TokenKey string `yaml:"token_key,omitempty" json:"TokenKey"`
TokenAlg string `yaml:"token_alg,omitempty" json:"TokenAlg"`
TokenTyp string `yaml:"token_typ,omitempty" json:"TokenTyp"`
TokenExp int64 `yaml:"token_exp,omitempty" json:"TokenExp"`
}
JwtConfig JWT配置 - 同时支持JWT和Server配置
type KeyPair ¶ added in v1.1.0
type KeyPair struct {
Name int64 `yaml:"name"`
PublicKey string `yaml:"public_key"`
PrivateKey string `yaml:"private_key"`
}
KeyPair 密钥对配置
type MGOConfig ¶ added in v1.1.0
type MGOConfig struct {
DsName string `yaml:"ds_name" json:"DsName"`
Addrs []string `yaml:"addrs" json:"Addrs"`
Direct bool `yaml:"direct" json:"Direct"`
ConnectTimeout int64 `yaml:"connect_timeout" json:"ConnectTimeout"`
SocketTimeout int64 `yaml:"socket_timeout" json:"SocketTimeout"`
Database string `yaml:"database" json:"Database"`
Username string `yaml:"username" json:"Username"`
Password string `yaml:"password" json:"Password"`
PoolLimit int `yaml:"pool_limit" json:"PoolLimit"`
}
MGOConfig MongoDB配置 - 与sqld.MGOConfig字段兼容
type MysqlConfig ¶ added in v1.1.0
type MysqlConfig struct {
DsName string `yaml:"ds_name" json:"DsName"`
Host string `yaml:"host" json:"Host"`
Port int `yaml:"port" json:"Port"`
Database string `yaml:"database" json:"Database"`
Username string `yaml:"username" json:"Username"`
Password string `yaml:"password" json:"Password"`
Charset string `yaml:"charset" json:"Charset"`
SlowQuery int64 `yaml:"slow_query" json:"SlowQuery"`
SlowLogPath string `yaml:"slow_log_path" json:"SlowLogPath"`
MaxIdleConns int `yaml:"max_idle_conns" json:"MaxIdleConns"`
MaxOpenConns int `yaml:"max_open_conns" json:"MaxOpenConns"`
ConnMaxLifetime int `yaml:"conn_max_lifetime" json:"ConnMaxLifetime"`
ConnMaxIdleTime int `yaml:"conn_max_idle_time" json:"ConnMaxIdleTime"`
}
MysqlConfig MySQL配置 - 与sqld.MysqlConfig字段兼容
type RedisConfig ¶ added in v1.1.0
type RedisConfig struct {
DsName string `yaml:"ds_name" json:"DsName"`
Host string `yaml:"host" json:"Host"`
Port int `yaml:"port" json:"Port"`
Password string `yaml:"password" json:"Password"`
MaxIdle int `yaml:"max_idle" json:"MaxIdle"`
MaxActive int `yaml:"max_active" json:"MaxActive"`
IdleTimeout int `yaml:"idle_timeout" json:"IdleTimeout"`
Network string `yaml:"network" json:"Network"`
}
RedisConfig Redis配置 - 与cache.RedisConfig字段兼容
type ServerConfig ¶ added in v1.1.0
type ServerConfig struct {
Name string `yaml:"name"`
Version string `yaml:"version"`
Debug bool `yaml:"debug"`
Env string `yaml:"env"`
Addr string `yaml:"addr"`
Port int `yaml:"port"`
SecretKey string `yaml:"secret_key"`
GCLimitMB int `yaml:"gc_limit_mb"`
GCPercent int `yaml:"gc_percent"`
Keys []KeyPair `yaml:"keys,omitempty"`
}
func (*ServerConfig) GetAllKeyPairs ¶ added in v1.1.0
func (s *ServerConfig) GetAllKeyPairs() []KeyPair
GetAllKeyPairs 获取所有密钥对
func (*ServerConfig) GetDefaultKeyPair ¶ added in v1.1.0
func (s *ServerConfig) GetDefaultKeyPair() *KeyPair
GetDefaultKeyPair 获取默认密钥对(第一个)
func (*ServerConfig) GetKeyPairByName ¶ added in v1.1.0
func (s *ServerConfig) GetKeyPairByName(name int64) *KeyPair
GetKeyPairByName 根据名称获取密钥对
type YamlConfig ¶ added in v1.1.0
type YamlConfig struct {
// RabbitMQ配置 - 支持多数据源,key为数据源名称
RabbitMQ map[string]*AmqpConfig `yaml:"rabbitmq,omitempty"`
// MySQL配置 - 支持多数据源,key为数据源名称
MySQL map[string]*MysqlConfig `yaml:"mysql,omitempty"`
// MongoDB配置 - 支持多数据源,key为数据源名称
MongoDB map[string]*MGOConfig `yaml:"mongodb,omitempty"`
// Redis配置 - 支持多数据源,key为数据源名称
Redis map[string]*RedisConfig `yaml:"redis,omitempty"`
// 日志配置 - 支持多日志输出器,key为日志器名称
Logger map[string]*ZapConfig `yaml:"logger,omitempty"`
// JWT配置 - 支持多JWT配置,key为配置名称
JWT map[string]*JwtConfig `yaml:"jwt,omitempty"`
// 应用基本信息
Server map[string]*ServerConfig `yaml:"server,omitempty"`
// contains filtered or unexported fields
}
YamlConfig 通用配置结构体 - 支持多数据源配置 注意:为避免循环依赖,这里重新定义了配置结构体 这些结构体与各包中原有结构体字段相同,但为了YAML配置读取的便利性而存在
func (*YamlConfig) CheckReady ¶ added in v1.1.0
func (c *YamlConfig) CheckReady() bool
CheckReady 判定是否已经初始化成功
func (*YamlConfig) GetAllJwtConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllJwtConfigs() map[string]*JwtConfig
GetAllJwtConfigs 获取所有JWT配置
func (*YamlConfig) GetAllLoggerConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllLoggerConfigs() map[string]*ZapConfig
GetAllLoggerConfigs 获取所有日志配置
func (*YamlConfig) GetAllMongoDBConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllMongoDBConfigs() map[string]*MGOConfig
GetAllMongoDBConfigs 获取所有MongoDB配置
func (*YamlConfig) GetAllMySQLConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllMySQLConfigs() map[string]*MysqlConfig
GetAllMySQLConfigs 获取所有MySQL配置
func (*YamlConfig) GetAllRabbitMQConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllRabbitMQConfigs() map[string]*AmqpConfig
GetAllRabbitMQConfigs 获取所有RabbitMQ配置
func (*YamlConfig) GetAllRedisConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllRedisConfigs() map[string]*RedisConfig
GetAllRedisConfigs 获取所有Redis配置
func (*YamlConfig) GetAllServerConfigs ¶ added in v1.1.0
func (c *YamlConfig) GetAllServerConfigs() map[string]*ServerConfig
GetAllServerConfigs 获取所有服务器配置
func (*YamlConfig) GetDefaultProject ¶ added in v1.1.2
func (c *YamlConfig) GetDefaultProject() string
GetDefaultProject 获取默认的项目名
func (*YamlConfig) GetJwtConfig ¶ added in v1.1.0
func (c *YamlConfig) GetJwtConfig(name string) *JwtConfig
GetJwtConfig 获取指定名称的JWT配置
func (*YamlConfig) GetLoggerConfig ¶ added in v1.1.0
func (c *YamlConfig) GetLoggerConfig(name string) *ZapConfig
GetLoggerConfig 获取指定名称的日志配置
func (*YamlConfig) GetMongoDBConfig ¶ added in v1.1.0
func (c *YamlConfig) GetMongoDBConfig(name string) *MGOConfig
GetMongoDBConfig 获取指定名称的MongoDB配置
func (*YamlConfig) GetMySQLConfig ¶ added in v1.1.0
func (c *YamlConfig) GetMySQLConfig(name string) *MysqlConfig
GetMySQLConfig 获取指定名称的MySQL配置
func (*YamlConfig) GetRabbitMQConfig ¶ added in v1.1.0
func (c *YamlConfig) GetRabbitMQConfig(name string) *AmqpConfig
GetRabbitMQConfig 获取指定名称的RabbitMQ配置
func (*YamlConfig) GetRedisConfig ¶ added in v1.1.0
func (c *YamlConfig) GetRedisConfig(name string) *RedisConfig
GetRedisConfig 获取指定名称的Redis配置
func (*YamlConfig) GetServerConfig ¶ added in v1.1.0
func (c *YamlConfig) GetServerConfig(name string) *ServerConfig
GetServerConfig 获取指定名称的服务器配置
func (*YamlConfig) InitDefaults ¶ added in v1.1.0
func (c *YamlConfig) InitDefaults()
InitDefaults 初始化默认值,避免nil map
func (*YamlConfig) SetDefaultProject ¶ added in v1.1.2
func (c *YamlConfig) SetDefaultProject(name string)
SetDefaultProject 设置默认的项目名