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

Function NewStoreEnqueuer

coderd/notifications/enqueuer.go:52–72  ·  view source on GitHub ↗

NewStoreEnqueuer creates an Enqueuer implementation which can persist notification messages in the store.

(cfg codersdk.NotificationsConfig, store Store, helpers template.FuncMap, log slog.Logger, clock quartz.Clock)

Source from the content-addressed store, hash-verified

50
51// NewStoreEnqueuer creates an Enqueuer implementation which can persist notification messages in the store.
52func NewStoreEnqueuer(cfg codersdk.NotificationsConfig, store Store, helpers template.FuncMap, log slog.Logger, clock quartz.Clock) (*StoreEnqueuer, error) {
53 var method database.NotificationMethod
54 // TODO(DanielleMaywood):
55 // Currently we do not want to allow setting `inbox` as the default notification method.
56 // As of 2025-03-25, setting this to `inbox` would cause a crash on the deployment
57 // notification settings page. Until we make a future decision on this we want to disallow
58 // setting it.
59 if err := method.Scan(cfg.Method.String()); err != nil || method == database.NotificationMethodInbox {
60 return nil, InvalidDefaultNotificationMethodError{Method: cfg.Method.String()}
61 }
62
63 return &StoreEnqueuer{
64 store: store,
65 log: log,
66 defaultMethod: method,
67 defaultEnabled: cfg.Enabled(),
68 inboxEnabled: cfg.Inbox.Enabled.Value(),
69 helpers: helpers,
70 clock: clock,
71 }, nil
72}
73
74// Enqueue queues a notification message for later delivery, assumes no structured input data.
75// Returns the IDs of successfully enqueued messages, if any.

Callers 15

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

Calls 4

ScanMethod · 0.95
EnabledMethod · 0.65
StringMethod · 0.45
ValueMethod · 0.45

Tested by 15

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