You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a worker is a consumer for multiple queues its not possible with the existing types to make the message body type depend on the name of the queue.
Changing the queue name to be generic would allow creating a discriminated union type for different message batches
typeBatch=|MessageBatch<{foo: number},"queue-1">|MessageBatch<{bar: number},"queue-2">exportdefaultclassextendsWorkerEntrypoint{asyncqueue(_batch: Batch){switch(batch.queue){case"queue-1": {// message.body is typed as { foo: number } herebreak;}case"queue-2": {// message.body is typed as { bar: number } herebreak;}}}}
The text was updated successfully, but these errors were encountered:
When a worker is a consumer for multiple queues its not possible with the existing types to make the message body type depend on the name of the queue.
Changing the queue name to be generic would allow creating a discriminated union type for different message batches
Which then enables:
The text was updated successfully, but these errors were encountered: