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