Skip to content

Ruby

Terminal window
gem install honker

Ruby uses the sqlite3 gem and a compiled libhonker_ext.{so,dylib}. The sqlite3 build must expose enable_load_extension.

require "honker"
db = Honker::Database.new(
"app.db",
extension_path: "./libhonker_ext.dylib",
watcher_backend: "shm",
)
q = db.queue("emails")
q.enqueue({ to: "alice@example.com" })
job = q.claim_one("worker-1")
if job
send_email(job.payload)
job.ack
end
outbox = db.outbox("email", ->(payload) { SendEmail.call(payload) })
db.transaction do |tx|
tx.execute("INSERT INTO orders (id, total) VALUES (?, ?)", [42, 9900])
outbox.enqueue({ order_id: 42 }, tx: tx)
end
outbox.run_worker("email-worker")

For Rails and ActiveRecord, load the Honker extension on the ActiveRecord SQLite connection, then call honker_enqueue or notify inside ActiveRecord::Base.transaction.

See the full Ruby ORM recipe for Rails initialization and a small wrapper module.

Run queue and outbox worker proofs in subprocesses. In CI, require a sqlite3 gem build with loadable-extension support so watcher e2e coverage cannot silently skip.