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

Method ensureRunning

coderd/notifications/notifier.go:130–150  ·  view source on GitHub ↗

ensureRunning checks if notifier is not paused.

(ctx context.Context)

Source from the content-addressed store, hash-verified

128
129// ensureRunning checks if notifier is not paused.
130func (n *notifier) ensureRunning(ctx context.Context) (bool, error) {
131 settingsJSON, err := n.store.GetNotificationsSettings(ctx)
132 if err != nil {
133 return false, xerrors.Errorf("get notifications settings: %w", err)
134 }
135
136 var settings codersdk.NotificationsSettings
137 if len(settingsJSON) == 0 {
138 return true, nil // settings.NotifierPaused is false by default
139 }
140
141 err = json.Unmarshal([]byte(settingsJSON), &settings)
142 if err != nil {
143 return false, xerrors.Errorf("unmarshal notifications settings")
144 }
145
146 if settings.NotifierPaused {
147 n.log.Debug(ctx, "notifier is paused, notifications will not be delivered")
148 }
149 return !settings.NotifierPaused, nil
150}
151
152// process is responsible for coordinating the retrieval, processing, and delivery of messages.
153// Messages are dispatched concurrently, but they may block when success/failure channels are full.

Callers 1

runMethod · 0.95

Calls 3

ErrorfMethod · 0.45
UnmarshalMethod · 0.45

Tested by

no test coverage detected