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

Method run

ring/basic_lifecycler.go:583–600  ·  view source on GitHub ↗

run a function within the lifecycler service goroutine.

(fn func() error)

Source from the content-addressed store, hash-verified

581
582// run a function within the lifecycler service goroutine.
583func (l *BasicLifecycler) run(fn func() error) error {
584 sc := l.ServiceContext()
585 if sc == nil {
586 return errors.New("lifecycler not running")
587 }
588
589 errCh := make(chan error)
590 wrappedFn := func() {
591 errCh <- fn()
592 }
593
594 select {
595 case <-sc.Done():
596 return errors.New("lifecycler not running")
597 case l.actorChan <- wrappedFn:
598 return <-errCh
599 }
600}
601
602func (l *BasicLifecycler) casRing(ctx context.Context, f func(in interface{}) (out interface{}, retry bool, err error)) error {
603 return l.store.CAS(ctx, l.ringKey, f)

Callers 4

ChangeStateMethod · 0.95
ChangeReadOnlyStateMethod · 0.95
TestDefaultResultTrackerFunction · 0.45

Calls 2

ServiceContextMethod · 0.80
DoneMethod · 0.65

Tested by 2

TestDefaultResultTrackerFunction · 0.36