MCPcopy
hub / github.com/grafana/dskit / GetMemberlistKV

Method GetMemberlistKV

kv/memberlist/kv_init_service.go:49–64  ·  view source on GitHub ↗

GetMemberlistKV will initialize Memberlist.KV on first call, and add it to service failure watcher.

()

Source from the content-addressed store, hash-verified

47
48// GetMemberlistKV will initialize Memberlist.KV on first call, and add it to service failure watcher.
49func (kvs *KVInitService) GetMemberlistKV() (*KV, error) {
50 // Validate WatchPrefixBufferSize before initialization
51 if kvs.cfg.WatchPrefixBufferSize <= 0 {
52 return nil, fmt.Errorf("invalid WatchPrefixBufferSize: must be greater than 0")
53 }
54
55 kvs.init.Do(func() {
56 kv := NewKV(*kvs.cfg, kvs.logger, kvs.dnsProvider, kvs.registerer)
57 kvs.watcher.WatchService(kv)
58 kvs.err = kv.StartAsync(context.Background())
59
60 kvs.kv.Store(kv)
61 })
62
63 return kvs.getKV(), kvs.err
64}
65
66// Returns KV if it was initialized, or nil.
67func (kvs *KVInitService) getKV() *KV {

Callers 4

TestPageFunction · 0.95
runClusterFunction · 0.80
runClientFunction · 0.80

Calls 6

getKVMethod · 0.95
NewKVFunction · 0.85
ErrorfMethod · 0.80
WatchServiceMethod · 0.80
StartAsyncMethod · 0.65
DoMethod · 0.45

Tested by 2

TestPageFunction · 0.76