-
Notifications
You must be signed in to change notification settings - Fork 178
Hi! I need to deploy a breaking change to job arguments in production. We have 2 workers and may have jobs queued with the old structure. We would need to handle both old and new formats during deployment.
// current type SendEmailArgs struct { User types.User `json:"user"` } // new (breaking change) type SendEmailArgs struct { UserID uuid.UUID `json:"user_id"` }
Questions:
- What's the recommended approach for handling this transition?
- Should I use versioned arguments, or multiple queues/workers?
- Any River-specific gotchas when migrating job arguments?
Thanks for any advice! 🙏
All reactions
@almottier I would typically handle this by keeping both sets of args around for a transitional period, following this rough strategy:
- Add the
UserIDfield and start using it on the enqueueing side where you can. - Update the worker to prefer
UserIDbut fall back toUserif that's all there is (can be deployed together with the above). - Once all relevant jobs have been worked or cleared out of the queue, remove the old field so it's just
UserIDremaining.
You could definitely adopt a versioned strategy if you're trying to solve this with a general pattern beyond just this one simple case.
Not sure if this is enough to help you, let me know if I can elaborate on anything!
Replies: 1 comment 2 replies
@almottier I would typically handle this by keeping both sets of args around for a transitional period, following this rough strategy:
- Add the
UserIDfield and start using it on the enqueueing side where you can. - Update the worker to prefer
UserIDbut fall back toUserif that's all there is (can be deployed together with the above). - Once all relevant jobs have been worked or cleared out of the queue, remove the old field so it's just
UserIDremaining.
You could definitely adopt a versioned strategy if you're trying to solve this with a general pattern beyond just this one simple case.
Not sure if this is enough to help you, let me know if I can elaborate on anything!
All reactions
Thank you for your response, that's the solution I'm going to use.
All reactions
-
👍 1
Great!
Also, forgot to mention, but we ended up publishing a docs page on this too:
All reactions
-
👍 1