Skip to content

Commit 9f1d6b3

Browse files
committed
Revert hack, no output param needed
Signed-off-by: Danny Kopping <danny@coder.com>
1 parent 91e2a23 commit 9f1d6b3

File tree

10 files changed

+27
-44
lines changed

10 files changed

+27
-44
lines changed

coderd/database/dbauthz/dbauthz.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,9 +1143,9 @@ func (q *querier) DeleteWorkspaceAgentPortSharesByTemplate(ctx context.Context,
11431143
return q.db.DeleteWorkspaceAgentPortSharesByTemplate(ctx, templateID)
11441144
}
11451145

1146-
func (q *querier) EnqueueNotificationMessage(ctx context.Context, arg database.EnqueueNotificationMessageParams) (uuid.UUID, error) {
1146+
func (q *querier) EnqueueNotificationMessage(ctx context.Context, arg database.EnqueueNotificationMessageParams) error {
11471147
if err := q.authorizeContext(ctx, policy.ActionCreate, rbac.ResourceSystem); err != nil {
1148-
return uuid.UUID{}, err
1148+
return err
11491149
}
11501150
return q.db.EnqueueNotificationMessage(ctx, arg)
11511151
}

coderd/database/dbmem/dbmem.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,10 +1817,10 @@ func (q *FakeQuerier) DeleteWorkspaceAgentPortSharesByTemplate(_ context.Context
18171817
return nil
18181818
}
18191819

1820-
func (q *FakeQuerier) EnqueueNotificationMessage(_ context.Context, arg database.EnqueueNotificationMessageParams) (uuid.UUID, error) {
1820+
func (q *FakeQuerier) EnqueueNotificationMessage(_ context.Context, arg database.EnqueueNotificationMessageParams) error {
18211821
err := validateDatabaseType(arg)
18221822
if err != nil {
1823-
return uuid.UUID{}, err
1823+
return err
18241824
}
18251825

18261826
q.mutex.Lock()
@@ -1829,7 +1829,7 @@ func (q *FakeQuerier) EnqueueNotificationMessage(_ context.Context, arg database
18291829
var payload types.MessagePayload
18301830
err = json.Unmarshal(arg.Payload, &payload)
18311831
if err != nil {
1832-
return uuid.UUID{}, err
1832+
return err
18331833
}
18341834

18351835
nm := database.NotificationMessage{
@@ -1847,7 +1847,7 @@ func (q *FakeQuerier) EnqueueNotificationMessage(_ context.Context, arg database
18471847

18481848
q.notificationMessages = append(q.notificationMessages, nm)
18491849

1850-
return nm.ID, err
1850+
return err
18511851
}
18521852

18531853
func (q *FakeQuerier) FavoriteWorkspace(_ context.Context, arg uuid.UUID) error {

coderd/database/dbmetrics/dbmetrics.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/querier.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries.sql.go

Lines changed: 4 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/notifications.sql

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,15 @@ FROM notification_templates nt,
1010
WHERE nt.id = @notification_template_id
1111
AND u.id = @user_id;
1212

13-
-- name: EnqueueNotificationMessage :one
13+
-- name: EnqueueNotificationMessage :exec
1414
INSERT INTO notification_messages (id, notification_template_id, user_id, method, payload, targets, created_by)
1515
VALUES (@id,
1616
@notification_template_id,
1717
@user_id,
1818
@method::notification_method,
1919
@payload::jsonb,
2020
@targets,
21-
@created_by)
22-
RETURNING id;
21+
@created_by);
2322

2423
-- Acquires the lease for a given count of notification messages, to enable concurrent dequeuing and subsequent sending.
2524
-- Only rows that aren't already leased (or ones which are leased but have exceeded their lease period) are returned.

coderd/notifications/enqueuer.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (s *StoreEnqueuer) Enqueue(ctx context.Context, userID, templateID uuid.UUI
5959
}
6060

6161
id := uuid.New()
62-
msg, err := s.store.EnqueueNotificationMessage(ctx, database.EnqueueNotificationMessageParams{
62+
err = s.store.EnqueueNotificationMessage(ctx, database.EnqueueNotificationMessageParams{
6363
ID: id,
6464
UserID: userID,
6565
NotificationTemplateID: templateID,
@@ -73,7 +73,7 @@ func (s *StoreEnqueuer) Enqueue(ctx context.Context, userID, templateID uuid.UUI
7373
return nil, xerrors.Errorf("enqueue notification: %w", err)
7474
}
7575

76-
s.log.Debug(ctx, "enqueued notification", slog.F("msg_id", msg.ID))
76+
s.log.Debug(ctx, "enqueued notification", slog.F("msg_id", id))
7777
return &id, nil
7878
}
7979

coderd/notifications/manager_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,15 +219,15 @@ func newEnqueueInterceptor(db notifications.Store, metadataFn func() database.Fe
219219
return &enqueueInterceptor{Store: db, payload: make(chan types.MessagePayload, 1), metadataFn: metadataFn}
220220
}
221221

222-
func (e *enqueueInterceptor) EnqueueNotificationMessage(_ context.Context, arg database.EnqueueNotificationMessageParams) (uuid.UUID, error) {
222+
func (e *enqueueInterceptor) EnqueueNotificationMessage(_ context.Context, arg database.EnqueueNotificationMessageParams) error {
223223
var payload types.MessagePayload
224224
err := json.Unmarshal(arg.Payload, &payload)
225225
if err != nil {
226-
return uuid.UUID{}, err
226+
return err
227227
}
228228

229229
e.payload <- payload
230-
return uuid.UUID{}, err
230+
return err
231231
}
232232

233233
func (e *enqueueInterceptor) FetchNewMessageMetadata(_ context.Context, _ database.FetchNewMessageMetadataParams) (database.FetchNewMessageMetadataRow, error) {

coderd/notifications/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type Store interface {
1818
AcquireNotificationMessages(ctx context.Context, params database.AcquireNotificationMessagesParams) ([]database.AcquireNotificationMessagesRow, error)
1919
BulkMarkNotificationMessagesSent(ctx context.Context, arg database.BulkMarkNotificationMessagesSentParams) (int64, error)
2020
BulkMarkNotificationMessagesFailed(ctx context.Context, arg database.BulkMarkNotificationMessagesFailedParams) (int64, error)
21-
EnqueueNotificationMessage(ctx context.Context, arg database.EnqueueNotificationMessageParams) (uuid.UUID, error)
21+
EnqueueNotificationMessage(ctx context.Context, arg database.EnqueueNotificationMessageParams) error
2222
FetchNewMessageMetadata(ctx context.Context, arg database.FetchNewMessageMetadataParams) (database.FetchNewMessageMetadataRow, error)
2323
GetNotificationMessagesByStatus(ctx context.Context, arg database.GetNotificationMessagesByStatusParams) ([]database.NotificationMessage, error)
2424
}

scripts/dbgen/main.go

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,22 +342,11 @@ func orderAndStubDatabaseFunctions(filePath, receiver, structName string, stub f
342342
switch typ := r.Type.(type) {
343343
case *dst.StarExpr, *dst.ArrayType:
344344
returnStmt.Results = append(returnStmt.Results, dst.NewIdent("nil"))
345-
case *dst.Ident, *dst.SelectorExpr:
346-
var ident *dst.Ident
347-
348-
// SelectorExpr contains a *dst.Ident
349-
if sel, ok := typ.(*dst.SelectorExpr); ok {
350-
if ident, ok = sel.X.(*dst.Ident); !ok {
351-
panic(fmt.Sprintf("SelectorExpr does not contain expected type %T: got %T", ident, sel.X))
352-
}
353-
} else {
354-
ident = typ.(*dst.Ident)
355-
}
356-
357-
if ident.Path != "" {
358-
returnStmt.Results = append(returnStmt.Results, dst.NewIdent(fmt.Sprintf("%s.%s{}", path.Base(ident.Path), ident.Name)))
345+
case *dst.Ident:
346+
if typ.Path != "" {
347+
returnStmt.Results = append(returnStmt.Results, dst.NewIdent(fmt.Sprintf("%s.%s{}", path.Base(typ.Path), typ.Name)))
359348
} else {
360-
switch ident.Name {
349+
switch typ.Name {
361350
case "uint8", "uint16", "uint32", "uint64", "uint", "uintptr",
362351
"int8", "int16", "int32", "int64", "int",
363352
"byte", "rune",
@@ -370,10 +359,8 @@ func orderAndStubDatabaseFunctions(filePath, receiver, structName string, stub f
370359
returnStmt.Results = append(returnStmt.Results, dst.NewIdent("false"))
371360
case "error":
372361
returnStmt.Results = append(returnStmt.Results, dst.NewIdent("err"))
373-
case "uuid":
374-
returnStmt.Results = append(returnStmt.Results, dst.NewIdent("uuid"))
375362
default:
376-
panic(fmt.Sprintf("unknown ident (%q): %#v", ident.Name, r.Type))
363+
panic(fmt.Sprintf("unknown ident: %#v", r.Type))
377364
}
378365
}
379366
default:

0 commit comments

Comments
 (0)