MCPcopy Index your code
hub / github.com/coder/coder / Run

Method Run

coderd/notifications/manager.go:143–159  ·  view source on GitHub ↗

Run initiates the control loop in the background, which spawns a given number of notifier goroutines. Manager requires system-level permissions to interact with the store. Run is only intended to be run once.

(ctx context.Context)

Source from the content-addressed store, hash-verified

141// Manager requires system-level permissions to interact with the store.
142// Run is only intended to be run once.
143func (m *Manager) Run(ctx context.Context) {
144 m.log.Debug(ctx, "notification manager started")
145
146 m.runOnce.Do(func() {
147 // Closes when Stop() is called or context is canceled.
148 pproflabel.Go(ctx, pproflabel.Service(pproflabel.ServiceNotifications), func(ctx context.Context) {
149 err := m.loop(ctx)
150 if err != nil {
151 if xerrors.Is(err, ErrManagerAlreadyClosed) {
152 m.log.Warn(ctx, "notification manager stopped with error", slog.Error(err))
153 } else {
154 m.log.Error(ctx, "notification manager stopped with error", slog.Error(err))
155 }
156 }
157 })
158 })
159}
160
161// loop contains the main business logic of the notification manager. It is responsible for subscribing to notification
162// events, creating a notifier, and publishing bulk dispatch result updates to the store.

Callers 15

TestMetricsFunction · 0.95
TestPendingUpdatesMetricFunction · 0.95
TestSMTPDispatchFunction · 0.95
TestWebhookDispatchFunction · 0.95
TestBackpressureFunction · 0.95
TestRetriesFunction · 0.95
TestNotifierPausedFunction · 0.95

Calls 6

loopMethod · 0.95
GoFunction · 0.92
ServiceFunction · 0.92
DoMethod · 0.65
IsMethod · 0.45
ErrorMethod · 0.45

Tested by 15

TestMetricsFunction · 0.76
TestPendingUpdatesMetricFunction · 0.76
TestSMTPDispatchFunction · 0.76
TestWebhookDispatchFunction · 0.76
TestBackpressureFunction · 0.76
TestRetriesFunction · 0.76
TestNotifierPausedFunction · 0.76