Skip to content

feat(coderd): add new dispatch logic for coder inbox #16764

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finishing up tests
  • Loading branch information
defelmnq committed Mar 3, 2025
commit 61746c85832e1c3af9eacffaef655f7a48efcd4d
2 changes: 1 addition & 1 deletion coderd/notifications/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ type enqueueInterceptor struct {
}

func newEnqueueInterceptor(db notifications.Store, metadataFn func() database.FetchNewMessageMetadataRow) *enqueueInterceptor {
return &enqueueInterceptor{Store: db, payload: make(chan types.MessagePayload, 1), metadataFn: metadataFn}
return &enqueueInterceptor{Store: db, payload: make(chan types.MessagePayload, 2), metadataFn: metadataFn}
}

func (e *enqueueInterceptor) EnqueueNotificationMessage(_ context.Context, arg database.EnqueueNotificationMessageParams) error {
Expand Down
5 changes: 3 additions & 2 deletions coderd/notifications/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,8 @@ func TestInflightDispatchesMetric(t *testing.T) {
// Barrier handler will wait until all notification messages are in-flight.
barrier := newBarrierHandler(msgCount, handler)
mgr.WithHandlers(map[database.NotificationMethod]notifications.Handler{
method: barrier,
method: barrier,
database.NotificationMethodInbox: &fakeHandler{},
})

enq, err := notifications.NewStoreEnqueuer(cfg, store, defaultHelpers(), logger.Named("enqueuer"), quartz.NewReal())
Expand Down Expand Up @@ -381,7 +382,7 @@ func TestInflightDispatchesMetric(t *testing.T) {

// Wait for the updates to be synced and the metric to reflect that.
require.Eventually(t, func() bool {
return promtest.ToFloat64(metrics.InflightDispatches) == 0
return promtest.ToFloat64(metrics.InflightDispatches.WithLabelValues(string(method), tmpl.String())) == 0
}, testutil.WaitShort, testutil.IntervalFast)
}

Expand Down
5 changes: 4 additions & 1 deletion coderd/notifications/notifications_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,10 @@ func TestSMTPDispatch(t *testing.T) {
handler := newDispatchInterceptor(dispatch.NewSMTPHandler(cfg.SMTP, logger.Named("smtp")))
mgr, err := notifications.NewManager(cfg, store, defaultHelpers(), createMetrics(), logger.Named("manager"))
require.NoError(t, err)
mgr.WithHandlers(map[database.NotificationMethod]notifications.Handler{method: handler})
mgr.WithHandlers(map[database.NotificationMethod]notifications.Handler{
method: handler,
database.NotificationMethodInbox: &fakeHandler{},
})
t.Cleanup(func() {
assert.NoError(t, mgr.Stop(ctx))
})
Expand Down
Loading