(ctx context.Context)
| 377 | } |
| 378 | |
| 379 | func (r *Ring) starting(ctx context.Context) error { |
| 380 | // Get the initial ring state so that, as soon as the service will be running, the in-memory |
| 381 | // ring would be already populated and there's no race condition between when the service is |
| 382 | // running and the WatchKey() callback is called for the first time. |
| 383 | value, err := r.KVClient.Get(ctx, r.key) |
| 384 | if err != nil { |
| 385 | return errors.Wrap(err, "unable to initialise ring state") |
| 386 | } |
| 387 | if value != nil { |
| 388 | r.updateRingState(value.(*Desc)) |
| 389 | } else { |
| 390 | level.Info(r.logger).Log("msg", "ring doesn't exist in KV store yet") |
| 391 | } |
| 392 | return nil |
| 393 | } |
| 394 | |
| 395 | func (r *Ring) loop(ctx context.Context) error { |
| 396 | // Update the ring metrics at start of the main loop. |
nothing calls this directly
no test coverage detected