api配置
rest.RestConf
service.ServiceConf // service配置
Host string `json:",default=0.0.0.0"` // http监听ip,默认0.0.0.0
Port int // http监听端口,必填
CertFile string `json:",optional"` // https证书文件,可选
KeyFile string `json:",optional"` // https私钥文件,可选
Verbose bool `json:",optional"` // 是否打印详细http请求日志
MaxBytes int64 `json:",default=1048576,range=[0:8388608]"` // http可接受请求的最大ContentLength,默认1048576,被设置值不能必须在0到8388608之间
// milliseconds
Timeout int64 `json:",default=3000"` // 超时时长控制,单位:毫秒,默认3000
Signature SignatureConf `json:",optional"` // 签名配置
service.ServiceConf
type ServiceConf struct {
Name string // 服务名称
Log logx.LogConf // 日志配置
Mode string `json:",default=pro,options=dev|test|pre|pro"` // 服务环境,dev-开发环境,test-测试环境,pre-预发环境,pro-正式环境
MetricsUrl string `json:",optional"` // 指标上报接口地址,该地址需要支持post json即可
Prometheus prometheus.Config `json:",optional"` // prometheus配置
}
prometheus.Config
type Config struct {
Host string `json:",optional"` // prometheus 监听host
Port int `json:",default=9101"` // prometheus 监听端口
Path string `json:",default=/metrics"` // 上报地址
SignatureConf
SignatureConf struct {
Expiry time.Duration `json:",default=1h"` // 有效期,默认1小时
PrivateKeys []PrivateKeyConf // 签名密钥相关配置
}
cache.CacheConf
ClusterConf []NodeConf
NodeConf struct {
redis.RedisConf
Weight int `json:",default=100"` // 权重
}
redis.RedisConf
RedisConf struct {
Host string // redis地址
Type string `json:",default=node,options=node|cluster"` // redis类型
Pass string `json:",optional"` // redis密码
}