(ctx context.Context)
| 226 | } |
| 227 | |
| 228 | func (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 | |
| 252 | func (l *BasicLifecycler) running(ctx context.Context) error { |
| 253 | heartbeatTickerStop, heartbeatTickerChan := newDisableableTicker(l.cfg.HeartbeatPeriod) |
nothing calls this directly
no test coverage detected