oliver-kriska/claude-elixir-phoenix / plugins/elixir-phoenix/skills/oban
oban
VerifiedUse when writing, scheduling, testing or debugging Oban jobs, even for a how-to question: workers, cron, retries, unique jobs, queues, Pro Workflow/Batch. Load it before touching job code; it holds the job rules.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.1 KB |
| references/oban-pro-basics.md | markdown | 9.7 KB |
| references/queue-config.md | markdown | 3.1 KB |
| references/testing-patterns.md | markdown | 2.9 KB |
| references/worker-patterns.md | markdown | 3.0 KB |
references/queue-config.md
View on GitHub# Queue Configuration Reference
## Basic Configuration
```elixir
# config/config.exs
config :my_app, Oban,
repo: MyApp.Repo,
queues: [
critical: 20, # High priority, fast
mailers: 50, # I/O-bound
webhooks: 30, # External API calls
media_processing: 3, # CPU-intensive
external_api: [limit: 5, dispatch_cooldown: 100],
imports: 10 # Bulk processing
],
plugins: [
{Oban.Plugins.Pruner, max_age: 60 * 60 * 24 * 7}, # 7 days
{Oban.Plugins.Lifeline, rescue_after: :timer.minutes(30)}
]
```
## Queue Design Principles
- **I/O vs CPU bound** — Separate queues prevent CPU work from blocking I/O
- **External dependencies** — Different APIs get isolated queues
- **Priority separation** — Critical jobs in dedicated high-concurrency queue
- **Rate limiting** — Queue-level `dispatch_cooldown` for API respect
## Connection Pool Sizing
```elixir
# Rule: pool_size >= num_queues + sum(queue_limits) + buffer
config :my_app, MyApp.Repo, pool_size: 25
```
## Cron Scheduling
Oban 2.24+ configures cron as a top-level key (module `Oban.Cron`); timezone
can be set per entry:
```elixir
config :my_app, Oban,
repo: MyApp.Repo,
cron: [
crontab: [
{"* * * * *", MyApp.MinuteWorker},
{"0 * * * *", MyApp.HourlyWorker},
{"0 0 * * *", MyApp.DailyWorker},
{"0 12 * * MON", MyApp.MondayNoonWorker, timezone: "America/New_York"},
{"@daily", MyApp.MidnightWorker},
{"@reboot", MyApp.StartupWorker}
]
]
```
Before 2.24 the same crontab went under `plugins: [{Oban.Plugins.Cron,
crontab: [...]}]`; that name is deprecated but still delegates to `Oban.Cron`.
## Smart Engine (Oban Pro)
If using Oban Pro, switch to Smart Engine for multi-node features:
```elixir
config :my_app, Oban,
engine: Oban.Pro.Engines.Smart,
queues: [
default: [local_limit: 10, global_limit: 50],
api_calls: [
local_limit: 5,
rate_limit: [allowed: 100, period: 60]
],
media: [local_limit: 3, global_limit: 10]
]
```
- `local_limit` — per-node concurrency (replaces plain integer)
- `global_limit` — cluster-wide concurrency cap
- `rate_limit` — distributed rate limiting (check docs for algorithm/partition options)
### Pro Plugin Config
Pro plugins **enhance** OSS equivalents — swap the module name, don't run both:
```elixir
plugins: [
{Oban.Pro.Plugins.DynamicCron, crontab: [{"0 0 * * *", DailyWorker}]},
{Oban.Pro.Plugins.DynamicLifeline, rescue_interval: 60_000},
{Oban.Pro.Plugins.DynamicPruner, mode: {:max_age, {7, :days}}}
# Optional: DynamicQueues for runtime queue management
# Optional: DynamicPrioritizer for starvation prevention
]
```
## Production Checklist
- [ ] Connection pool sized: `>= num_queues + sum(limits) + buffer`
- [ ] Pruner configured with `max_age`
- [ ] Lifeline plugin enabled for stuck jobs
- [ ] Telemetry attached for error tracking
- [ ] Graceful shutdown period set
- [ ] Unique constraints on user-triggered jobs
- [ ] All workers handle return values explicitly
- [ ] Idempotency for critical operations (payments, emails)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |