MCPcopy Index your code
hub / github.com/riverqueue/river / Start

Method Start

internal/maintenance/queue_maintainer.go:45–72  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

43}
44
45func (m *QueueMaintainer) Start(ctx context.Context) error {
46 ctx, shouldStart, started, stopped := m.StartInit(ctx)
47 if !shouldStart {
48 return nil
49 }
50
51 for _, service := range m.servicesByName {
52 if err := service.Start(ctx); err != nil {
53 startstop.StopAllParallel(maputil.Values(m.servicesByName)...)
54 stopped()
55 return err
56 }
57 }
58
59 go func() {
60 // Wait for all subservices to start up before signaling our own start.
61 startstop.WaitAllStarted(maputil.Values(m.servicesByName)...)
62
63 started()
64 defer stopped() // this defer should come first so it's last out
65
66 <-ctx.Done()
67
68 startstop.StopAllParallel(maputil.Values(m.servicesByName)...)
69 }()
70
71 return nil
72}
73
74// GetService is a convenience method for getting a service by name and casting
75// it to the desired type. It should only be used in tests due to its use of

Callers 1

TestQueueMaintainerFunction · 0.95

Calls 6

StopAllParallelFunction · 0.92
ValuesFunction · 0.92
WaitAllStartedFunction · 0.92
StartInitMethod · 0.80
DoneMethod · 0.80
StartMethod · 0.65

Tested by 1

TestQueueMaintainerFunction · 0.76