Files
logs/internal/config/config.go

52 lines
1.6 KiB
Go
Raw Normal View History

2026-03-30 15:26:16 +08:00
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"`
}
2026-04-27 19:26:57 +08:00
type ResourceEventConf struct {
// HMACSecret 用于校验 dc-control 推送签名X-Event-Signature
HMACSecret string `yaml:"hmac_secret"`
// MaxSkewSecs 允许事件时间与服务端时间的最大偏差(秒)。
MaxSkewSecs int `yaml:"max_skew_secs"`
}
2026-03-30 15:26:16 +08:00
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"`
2026-04-27 19:26:57 +08:00
ResourceEvent ResourceEventConf `yaml:"ResourceEvent"`
2026-03-30 15:26:16 +08:00
}
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)
}