Awa
Postgres-native background job queue for Rust and Python.
Awa (Māori: river) provides durable, transactional job enqueueing with typed handlers in both Rust and Python. The Rust runtime handles all queue machinery — polling, LISTEN/NOTIFY wakeups, heartbeating, crash recovery, dispatch — while Python workers run as callbacks via PyO3 on that same runtime, getting Rust-grade queue reliability with Python-native ergonomics.
Features
- Postgres-only — no Redis, no RabbitMQ. One dependency you already have.
- Transactional enqueue — insert jobs inside your business transaction. Commit = job exists. Rollback = it doesn't.
- Two first-class languages — Rust and Python workers on the same queues with identical semantics.
- SKIP LOCKED dispatch — efficient, contention-free job claiming.
- Heartbeat + deadline crash recovery — stale jobs rescued automatically.
- Priority aging — low-priority jobs won't starve.
- LISTEN/NOTIFY wakeup — sub-10ms pickup latency.
- OpenTelemetry metrics — built-in counters, histograms, and gauges.
Quick Start (Rust)
use ;
use ;
// Insert a job
insert.await?;
// Transactional insert — atomic with your business logic
let mut tx = pool.begin.await?;
create_order.await?;
insert.await?;
tx.commit.await?;
// Start workers
let client = builder
.queue
.register_worker
.build?;
client.start.await?;
Quick Start (Python)
:
:
=
# Insert
await
# Transactional insert — atomic with your business logic
await
await
# Commits on success, rolls back on exception
# Worker
await
= await
assert
await
await
Note:
async with await client.transaction()uses a double-await becausetransaction()is an async method that returns a context manager. This is inherent to the PyO3 async bridge pattern.
Setup
# Run migrations once (not on every app startup)
# Or from Python:
# await awa.migrate("postgres://...")
Installation
Rust
[]
= "0.1"
Python
CLI
Architecture
┌────────────────────┐ ┌────────────────────┐
│ Rust producers │ │ Python producers │
│ `awa-model` / `awa`│ │ `pip install awa-pg` │
└─────────┬──────────┘ └─────────┬──────────┘
│ │
└──────────────┬────────────┘
▼
┌──────────────────────┐
│ PostgreSQL `awa.jobs`│
└──────────┬───────────┘
│
┌────────────────┼────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────┐ ┌───────────────┐
│ Rust runtime │ │ Rust runtime │ │ Rust runtime │
│ + Rust worker │ │ + Python cb │ │ + Python cb │
│ `awa-worker` │ │ via PyO3 │ │ via PyO3 │
└───────────────┘ └───────────────┘ └───────────────┘
All coordination happens through Postgres, and the Rust runtime owns polling, heartbeats, shutdown, and crash recovery for both Rust and Python handlers. Mixed Rust and Python workers coexist on the same queues — jobs inserted from any language are workable by any language.
Workspace
| Crate | Purpose |
|---|---|
awa |
Facade — re-exports everything |
awa-model |
Types, queries, migrations, admin ops |
awa-macros |
#[derive(JobArgs)] proc macro |
awa-worker |
Runtime: dispatch, heartbeat, maintenance |
awa-python |
PyO3 extension module |
awa-testing |
Test helpers (TestClient) |
awa-cli |
CLI binary |
Documentation
- Architecture
- ADR-001: Postgres-only
- ADR-002: BLAKE3 uniqueness
- ADR-003: Heartbeat + deadline hybrid
- ADR-004: PyO3 async bridge
- ADR-005: Priority aging
- ADR-006: AwaTransaction as narrow SQL surface
- Validation test plan
License
MIT OR Apache-2.0