Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
defelmnq merged 22 commits intomainfromnotif-inbox/inte-403
Mar 5, 2025

Conversation

defelmnq
Copy link
Contributor

@defelmnqdefelmnq commentedMar 3, 2025
edited
Loading

This PR isresolving the dispatch part of Coder Inbocx.

Since the DB layer has been merged - we now want to insert notifications into Coder Inbox in parallel of the other delivery target.

To do so, we push two messages instead of one using theEnqueue method.

@defelmnqdefelmnq changed the titleadd new notification methodfeat(coderd): add new dispatch logic for coder inboxMar 3, 2025
@defelmnqdefelmnq marked this pull request as ready for reviewMarch 4, 2025 11:14
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good start, a few things we need to address but none of them huge.

@@ -79,7 +81,7 @@ func TestBufferedUpdates(t *testing.T) {
// Wait for the expected number of buffered updates to be accumulated.
require.Eventually(t, func() bool {
success, failure := mgr.BufferedUpdatesCount()
return success == expectedSuccess && failure == expectedFailure
return success == expectedSuccess*2 && failure == expectedFailure*2 // Each message is enqueued twice.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Your tests are going to become complicated once inbox can be disabled (by feature flag or otherwise).
I'd suggest creating a func which returns the configured targets and then you canlen them instead of hardcoding magic numbers like this.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I tried to clean it up a bit - still not perfect but as we do not have FF or experiment logic, please tell me if that's good enough.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No I think we need to take this further; there are several other places relying on this magic number.

@@ -77,7 +78,10 @@ func TestMetrics(t *testing.T) {

// Build fingerprints for the two different series we expect.
methodTemplateFP := fingerprintLabels(notifications.LabelMethod, string(method), notifications.LabelTemplateID, tmpl.String())
methodTemplateFPWithInbox := fingerprintLabels(notifications.LabelMethod, string(database.NotificationMethodInbox), notifications.LabelTemplateID, tmpl.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Do we need metrics for inbox?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I kept it to avoid any specific logic and as I felt like it could be interesting to have - no real other reason tbh.

@@ -19,7 +19,8 @@
"name": "bobby-workspace",
"reason": "autostart"
},
"data": null
"data": null,
"targets": null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I guess we're never testing with targets?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

def not as much as we could - I added one on the logic but we can improve the golden files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Which golden file did that update? I don't see it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok I took a bit longer than expected , but this targets never changes - it is part ofthe buildPayload which takes directly data fetched from db that does not contain the targets.

I'd like to clean it up as a follow-up PR, seems like there's some mixed fields with targets - one within thepayload and another one outside of it.

dannykopping reacted with thumbs up emoji
Copy link
ContributorAuthor

@defelmnqdefelmnq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks@dannykopping for the first review - I tried to fix all your comments. 🙏

Just still have an open comment on the FF for inbox.

@@ -77,7 +78,10 @@ func TestMetrics(t *testing.T) {

// Build fingerprints for the two different series we expect.
methodTemplateFP := fingerprintLabels(notifications.LabelMethod, string(method), notifications.LabelTemplateID, tmpl.String())
methodTemplateFPWithInbox := fingerprintLabels(notifications.LabelMethod, string(database.NotificationMethodInbox), notifications.LabelTemplateID, tmpl.String())
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I kept it to avoid any specific logic and as I felt like it could be interesting to have - no real other reason tbh.

@@ -79,7 +81,7 @@ func TestBufferedUpdates(t *testing.T) {
// Wait for the expected number of buffered updates to be accumulated.
require.Eventually(t, func() bool {
success, failure := mgr.BufferedUpdatesCount()
return success == expectedSuccess && failure == expectedFailure
return success == expectedSuccess*2 && failure == expectedFailure*2 // Each message is enqueued twice.
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I tried to clean it up a bit - still not perfect but as we do not have FF or experiment logic, please tell me if that's good enough.

// THEN: we expect to see all but the final attempts failing
// the number of tries is equal to the number of messages times the number of attempts
// times 2 as the Enqueue method pushes into both the defined dispatch method and inbox
nbTries := msgCount * maxAttempts * 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If we conditionalize when inbox is used in the future, this will become brittle and it won't be easily understood why; this is why magic numbers are to be avoided atall reasonable costs.

@@ -79,7 +81,7 @@ func TestBufferedUpdates(t *testing.T) {
// Wait for the expected number of buffered updates to be accumulated.
require.Eventually(t, func() bool {
success, failure := mgr.BufferedUpdatesCount()
return success == expectedSuccess && failure == expectedFailure
return success == expectedSuccess*2 && failure == expectedFailure*2 // Each message is enqueued twice.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

No I think we need to take this further; there are several other places relying on this magic number.

@@ -19,7 +19,8 @@
"name": "bobby-workspace",
"reason": "autostart"
},
"data": null
"data": null,
"targets": null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Which golden file did that update? I don't see it.

@defelmnq
Copy link
ContributorAuthor

I fixed most of the comments, but would like to create two follow-up PR :

  • One prio to implement a FF to enable / disable inbox. This one would need to be implemented just after the endpoints, and will also change the tests and way we compute number of messages sent etc..
  • One less prio that will define if we want to remove or nottargets from payload as this value is set in two places, including one which is always null.
dannykopping reacted with thumbs up emoji

@@ -34,7 +35,7 @@ func TestInbox(t *testing.T) {
payload: types.MessagePayload{
NotificationName: "test",
NotificationTemplateID: notifications.TemplateWorkspaceDeleted.String(),
UserID: "1e965b51-9465-43d8-ac20-c5f689f9c788",
UserID: "valid",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

How isvalid a validUserID?

Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Approving to unblock, and for the outstanding comments to be addressed in a follow-up.

I would like to see the magic numbers replaced with a functional call to express which delivery targets are active (this will help when we allow multiple targetsplus inbox, later). Having the feature flag (default on, possible opt-out) will naturally expose the need for this.

We just need to ensure this PR does not get cherry-picked into a release, otherwise customers will have no way to turn it off.

@defelmnqdefelmnq merged commit522181f intomainMar 5, 2025
30 checks passed
@defelmnqdefelmnq deleted the notif-inbox/inte-403 branchMarch 5, 2025 21:43
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 5, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@johnstcnjohnstcnAwaiting requested review from johnstcn

@DanielleMaywoodDanielleMaywoodAwaiting requested review from DanielleMaywood

Assignees

@defelmnqdefelmnq

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@defelmnq@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp