projects / tinybus
tinybus
A durable job queue for Go, backed by Postgres. Single binary, no broker, crash-safe via SELECT … FOR UPDATE SKIP LOCKED. The sibling project to collab-board: where collab-board nails real-time concurrency, tinybus nails the SQL-design half of backend engineering: schema, partial indexes, transactional claim, lease-based crash recovery.
Overview
Highlights
- Single CTE+UPDATE+RETURNING claim query: one round-trip per job, no race window between SELECT and UPDATE
- Postgres row-level locks (FOR UPDATE SKIP LOCKED) as the broker. No Redis, no AMQP, no Kafka
- State stored implicitly in nullable timestamps; three partial indexes back the hot paths
- Lock-expiry sweeper reclaims locks from crashed workers (lease-based, not heartbeat; the same choice River and Oban make)
- Exponential backoff with equal jitter to prevent retry dogpiling after transient outages
- Embedded migrations via embed.FS; ledger-tracked up/down runner is ~150 lines
Stack
- Go
- Backend
- Postgres
- SQL
- Job Queue
- Distributed Systems
- Docker
- Railway