package config import ( "reflect" cdr "git.loafle.net/commons/di-go/registry" "git.loafle.net/commons/logging-go" cur "git.loafle.net/commons/util-go/reflect" ocpc "git.loafle.net/overflow/commons-go/probe/config" ) const ( ConfigKey = "Config" ) type Config struct { Account *ocpc.Account `required:"true" json:"account" yaml:"account" toml:"account"` Central *ocpc.Central `required:"true" json:"central" yaml:"central" toml:"central"` Probe *ocpc.Probe `required:"true" json:"probe" yaml:"probe" toml:"probe"` } func GetConfig() *Config { _config, err := cdr.GetInstanceByName(ConfigKey) if nil != err { logging.Logger().Error(err) return nil } config, ok := _config.(*Config) if !ok { _, pkg, n := cur.GetTypeInfo(reflect.TypeOf(_config)) logging.Logger().Errorf("Cannot convert [%s]%s to Config type", pkg, n) return nil } return config }