honker (Rust)
Ergonomic Rust binding for Honker. Durable queues, streams, pub/sub, and cron scheduler on SQLite. One file, zero servers.
Install
[]
= "0.1"
= "1"
No separate extension download. This crate statically links honker-core and registers every honker_* SQL function on the connection it opens.
Quick start
use ;
use json;
Atomic enqueue with business writes
The killer feature of a SQLite-native queue. Open a transaction, do your business INSERT, enqueue with enqueue_tx, commit. Rollback drops both.
let tx = db.transaction?;
tx.execute?;
q.enqueue_tx?;
tx.commit?;
WAL-waking workers
claim_waker blocks until the next job lands, driven by the WAL watcher. No polling.
let waker = q.claim_waker;
loop
Streams (durable pub/sub)
Persistent event log with per-consumer offsets. Consumers resume after restart.
let s = db.stream;
s.publish?;
for event in s.subscribe?
Ephemeral pub/sub
pg_notify-style. Fire-and-forget, sub-2ms cross-process wake.
db.notify?;
let mut sub = db.listen?;
while let Some = sub.recv
Scheduler
Cron-style periodic tasks with leader election. Multiple processes can call run(); only the lock holder fires.
use ScheduledTask;
use ;
let sched = db.scheduler;
sched.add?;
let stop = new;
sched.run?;
Advisory locks
RAII: the lock releases when Lock drops. Use heartbeat to extend the TTL for long-held locks.
if let Some = db.try_lock?
Rate limiting
Fixed-window rate limit, backed by the same file.
if db.try_rate_limit?
Job results
Persist a return value keyed by job id, retrievable by the caller.
db.save_result?;
// Later, possibly in another process:
if let Some = db.get_result?
Threading
Database is cheap to clone (internally Arc<Mutex<Connection>>). Clone it across threads; every operation serializes through the shared connection. Open a second Database if you need a parallel reader.
Transaction pins the connection mutex for its lifetime. Use *_tx methods (enqueue_tx, publish_tx, save_offset_tx, notify_tx) to run operations inside the transaction. Calling non-tx methods on the same thread while a transaction is open deadlocks.
Escape hatch
If you need to run custom SQL or join across _honker_live and your business tables:
db.with_conn;
Testing
Relationship to other crates
honker-coreis the low-level Rust crate every binding (this one, the Python PyO3 bridge, the Node napi-rs bridge, the SQLite loadable extension) shares. Import it directly only if you're writing another language binding.honkeris this crate: the idiomatic Rust surface for applications.honker-extensionis the loadable.dylib/.sofor mixing with thesqlite3CLI or other-language clients that already have their own SQLite connection.