Files
logs/internal/config/config.go
2026-04-27 19:26:57 +08:00

52 lines
1.6 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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)
}