MCPcopy Create free account
hub / github.com/cortexproject/cortex / NewMultiClient

Function NewMultiClient

pkg/ring/kv/multi.go:89–112  ·  view source on GitHub ↗

NewMultiClient creates new MultiClient with given KV Clients. First client in the slice is the primary client.

(cfg MultiConfig, clients []kvclient, logger log.Logger, registerer prometheus.Registerer)

Source from the content-addressed store, hash-verified

87// NewMultiClient creates new MultiClient with given KV Clients.
88// First client in the slice is the primary client.
89func NewMultiClient(cfg MultiConfig, clients []kvclient, logger log.Logger, registerer prometheus.Registerer) *MultiClient {
90 c := &MultiClient{
91 clients: clients,
92 primaryID: atomic.NewInt32(0),
93 inProgress: map[int]clientInProgress{},
94
95 mirrorTimeout: cfg.MirrorTimeout,
96 mirroringEnabled: atomic.NewBool(cfg.MirrorEnabled),
97
98 logger: log.With(logger, "component", "multikv"),
99 }
100
101 ctx, cancelFn := context.WithCancel(context.Background())
102 c.cancel = cancelFn
103
104 if cfg.ConfigProvider != nil {
105 go c.watchConfigChannel(ctx, cfg.ConfigProvider())
106 }
107
108 c.registerMetrics(registerer)
109 c.updatePrimaryStoreGauge()
110 c.updateMirrorEnabledGauge()
111 return c
112}
113
114func (m *MultiClient) watchConfigChannel(ctx context.Context, configChannel <-chan MultiRuntimeConfig) {
115 for {

Callers 1

buildMultiClientFunction · 0.85

Calls 4

watchConfigChannelMethod · 0.95
registerMetricsMethod · 0.95

Tested by

no test coverage detected