pub struct WorkerSettings {
pub worker_id: String,
pub lease_ttl_secs: i64,
pub runtime_label: String,
pub worker_pools: Option<Vec<String>>,
pub worker_poll_interval_ms: u64,
pub skip_run_persistence: bool,
}Expand description
Resolved worker settings for claim, lease, and telemetry labels.
Usually constructed by BosonBuilder via worker_id
and lease_ttl_secs. Defaults: worker id from
INSTANCE_ID / BOSON_WORKER_ID / boson-worker-1, lease TTL 0 (Mode 1 embedded, no
distributed leases).
Getting started: Mode 2 — Remote worker.
§Example — multiple worker processes (Mode 2)
Run one Boson instance per process against shared persistence (Postgres, SQLite path,
Redis, or NATS — not MemQueueBackend, which is
in-process only). Each process needs a unique worker_id and a positive
lease_ttl_secs so
QueueBackend::try_claim_run_lease prevents
double execution:
use std::sync::Arc;
use boson_backend_postgres::PostgresQueueBackend;
use boson_core::JsonExecutionContextFactory;
use boson_runtime::Boson;
let url = std::env::var("DATABASE_URL")?;
let backend = PostgresQueueBackend::connect(&url).await?;
let _boson = Boson::builder()
.queue_backend(Arc::new(backend))
.execution_context_factory(JsonExecutionContextFactory)
.worker_id("worker-a")
.lease_ttl_secs(30)
.auto_registry()
.build()?;Fields§
§worker_id: StringWorker identity for distributed lease claims.
lease_ttl_secs: i64Run lease TTL in seconds; 0 disables lease coordination.
runtime_label: StringTelemetry/runtime label (topology slug or host-provided).
worker_pools: Option<Vec<String>>When set, poll only these pools (shared-nothing fleet pinning).
worker_poll_interval_ms: u64Delay between worker poll ticks in milliseconds (default 50).
skip_run_persistence: boolSkip persisting run rows on the hot path (bench / throughput mode).
Implementations§
Source§impl WorkerSettings
impl WorkerSettings
Sourcepub fn embedded() -> WorkerSettings
pub fn embedded() -> WorkerSettings
Default embedded monolith: no leases, label embedded.
Sourcepub fn resolve(
worker_id: Option<String>,
lease_ttl_secs: Option<i64>,
runtime_label: Option<String>,
worker_pools: Option<Vec<String>>,
worker_poll_interval_ms: Option<u64>,
) -> WorkerSettings
pub fn resolve( worker_id: Option<String>, lease_ttl_secs: Option<i64>, runtime_label: Option<String>, worker_pools: Option<Vec<String>>, worker_poll_interval_ms: Option<u64>, ) -> WorkerSettings
Build settings from optional builder overrides.
Sourcepub fn pools_to_poll(&self, discovered: Vec<String>) -> Vec<String>
pub fn pools_to_poll(&self, discovered: Vec<String>) -> Vec<String>
Pools this worker should poll. When pinned, uses Self::worker_pools; otherwise backend discovery.
Trait Implementations§
Source§impl Clone for WorkerSettings
impl Clone for WorkerSettings
Source§fn clone(&self) -> WorkerSettings
fn clone(&self) -> WorkerSettings
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for WorkerSettings
impl RefUnwindSafe for WorkerSettings
impl Send for WorkerSettings
impl Sync for WorkerSettings
impl Unpin for WorkerSettings
impl UnsafeUnpin for WorkerSettings
impl UnwindSafe for WorkerSettings
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more