Skip to content

Commit 102a245

Browse files
committed
enqueue with data
1 parent bf7737d commit 102a245

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

coderd/notifications/enqueuer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ func NewStoreEnqueuer(cfg codersdk.NotificationsConfig, store Store, helpers tem
5454

5555
// Enqueue queues a notification message for later delivery, assumes no structured input data.
5656
func (s *StoreEnqueuer) Enqueue(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
57-
return s.EnqueueData(ctx, userID, templateID, labels, nil, createdBy, targets...)
57+
return s.EnqueueWithData(ctx, userID, templateID, labels, nil, createdBy, targets...)
5858
}
5959

6060
// Enqueue queues a notification message for later delivery.
6161
// Messages will be dequeued by a notifier later and dispatched.
62-
func (s *StoreEnqueuer) EnqueueData(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, data map[string]any, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
62+
func (s *StoreEnqueuer) EnqueueWithData(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, data map[string]any, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
6363
metadata, err := s.store.FetchNewMessageMetadata(ctx, database.FetchNewMessageMetadataParams{
6464
UserID: userID,
6565
NotificationTemplateID: templateID,
@@ -170,7 +170,7 @@ func (*NoopEnqueuer) Enqueue(context.Context, uuid.UUID, uuid.UUID, map[string]s
170170
return nil, nil
171171
}
172172

173-
func (*NoopEnqueuer) EnqueueData(context.Context, uuid.UUID, uuid.UUID, map[string]string, map[string]any, string, ...uuid.UUID) (*uuid.UUID, error) {
173+
func (*NoopEnqueuer) EnqueueWithData(context.Context, uuid.UUID, uuid.UUID, map[string]string, map[string]any, string, ...uuid.UUID) (*uuid.UUID, error) {
174174
// nolint:nilnil // irrelevant.
175175
return nil, nil
176176
}

coderd/notifications/reports/generator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func reportFailedWorkspaceBuilds(ctx context.Context, logger slog.Logger, db dat
166166
templateDisplayName = stats.TemplateName
167167
}
168168

169-
if _, err := enqueuer.EnqueueData(ctx, templateAdmin.ID, notifications.TemplateWorkspaceBuildsFailedReport,
169+
if _, err := enqueuer.EnqueueWithData(ctx, templateAdmin.ID, notifications.TemplateWorkspaceBuildsFailedReport,
170170
map[string]string{
171171
"template_name": stats.TemplateName,
172172
"template_display_name": templateDisplayName,

coderd/notifications/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ type Handler interface {
3333
// Enqueuer enqueues a new notification message in the store and returns its ID, should it enqueue without failure.
3434
type Enqueuer interface {
3535
Enqueue(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error)
36-
EnqueueData(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, data map[string]any, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error)
36+
EnqueueWithData(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, data map[string]any, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error)
3737
}

testutil/notifications.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ type Notification struct {
2121
}
2222

2323
func (f *FakeNotificationsEnqueuer) Enqueue(ctx context.Context, userID, templateID uuid.UUID, labels map[string]string, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
24-
return f.EnqueueData(ctx, userID, templateID, labels, nil, createdBy, targets...)
24+
return f.EnqueueWithData(ctx, userID, templateID, labels, nil, createdBy, targets...)
2525
}
2626

27-
func (f *FakeNotificationsEnqueuer) EnqueueData(_ context.Context, userID, templateID uuid.UUID, labels map[string]string, data map[string]any, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
27+
func (f *FakeNotificationsEnqueuer) EnqueueWithData(_ context.Context, userID, templateID uuid.UUID, labels map[string]string, data map[string]any, createdBy string, targets ...uuid.UUID) (*uuid.UUID, error) {
2828
f.mu.Lock()
2929
defer f.mu.Unlock()
3030

0 commit comments

Comments
 (0)