44 lines
1.3 KiB
Go
44 lines
1.3 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 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"`
|
||
|
|
}
|
||
|
|
|
||
|
|
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)
|
||
|
|
}
|