towerops/vendor/oban_pro/usage-rules/queues.md
Graham McIntire 6c05d45dd6 deps: upgrade oban_pro to 1.7.0
Bumps vendored Oban Pro from 1.6.13 to 1.7.0, which transitively bumps
oban core to 2.22.1 (requires migrations v14) and db_connection to 2.10.0.

- mix.exs constraint: ~> 1.6 → ~> 1.7
- vendor/oban_pro/ replaced with v1.7.0 hex package
- migration 20260430142200: Oban core v12 → v14 (must run first)
- migration 20260430142241: Oban Pro 1.7.0 schema additions

Also corrects a pre-existing constraint name in AgentAssignment that was
left stale by the equipment→devices rename migration (20260117190134).
The unique index is named agent_assignments_device_id_index, but the
schema's unique_constraint/3 still pointed at the old equipment_id name,
causing the test suite to surface Ecto.ConstraintError instead of a
changeset error. Required to get the suite green for this upgrade.
2026-04-30 10:26:18 -05:00

54 lines
1.3 KiB
Markdown

# Queues
Consider a dedicated queue when you need global concurrency, rate limiting, isolation, or different SLAs.
## Global concurrency
Limit concurrent jobs across all nodes:
```elixir
# 10 jobs total across all nodes
my_queue: [global_limit: 10]
# 10 global, but max 3 per node
my_queue: [local_limit: 3, global_limit: 10]
# Exactly 1 job at a time cluster-wide
my_queue: [global_limit: 1]
```
## Rate limiting
Control throughput over time:
```elixir
# 60 jobs per minute
my_queue: [rate_limit: [allowed: 60, period: {1, :minute}]]
# 1000 jobs per hour
my_queue: [rate_limit: [allowed: 1000, period: {1, :hour}]]
# 10 jobs per 30 seconds
my_queue: [rate_limit: [allowed: 10, period: 30]]
```
Algorithms: `:sliding_window` (default, smooth), `:fixed_window` (simple resets), `:token_bucket` (allows bursts):
```elixir
my_queue: [rate_limit: [allowed: 100, period: {1, :minute}, algorithm: :token_bucket]]
```
## Partitioning
Apply limits per-partition instead of queue-wide (partition is nested inside the limit):
```elixir
# Global limit of 1 per worker
my_queue: [global_limit: [allowed: 1, partition: :worker]]
# Global limit of 1 per tenant_id from args
my_queue: [global_limit: [allowed: 1, partition: [args: :tenant_id]]]
# Rate limit per account_id
my_queue: [rate_limit: [allowed: 100, period: {1, :minute}, partition: [args: :account_id]]]
```