-
Docs say:
..but I'm curious if they can purposefully be the same. This would open the door to notifying multiple workflow instances at once that they should resume. I'm specifically looking into building some sort of real-time/live query infra on top of workflows, and the ability to invalidate queries through hooks causing the query to rerun and stream the next value would be 🔥. Alternative, would seem to be to store instances (and their respective tokens) in some sort of KV, and loop through them to resume. Doesn't scale well, so curious what you guys think. PS: As a product guy, I'm super excited about using workflows as a new primitive for building cool software, amazing tool. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Yeah we made an intentional choice to have a 1:1 mapping between a token and a workflow run. It enables things like If you try to register the same token twice, it should throw a conflict error in your workflow (if it's not failing, that's a bug 😬) To resume multiple runs from one event, we kinda leave it upto you rn to either store or calculate all the possible tokens you want to resume and then resume them all at once using The Tags RFC #132 would be a way where you can set a "tag" when creating the hook so that it's easier to just query all the hooks that have the same tags, and resume them all more easily |
Beta Was this translation helpful? Give feedback.
Yeah we made an intentional choice to have a 1:1 mapping between a token and a workflow run. It enables things like
respondWithin the webhook abstraction. We went through multiple iterations on the design before arriving at this constraint.If you try to register the same token twice, it should throw a conflict error in your workflow (if it's not failing, that's a bug 😬)
To resume multiple runs from one event, we kinda leave it upto you rn to either store or calculate all the possible tokens you want to resume and then resume them all at once using
Promise.all(btw you can also just attempt toresumeHookfor tokens that don't exist, and then eat up and silently ignore the error. So if th…