Files
2022-02-08 11:05:47 +08:00

98 lines
2.1 KiB
Go

package config
var (
SettingInfo = new(Setting)
EngineInfo = new(Engine)
//RPCServerSettingInfo = new(RPCServerSetting)
)
// Mysql 配置
type Mysql struct {
Database string `yaml:"database"`
Host string `yaml:"host"`
Port int `yaml:"port"`
Username string `yaml:"username"`
Password string `yaml:"password"`
Parameters string `yaml:"parameters"`
}
// Sqlite 配置
type Sqlite struct {
Path string `yaml:"path"`
Name string `yaml:"name"`
}
// RPCServer RPC Server服务
type RPCServer struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
IsTLS bool `yaml:"is_tls"`
TLSName string `yaml:"tls_name"`
Pem string `yaml:"pem"`
Key string `yaml:"key"`
}
// Redis 配置
type Redis struct {
Addr string `yaml:"addr"`
Password string `yaml:"password"`
DB int `yaml:"db"`
MaxActive int `yaml:"max_active"`
MaxIdle int `yaml:"max_idle"`
IdleTimeout int `yaml:"idle_timeout"`
}
// Setting 配置信息
type Setting struct {
// Server 配置
Server struct {
Port int `yaml:"port"`
ReadTimeout int `yaml:"read_timeout"`
WriteTimeout int `yaml:"write_timeout"`
IdleTimeout int `yaml:"idle_timeout"`
}
// ESServer 配置
ESServer struct {
Host string `yaml:"host"`
} `yaml:"es_server"`
// Rate 限流器
Rate struct {
Limit int `yaml:"limit"`
Capacity int `yaml:"capacity"`
}
// Cache 缓存配置
Cache struct {
Type string `yaml:"type"`
Redis *Redis `yaml:"redis"`
}
// Log 配置
Log struct {
File string `yaml:"file"`
LeastDay uint `yaml:"least_day"`
Level string `yaml:"level"`
}
}
// Engine 配置
type Engine struct {
Debug bool `yaml:"debug"`
Mode string `yaml:"mode"`
MaxLifetime int `yaml:"max_lifetime"`
MaxOpenConns int `yaml:"max_open_conns"`
MaxIdleConns int `yaml:"max_idle_conns"`
Engines struct {
Mysql *Mysql `yaml:"mysql"`
Sqlite *Sqlite `yaml:"sqlite"`
} `yaml:"engines"`
}
// RPCServerSetting 配置
type RPCServerSetting struct {
Key int `yaml:"key"`
Servers map[string]*RPCServer `yaml:"servers"`
}