Elixir
Install
Section titled “Install”def deps do [ {:honker, "~> 0.4"} ]endElixir uses exqlite and the compiled Honker extension.
{:ok, db} = Honker.open("app.db", extension_path: "./libhonker_ext.so", watcher_backend: "shm" ){:ok, _id} = Honker.Queue.enqueue(db, "emails", %{to: "alice@example.com"})
case Honker.Queue.claim_one(db, "emails", "worker-1") do {:ok, job} -> Honker.Job.ack(db, job) {:ok, nil} -> :okendPub/Sub
Section titled “Pub/Sub”{:ok, subscription} = Honker.listen(db, "orders")ref = subscription.ref
receive do {:honker_notification, ^ref, notification} -> IO.inspect(notification.payload)end
Honker.unlisten(subscription)Subscriptions are live-only and channel-filtered. They stop automatically
when the subscribing process exits, or explicitly through Honker.unlisten/1.
Transactional Outbox
Section titled “Transactional Outbox”outbox = Honker.outbox(db, "email", fn payload -> MyApp.Email.deliver(payload) end)
Honker.Transaction.transaction(db, fn tx -> Honker.Transaction.execute(tx, "INSERT INTO orders (id, total) VALUES (?, ?)", [42, 9900]) Honker.Outbox.enqueue_tx(outbox, tx, %{order_id: 42})end)
Honker.Outbox.run_once(outbox, "email-worker")ORM Section
Section titled “ORM Section”For Ecto, load the Honker extension through the SQLite adapter/exqlite
connection setup. Keep business writes in Ecto.Multi, then add a step that
executes honker_enqueue or notify on the same transaction.
See the full Elixir ORM recipe for Ecto.Multi examples.
Testing
Section titled “Testing”Use System.tmp_dir!() plus a real .db file and start worker processes with
the same extension path. Avoid in-memory SQLite for anything that needs worker
or watcher fidelity.