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

Method awaitState

services/basic_service.go:296–313  ·  view source on GitHub ↗
(ctx context.Context, expectedState State, ch chan struct{})

Source from the content-addressed store, hash-verified

294}
295
296func (b *BasicService) awaitState(ctx context.Context, expectedState State, ch chan struct{}) error {
297 select {
298 case <-ctx.Done():
299 return ctx.Err()
300 case <-ch:
301 s := b.State()
302 if s == expectedState {
303 return nil
304 }
305
306 // if service has failed, include failure case in the returned error.
307 if failure := b.FailureCase(); failure != nil {
308 return invalidServiceStateWithFailureError(s, expectedState, failure)
309 }
310
311 return invalidServiceStateError(s, expectedState)
312 }
313}
314
315// FailureCase is part of Service interface.
316func (b *BasicService) FailureCase() error {

Callers 2

AwaitRunningMethod · 0.95
AwaitTerminatedMethod · 0.95

Calls 6

StateMethod · 0.95
FailureCaseMethod · 0.95
invalidServiceStateErrorFunction · 0.85
DoneMethod · 0.65
ErrMethod · 0.45

Tested by

no test coverage detected