Partitioned Queues (#458)
This PR allows you to create "partitioned queues."
Partitioned queues let you distribute work across dynamically created
queue partitions. When you enqueue a workflow on a partitioned queue,
you must supply a "queue partition key." Partitioned queues dequeue
workflows and apply flow control limits for individual partitions, not
for the entire queue. Essentially, you can think of each partition as a
"virtual queue" you can create dynamically by just enqueueing a workflow
with a new partition key.
For example, let's say you want to run only once task at once per user.
You can do this with a partitioned queue where the partition key is the
user ID:
```python
queue = Queue("queue", partition_queue=True, concurrency=1)
@DBOS.workflow()
def process_task(task: Task):
...
def on_user_task_submission(user_id: str, task: Task):
with SetEnqueueOptions(queue_partition_key=user_id):
queue.enqueue(process_task, task)
``` P
Peter Kraft committed
cf48898fc5537aaabd89d2792426f3079c7bb987
Parent: 6b6cd27
Committed by GitHub <noreply@github.com>
on 10/9/2025, 11:12:24 PM