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

Method StartAsync

services/basic_service.go:118–129  ·  view source on GitHub ↗

StartAsync is part of Service interface.

(parentContext context.Context)

Source from the content-addressed store, hash-verified

116
117// StartAsync is part of Service interface.
118func (b *BasicService) StartAsync(parentContext context.Context) error {
119 switched, oldState := b.switchState(New, Starting, func() {
120 b.serviceContext, b.serviceCancel = context.WithCancel(parentContext)
121 b.notifyListeners(func(l Listener) { l.Starting() }, false)
122 go b.main()
123 })
124
125 if !switched {
126 return invalidServiceStateError(oldState, New)
127 }
128 return nil
129}
130
131// Returns true, if state switch succeeds, false if it fails. Returned state is the state before switch.
132// 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