Skip to content

balyakin/sqliteq

Repository files navigation

sqliteq

Zero-polling job queues inside SQLite. No Redis, no daemon, no polling.

sqliteq adds durable background jobs to a SQLite app with one table, one crate, and no busy loop. Workers sleep on OS-native file watcher events and claim jobs with an atomic SQLite UPDATE ... RETURNING statement. WAL mode is used by default so enqueue can compose with normal SQLite writes.

sqliteq worker waking on enqueue

Quickstart

cargo add sqliteq
use serde_json::json;
use sqliteq::Sqliteq;

let sq = Sqliteq::open("app.db").await?;
let emails = sq.queue("emails");

emails.enqueue(json!({"to": "alice@example.com"})).await?;
let job = emails.claim("worker-1").await?;
job.ack().await?;

Run local benchmarks before publishing numbers:

cargo run -p sqliteq-cli -- bench --db bench.db --markdown

CLI

cargo run -p sqliteq-cli -- --db app.db init
cargo run -p sqliteq-cli -- --db app.db enqueue --queue emails '{"to":"alice@example.com"}'
cargo run -p sqliteq-cli -- --db app.db stats

Start a shell worker:

cargo run -p sqliteq-cli -- --db app.db worker --queue emails -- ./examples/worker.sh

How It Works

sqliteq watches the SQLite database, the parent directory, and WAL/SHM sidecar files through notify. When another process writes to the database, waiting workers wake up and run a targeted atomic claim query. If a filesystem watcher misses an event, a low-frequency fallback wake checks for work without becoming the primary mechanism.

Shipped In v0.1

  • SQLite-backed durable queue table
  • Atomic concurrent claim with UPDATE ... RETURNING
  • Priority, delayed jobs, retries, visibility timeout, and dead-letter jobs
  • Transactional enqueue through a caller-owned SQLite transaction
  • CLI commands: enqueue, worker, stats, purge, bench, init, version
  • Integration tests for core queue behavior, watcher wake, and concurrent workers

Roadmap

  • Durable pub/sub channels
  • Cron scheduler
  • Python bindings after Rust API and wheel packaging are stable
  • Dashboard and extra language bindings after repeated user demand

Limitations

sqliteq is a single-file, single-machine queue. It is not a distributed queue and does not replace Postgres-backed or broker-backed systems when multiple machines must coordinate claims. See docs/limitations.md for filesystem watcher, WAL, and concurrency details.

License

MIT

About

Zero-polling job queues, pub/sub and cron inside your SQLite file. Uses OS-native file watchers instead of busy loops. Drop-in, no daemon, no Redis.

Topics

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages