Files
antigravity-skills-reference/skills/dbos-golang/references/queue-partitioning.md
Max dml 7e5abd504f feat: add DBOS skills for TypeScript, Python, and Go (#94)
Add three DBOS SDK skills with reference documentation for building
reliable, fault-tolerant applications with durable workflows.

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-17 23:26:51 +01:00

1.3 KiB

title, impact, impactDescription, tags
title impact impactDescription tags
Partition Queues for Per-Entity Limits HIGH Enables per-entity concurrency control queue, partition, per-user, dynamic

Partition Queues for Per-Entity Limits

Partitioned queues apply flow control limits per partition key instead of the entire queue. Each partition acts as a dynamic "subqueue".

Incorrect (global concurrency for per-user limits):

// Global concurrency=1 blocks ALL users, not per-user
queue := dbos.NewWorkflowQueue(ctx, "tasks",
	dbos.WithGlobalConcurrency(1),
)

Correct (partitioned queue):

queue := dbos.NewWorkflowQueue(ctx, "tasks",
	dbos.WithPartitionQueue(),
	dbos.WithGlobalConcurrency(1),
)

func onUserTask(ctx dbos.DBOSContext, userID, task string) error {
	// Each user gets their own partition - at most 1 task per user
	// but tasks from different users can run concurrently
	_, err := dbos.RunWorkflow(ctx, processTask, task,
		dbos.WithQueue(queue.Name),
		dbos.WithQueuePartitionKey(userID),
	)
	return err
}

When a queue has WithPartitionQueue() enabled, you must provide a WithQueuePartitionKey() when enqueuing. Partition keys and deduplication IDs cannot be used together.

Reference: Partitioning Queues