Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( DefaultLoadFunc = func(kvs []*mvccpb.KeyValue, target any) { data := kvs[0].Value if err := conf.LoadFromYamlBytes(data, target); err != nil { log.Panicf("load and parse config from etcd fail err = %v", err) } } DefaultWatchOnConfigChange = func(evs []*clientv3.Event, target any) { for _, ev := range evs { logx.Sloww(" config has changed", logx.Field("data", string(ev.Kv.Value))) if err := conf.LoadFromYamlBytes(ev.Kv.Value, target); err != nil { logx.Errorw("load and parse config from etcd fail err = %v", logger.ErrorField(err)) } } } )
Functions ¶
func MustLoadFromEtcd ¶
func MustLoadFromEtcd(key string, etcdConfig etcd.EtcdConfig, target any, ops ...ConfigCustomFuncOption)
MustLoadFromEtcd 从etcd中加载配置,有状态的服务从etcd中获取
Types ¶
type ConfigCustomFuncOption ¶
type ConfigCustomFuncOption struct {
// contains filtered or unexported fields
}
func WithCustomInitLoadFunc ¶
func WithCustomInitLoadFunc(f func(kvs []*mvccpb.KeyValue, target any)) ConfigCustomFuncOption
func WithCustomWatchFunc ¶
func WithCustomWatchFunc(f func(evs []*clientv3.Event, target any)) ConfigCustomFuncOption
func WithDefaultInitLoadFunc ¶
func WithDefaultInitLoadFunc() ConfigCustomFuncOption
type ConfigPrefix ¶
type ConfigPrefix string
const ( Prefix = "config" Kline ConfigPrefix = "kline" Ticker ConfigPrefix = "ticker" Match ConfigPrefix = "match" Order ConfigPrefix = "order" )
func (ConfigPrefix) BuildKey ¶
func (c ConfigPrefix) BuildKey(symbol string) string
Click to show internal directories.
Click to hide internal directories.