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

Method changeState

ring/basic_lifecycler.go:536–552  ·  view source on GitHub ↗

changeState of the instance within the ring. This function is guaranteed to be called within the lifecycler main goroutine.

(ctx context.Context, state InstanceState)

Source from the content-addressed store, hash-verified

534// changeState of the instance within the ring. This function is guaranteed
535// to be called within the lifecycler main goroutine.
536func (l *BasicLifecycler) changeState(ctx context.Context, state InstanceState) error {
537 err := l.updateInstance(ctx, func(_ *Desc, i *InstanceDesc) bool {
538 // No-op if the state hasn't changed.
539 if i.State == state {
540 return false
541 }
542
543 i.State = state
544 return true
545 })
546
547 if err != nil {
548 level.Warn(l.logger).Log("msg", "failed to change instance state in the ring", "from", l.GetState(), "to", state, "err", err)
549 }
550
551 return err
552}
553
554func (l *BasicLifecycler) changeReadOnlyState(ctx context.Context, readOnly bool) error {
555 err := l.updateInstance(ctx, func(_ *Desc, i *InstanceDesc) bool {

Callers 1

ChangeStateMethod · 0.95

Calls 3

updateInstanceMethod · 0.95
GetStateMethod · 0.95
LogMethod · 0.45

Tested by

no test coverage detected