MCPcopy Create free account
hub / github.com/cortexproject/cortex / StartAsync

Method StartAsync

pkg/util/services/basic_service.go:115–126  ·  view source on GitHub ↗

StartAsync is part of Service interface.

(parentContext context.Context)

Source from the content-addressed store, hash-verified

113
114// StartAsync is part of Service interface.
115func (b *BasicService) StartAsync(parentContext context.Context) error {
116 switched, oldState := b.switchState(New, Starting, func() {
117 b.serviceContext, b.serviceCancel = context.WithCancel(parentContext)
118 b.notifyListeners(func(l Listener) { l.Starting() }, false)
119 go b.main()
120 })
121
122 if !switched {
123 return invalidServiceStateError(oldState, New)
124 }
125 return nil
126}
127
128// Returns true, if state switch succeeds, false if it fails. Returned state is the state before switch.
129// if state switching succeeds, stateFn runs with lock held.

Calls 5

switchStateMethod · 0.95
notifyListenersMethod · 0.95
mainMethod · 0.95
invalidServiceStateErrorFunction · 0.85
StartingMethod · 0.65