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

Method watchConfigChannel

pkg/ring/kv/multi.go:114–145  ·  view source on GitHub ↗
(ctx context.Context, configChannel <-chan MultiRuntimeConfig)

Source from the content-addressed store, hash-verified

112}
113
114func (m *MultiClient) watchConfigChannel(ctx context.Context, configChannel <-chan MultiRuntimeConfig) {
115 for {
116 select {
117 case cfg, ok := <-configChannel:
118 if !ok {
119 return
120 }
121
122 if cfg.Mirroring != nil {
123 enabled := *cfg.Mirroring
124 old := m.mirroringEnabled.Swap(enabled)
125 if old != enabled {
126 level.Info(m.logger).Log("msg", "toggled mirroring", "enabled", enabled)
127 }
128 m.updateMirrorEnabledGauge()
129 }
130
131 if cfg.PrimaryStore != "" {
132 switched, err := m.setNewPrimaryClient(cfg.PrimaryStore)
133 if switched {
134 level.Info(m.logger).Log("msg", "switched primary KV store", "primary", cfg.PrimaryStore)
135 }
136 if err != nil {
137 level.Error(m.logger).Log("msg", "failed to switch primary KV store", "primary", cfg.PrimaryStore, "err", err)
138 }
139 }
140
141 case <-ctx.Done():
142 return
143 }
144 }
145}
146
147func (m *MultiClient) getPrimaryClient() (int, kvclient) {
148 v := m.primaryID.Load()

Callers 1

NewMultiClientFunction · 0.95

Calls 6

setNewPrimaryClientMethod · 0.95
DoneMethod · 0.80
SwapMethod · 0.45
LogMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected