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

Function WaitInstanceState

pkg/ring/util.go:44–60  ·  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

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

Calls 5

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