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

Method starting

ring/basic_lifecycler.go:228–250  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

226}
227
228func (l *BasicLifecycler) starting(ctx context.Context) error {
229 if err := l.registerInstance(ctx); err != nil {
230 return errors.Wrap(err, "register instance in the ring")
231 }
232
233 // If we have registered an instance with some tokens and
234 // an observe period has been configured, we should now wait
235 // until tokens are "stable" within the ring.
236 if len(l.GetTokens()) > 0 && l.cfg.TokensObservePeriod > 0 {
237 if err := l.waitStableTokens(ctx, l.cfg.TokensObservePeriod); err != nil {
238 return errors.Wrap(err, "wait stable tokens in the ring")
239 }
240 }
241
242 // At this point, if some tokens have been set they're stable and we
243 // can notify the delegate.
244 if tokens := l.GetTokens(); len(tokens) > 0 {
245 l.metrics.tokensOwned.Set(float64(len(tokens)))
246 l.delegate.OnRingInstanceTokens(l, tokens)
247 }
248
249 return nil
250}
251
252func (l *BasicLifecycler) running(ctx context.Context) error {
253 heartbeatTickerStop, heartbeatTickerChan := newDisableableTicker(l.cfg.HeartbeatPeriod)

Callers

nothing calls this directly

Calls 6

registerInstanceMethod · 0.95
GetTokensMethod · 0.95
waitStableTokensMethod · 0.95
WrapMethod · 0.65
SetMethod · 0.65
OnRingInstanceTokensMethod · 0.65

Tested by

no test coverage detected