Expand description
SQLite QueueBackend for Boson.
When to use: durable single-host Mode 1, or Mode 2 on one machine when enqueue and worker
processes share the same database file (BOSON_SQLITE_PATH). Enable via the boson crate
sqlite feature.
Getting started: Mode 1 / Mode 2.
§Entry points
SqliteQueueBackend::new/SqliteQueueBackend::connect— open a databaseinstall_default_sqlite_backend— register on the globalQueueRouter
§Mode 2 — Enqueue binary
Shared file path with the worker. No claim loop in this process:
use std::sync::Arc;
use boson_backend_sqlite::SqliteQueueBackend;
use boson_core::JsonExecutionContextFactory;
use boson_runtime::{configure, Boson};
let path = std::env::var("BOSON_SQLITE_PATH").unwrap_or_else(|_| "/tmp/boson-remote.db".into());
let backend = SqliteQueueBackend::new(&path).await?;
let boson = Boson::builder()
.queue_backend(Arc::new(backend))
.execution_context_factory(JsonExecutionContextFactory)
.auto_registry()
.without_worker()
.build()?;
configure(boson);
// MyTask::send_with(...).await?;Runnable: cargo run -p uf-boson --example remote_enqueue --features sqlite
§Mode 2 — Worker binary
Same BOSON_SQLITE_PATH, unique worker_id, and lease_ttl_secs > 0:
use std::sync::Arc;
use boson_backend_sqlite::SqliteQueueBackend;
use boson_core::JsonExecutionContextFactory;
use boson_runtime::Boson;
let path = std::env::var("BOSON_SQLITE_PATH").unwrap_or_else(|_| "/tmp/boson-remote.db".into());
let backend = SqliteQueueBackend::new(&path).await?;
let _boson = Boson::builder()
.queue_backend(Arc::new(backend))
.execution_context_factory(JsonExecutionContextFactory)
.worker_id(std::env::var("BOSON_WORKER_ID").unwrap_or_else(|_| "worker-1".into()))
.lease_ttl_secs(30)
.auto_registry()
.build()?;Runnable: cargo run -p uf-boson --example remote_worker --features sqlite
Structs§
- Sqlite
Queue Backend SQLite-backed queue backend.
Functions§
- install_
default_ sqlite_ backend - Install a new
SqliteQueueBackendas the process-global default backend.