(ctx context.Context)
| 393 | } |
| 394 | |
| 395 | func (r *Ring) loop(ctx context.Context) error { |
| 396 | // Update the ring metrics at start of the main loop. |
| 397 | r.mtx.Lock() |
| 398 | r.updateRingMetrics() |
| 399 | r.mtx.Unlock() |
| 400 | |
| 401 | r.KVClient.WatchKey(ctx, r.key, func(value interface{}) bool { |
| 402 | if value == nil { |
| 403 | level.Info(r.logger).Log("msg", "ring doesn't exist in KV store yet") |
| 404 | return true |
| 405 | } |
| 406 | |
| 407 | r.updateRingState(value.(*Desc)) |
| 408 | return true |
| 409 | }) |
| 410 | return nil |
| 411 | } |
| 412 | |
| 413 | func (r *Ring) updateRingState(ringDesc *Desc) { |
| 414 | r.mtx.RLock() |
nothing calls this directly
no test coverage detected