52 lines
1.6 KiB
Go
52 lines
1.6 KiB
Go
package config
|
||
|
||
import (
|
||
"net"
|
||
|
||
"git.apinb.com/bsm-sdk/core/conf"
|
||
)
|
||
|
||
var Spec SrvConfig
|
||
|
||
type AlertForwardConf struct {
|
||
BaseURL string `yaml:"base_url"`
|
||
InternalKey string `yaml:"internal_key"`
|
||
Enabled bool `yaml:"enabled"`
|
||
DefaultPolicyID uint `yaml:"default_policy_id"`
|
||
}
|
||
|
||
type IngestConf struct {
|
||
SyslogListenAddr string `yaml:"syslog_listen_addr"`
|
||
TrapListenAddr string `yaml:"trap_listen_addr"`
|
||
RuleRefreshSecs int `yaml:"rule_refresh_secs"`
|
||
}
|
||
|
||
type ResourceEventConf struct {
|
||
// HMACSecret 用于校验 dc-control 推送签名(X-Event-Signature)。
|
||
HMACSecret string `yaml:"hmac_secret"`
|
||
// MaxSkewSecs 允许事件时间与服务端时间的最大偏差(秒)。
|
||
MaxSkewSecs int `yaml:"max_skew_secs"`
|
||
}
|
||
|
||
type SrvConfig struct {
|
||
conf.Base `yaml:",inline"`
|
||
Databases *conf.DBConf `yaml:"Databases"`
|
||
MicroService *conf.MicroServiceConf `yaml:"MicroService"`
|
||
Rpc map[string]conf.RpcConf `yaml:"Rpc"`
|
||
Gateway *conf.GatewayConf `yaml:"Gateway"`
|
||
Apm *conf.ApmConf `yaml:"APM"`
|
||
Etcd *conf.EtcdConf `yaml:"Etcd"`
|
||
AlertForward *AlertForwardConf `yaml:"AlertForward"`
|
||
Ingest IngestConf `yaml:"Ingest"`
|
||
ResourceEvent ResourceEventConf `yaml:"ResourceEvent"`
|
||
}
|
||
|
||
func New(srvKey string) {
|
||
conf.New(srvKey, &Spec)
|
||
Spec.Port = conf.CheckPort(Spec.Port)
|
||
Spec.BindIP = conf.CheckIP(Spec.BindIP)
|
||
Spec.Addr = net.JoinHostPort(Spec.BindIP, Spec.Port)
|
||
conf.NotNil(Spec.Service, Spec.Cache)
|
||
conf.PrintInfo(Spec.Addr)
|
||
}
|