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

Method heartbeat

ring/basic_lifecycler.go:519–532  ·  view source on GitHub ↗

heartbeat updates the instance timestamp within the ring. This function is guaranteed to be called within the lifecycler main goroutine.

(ctx context.Context)

Source from the content-addressed store, hash-verified

517// heartbeat updates the instance timestamp within the ring. This function is guaranteed
518// to be called within the lifecycler main goroutine.
519func (l *BasicLifecycler) heartbeat(ctx context.Context) {
520 err := l.updateInstance(ctx, func(r *Desc, i *InstanceDesc) bool {
521 l.delegate.OnRingInstanceHeartbeat(l, r, i)
522 i.Timestamp = time.Now().Unix()
523 return true
524 })
525
526 if err != nil {
527 level.Warn(l.logger).Log("msg", "failed to heartbeat instance in the ring", "ring", l.ringName, "err", err)
528 return
529 }
530
531 l.metrics.heartbeats.Inc()
532}
533
534// changeState of the instance within the ring. This function is guaranteed
535// to be called within the lifecycler main goroutine.

Callers 3

runningMethod · 0.95
stoppingMethod · 0.95
waitStableTokensMethod · 0.95

Calls 3

updateInstanceMethod · 0.95
LogMethod · 0.45

Tested by

no test coverage detected