Add BullMQ + Redis and prototype notifications queue #161
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an initial attempt to add BullMQ and Redis (i.e., ioredis) to our code.
I've done the most basic thing possible vs. making this so it will scale. At the moment we have:
app/queues/*
which holds all of our queues.app/queues/notifications.server.ts
which is our first queue, dealing with sending user notifications asynchronously. We'll add more as we go, but this can provide a template.Queue
andWorker
are both co-located in the same file, and in the same process. Down the road, we can break the worker into its own process or container(s). But I didn't want to do this at first, since it will complicate things significantly.The way this queue would be used is like this. Imagine we want to send a message to a user. The code would be:
The job can now be handled by the
Worker
, which will attempt to send it at some point in the near future. If it fails, it will retry the job 3 more times, waiting progressively longer each time. We can configure all of this.I don't have anywhere in the code to hook into this yet, so it's not easy to test.