honker:为 SQLite 添加 Postgres 风格的 NOTIFY/LISTEN 通知机制russellromney/honker
Russell Romney 开发的 honker 是一个用 Rust 编写的 SQLite 扩展,实现了类似 PostgreSQL 的 NOTIFY/LISTEN 异步消息通知语义。通过 Python 绑定,开发者可以轻松地在 SQLite 数据库变更时触发事件通知,适用于轻量级队列系统或实时同步场景。该项目展示了跨数据库抽象通信层的设计潜力。
Simon Willison
24th April 2026 - Link Blog
russellromney/honker (via) "Postgres NOTIFY/LISTEN semantics" for SQLite, implemented as a Rust SQLite extension and various language bindings to help make use of it.
The design of this looks very solid. It lets you write Python code for queues that looks like this:
import honker
db = honker.open("app.db")
emails = db.queue("emails")
emails.enqueue({"to": "alice@example.com"})
# Consume (in a worker process)
async for job in emails.claim("worker-1"):
send(job.payload)
job.ack()And Kafka-style durable streams like this:
stream = db.stream("user-events")
with db.transaction() as tx:
tx.execute("UPDATE users SET name=? WHERE id=?", [name, uid])
stream.publish({"user_id": uid, "change": "name"}, tx=tx)
async for event in stream.subscribe(consumer="dashboard"):
await push_to_browser(event)It also adds 20+ custom SQL functions including these two:
SELECT notify('orders', '{"id":42}');
SELECT honker_stream_read_since('orders', 0, 1000);The extension requires WAL mode, and workers can poll the .db-wal file with a stat call every 1ms to get as close to real-time as possible without the expense of running a full SQL query.
honker implements the transactional outbox pattern, which ensures items are only queued if a transaction successfully commits. My favorite explanation of that pattern remains Transactionally Staged Job Drains in Postgres by Brandur Leach. It's great to see a new implementation of that pattern for SQLite.
需要完整排版与评论请前往来源站点阅读。