HeadlinesBriefing favicon HeadlinesBriefing.com

River delivers fast Go background jobs on Postgres

Hacker News •
×

River is a high‑performance job processing system built for Go and Postgres. By enqueueing jobs inside the same database transaction that writes application data, it eliminates classic distributed‑system pitfalls. A job only becomes visible after its transaction commits, guaranteeing atomicity between business changes and background work. This design lets developers avoid separate message brokers and simplifies deployment.

Jobs are defined as a pair of structs: an Args type that serializes to JSON and a Worker that implements a Work method. Registration maps a stable “kind” string to its worker, preventing duplicate or missing handlers. A River client is created with a pgx pool, a Config that lists queues and max workers, then started with a context to process jobs.

Beyond basic enqueueing, River supports batch inserts via PostgreSQL COPY, cron‑style scheduling, job snoozing, and graceful shutdown with soft‑stop timeouts. A built‑in web UI surfaces queue statistics, and test helpers verify job insertion. The library also offers language bindings so Python or Ruby services can enqueue jobs that Go workers execute. River consolidates queue and application data into a single, type‑safe store.