estack-oban
Oban patterns
Inspect the locked Oban version, engine, Repo, plugins, and deployment topology. Use supported options and preserve the project's conventions.
Worker contracts
Declare an intentional queue and retry budget. Oban already has a bounded default attempt count; tune attempts and backoff to the failure mode. Configure a timeout where unbounded execution is inappropriate.
Return :ok or {:ok, value} only on success. Return {:error, reason} for retryable failures. Use the installed version's terminal cancellation result for permanent failures (modern Oban uses {:cancel, reason}; {:discard, reason} is deprecated). Never mark a failed operation successful merely to stop retries.
Job args are serialized data, generally string-keyed when delivered to perform. Pass stable IDs and fetch current data with appropriate scoping. Avoid putting secrets or unnecessary PII in persisted args.
Idempotency before uniqueness
Assume a job may run more than once. Separate three concerns:
- Insertion deduplication:
uniquecan suppress matching enqueues within a configured window. - Concurrency control: queue/engine limits or explicit locks control simultaneous execution.
- Business idempotency: a repeated execution must not repeat an irreversible effect.