MCPcopy
hub / github.com/grafana/dskit / WaitInstanceState

Function WaitInstanceState

ring/util.go:43–59  ·  view source on GitHub ↗

WaitInstanceState waits until the input instanceID is registered within the ring matching the provided state. A timeout should be provided within the context.

(ctx context.Context, r ReadRing, instanceID string, state InstanceState)

Source from the content-addressed store, hash-verified

41// WaitInstanceState waits until the input instanceID is registered within the
42// ring matching the provided state. A timeout should be provided within the context.
43func WaitInstanceState(ctx context.Context, r ReadRing, instanceID string, state InstanceState) error {
44 backoff := backoff.New(ctx, backoff.Config{
45 MinBackoff: 100 * time.Millisecond,
46 MaxBackoff: time.Second,
47 MaxRetries: 0,
48 })
49
50 for backoff.Ongoing() {
51 if actualState, err := r.GetInstanceState(instanceID); err == nil && actualState == state {
52 return nil
53 }
54
55 backoff.Wait()
56 }
57
58 return backoff.Err()
59}
60
61// WaitRingStability monitors the ring topology for the provided operation and waits until it
62// keeps stable for at least minStability.

Calls 5

NewFunction · 0.92
OngoingMethod · 0.80
GetInstanceStateMethod · 0.65
WaitMethod · 0.45
ErrMethod · 0.45