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

Struct mockKV

kv/etcd/mock.go:70–84  ·  view source on GitHub ↗

mockKV is an in-memory implementation of an Etcd client. This implementation has many limitations compared to the real client since it only exists to be used by the Etcd kv.Client implementation during unit tests. As such some behavior may be missing or incorrect compared to the real client. This i

Source from the content-addressed store, hash-verified

68// - There may be inconsistencies with how various version numbers are adjusted
69// but none that are exposed by kv.Client unit tests
70type mockKV struct {
71 // Key-value pairs created by put calls or transactions
72 values map[string]mvccpb.KeyValue
73 valuesMtx sync.Mutex
74
75 // Channel for stopping all running watch goroutines and closing
76 // and cleaning up all channels used for sending events to watchers
77 close chan struct{}
78
79 // Channels that should receive events in response to Put or Delete
80 // calls. These channels are in turn read by goroutines that apply
81 // filtering before sending watch responses to their callers.
82 events map[chan clientv3.Event]struct{}
83 eventsMtx sync.Mutex
84}
85
86// Watch implements the Clientv3Facade interface
87func (m *mockKV) Watch(ctx context.Context, key string, opts ...clientv3.OpOption) clientv3.WatchChan {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected