You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.5 KiB
38 lines
1.5 KiB
package analyze
|
|
|
|
import (
|
|
"yunyan/lego/utils/mapstructure"
|
|
"yunyan/modules"
|
|
)
|
|
|
|
type Options struct {
|
|
modules.Options
|
|
AppName string // 本部署应用名称;落 stats_global_day.app_id。统计上报的核心维度。
|
|
// ⚠️ 须与 console 注册表的 app_registry.**name** 列完全一致(大小写敏感):console 消费端
|
|
// isRegisteredApp() 就是拿它查 `name=?`,对不上整条快照丢弃且只留一行 WARN 日志。
|
|
// 同时它也是 comm.AppName()(按应用作用域读配置,认 app_name 列),故注册时两列须同值。
|
|
Region int32 // 本部署所属区域;取值见 pb.Region 枚举。每区域只写自己的行,多区域同步不冲突
|
|
SyncInterval int // Redis→DB 同步间隔(秒),默认 600;设为 86400 即每天同步一次
|
|
Subject string // 转发到运维服务的 NATS subject(如 stats.event);为空则不转发(双写过渡开关)
|
|
Timezone string // 统计日界时区,默认 Asia/Shanghai;决定 0 点切日口径,须与 console 端一致
|
|
}
|
|
|
|
// AppKey 返回落库用的应用标识(app_id 列),即配置的应用名称。
|
|
func (this *Options) AppKey() string {
|
|
return this.AppName
|
|
}
|
|
|
|
func (this *Options) LoadConfig(settings map[string]interface{}) (err error) {
|
|
if settings != nil {
|
|
if err = this.Options.LoadConfig(settings); err != nil {
|
|
return
|
|
}
|
|
if err = mapstructure.Decode(settings, this); err != nil {
|
|
return
|
|
}
|
|
}
|
|
if this.SyncInterval <= 0 {
|
|
this.SyncInterval = 600
|
|
}
|
|
return
|
|
}
|
|
|