Skip to content

queue messages into a channel that workers drain#1

Merged
Gargron merged 1 commit intomastodon:masterfrom
xavdid:master
Nov 6, 2022
Merged

queue messages into a channel that workers drain#1
Gargron merged 1 commit intomastodon:masterfrom
xavdid:master

Conversation

@xavdid
Copy link

@xavdid xavdid commented Nov 5, 2022

Per discussion in discord, refactor the notification service to queue up messages and immediately respond to incoming requests. This closely follows the structure of the Android version.

Considerations

  • We'll now always send an HTTP 201 on notification, since we don't know yet if the push will succeed
  • I did not run/test this code since I don't have an active Apple developer account and can't generate a certificate (that section of my UI is blank). The changes are simple enough, but please verify it still works before deploying.
  • In the interest of simplicity, I didn't make the queue size and number of worker threads configurable. Happy to add flags for that (or change the defaults) if you anticipate wanting to tweak them.

@Gargron Gargron merged commit 38e3390 into mastodon:master Nov 6, 2022

if err != nil {
log.Println("Push error:", err)
return
Copy link
Member

Choose a reason for hiding this comment

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

I think this has to be a continue, otherwise you're exiting the worker?

Copy link
Author

@xavdid xavdid Nov 6, 2022

Choose a reason for hiding this comment

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

Ah, you're totally right. That's a holdover for when I had the whole push in a goroutine. I can update it in by fork and send a new PR if you'd like, or you can just swap it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants