What is the relation between queue-name and task/job payload type? #53
Replies: 1 comment 4 replies
-
For tasks specifically (so setting aside the job abstraction for a moment) the input type is tied to the queue in a one-to-one manner, yes. In other words, the named queue should only handle input of that type. You can extend this somewhat to support multiple tasks through more complex input types (the multitask example demonstrates this). This is true of jobs as well but jobs work by wrapping a serde_json::Value (see the job input type construction). So each step has its own input type and it must be deserialized to whatever that input is. Internally this is stored as a Value. Even so, we get compile time input type safety thanks to the job builder. All that said, our type safety can only extend to the surface of the application: if something were to interfere with what's actually stored by Postgres or we change the application-level types, stored data can become corrupted. (Versioning tasks or jobs could help a bit here, but doesn't entirely address misuse.) |
Beta Was this translation helpful? Give feedback.
-
I might be overlooking something, but I am currious how those are related? is it 1 to 1? can
WelcomeEmail
appear in different job-queues? Is it needed for the steps?Beta Was this translation helpful? Give feedback.
All reactions