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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: v2 - add worker mode #6739
Conversation
🦋 Changeset detectedLatest commit: 7819a5a The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
3 Ignored Deployments
|
/snapshot-this |
@carlos-r-l-rodrigues, @adrien2p - I will need some help with conditionally starting workflow-engine-redis workers too. |
/snapshot-this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally !! 🎉 we can start subscribers only 🔥
It can be an option of the module right? And you can access the options as the second argument of the constructor too |
It will free the node event loop a lot when handling subscribers separately from the api |
My thinking on this is that it makes more sense to define it at the MedusaApp-level and not the module-level. This gives a more standardized way for modules to do conditional stuff depending on the worker mode. That said we could have a priority stack for this:
-- Think it would be great if the mode always gets passed to the module as moduleDeclaration instead of an option. Again to standardize usage. We could potentially do it like this in medusa-config.js // An eventbus only worker
{
resolve: "@medusajs/event-bus-redis",
options: { redisUrl: REDIS_URL },
worker_mode: "worker"
},
{
resolve: "@medusajs/workflow-engine-redis",
options: { redis: { url: REDIS_URL } },
worker_mode: "server"
},
// A workflow engine only worker
{
resolve: "@medusajs/event-bus-redis",
options: { redisUrl: REDIS_URL },
worker_mode: "server"
},
{
resolve: "@medusajs/workflow-engine-redis",
options: { redis: { url: REDIS_URL } },
worker_mode: "worker"
}, |
Yes definitely, i like the priority order, but the modules does not have access to the config as it is not injected and they do not require it as a dependency. But it can be changed and when using medusa app it can be added to the dependencies and getting injected in the module, so we can apply the ordering as you suggested |
b4e84d1
to
771a516
Compare
@olivermrbl, @adrien2p - can we get this in as is for now and then come back to improvements later on? :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we can @srindom if you want you can create a linear ticket to come back to it later with non automatic closing :)
…o feat/add-worker-mode
What