Skip to content

Elixir

def deps do
[
{:honker, "~> 0.1"}
]
end

Elixir 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} -> :ok
end
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")

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.

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.