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 (single-process, no
distributed leases).
§Example — multiple worker processes
Run one Boson instance per process against shared persistence. 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_mem::MemQueueBackend;
use boson_core::JsonExecutionContextFactory;
use boson_runtime::Boson;
let _boson = Boson::builder()
.queue_backend(Arc::new(MemQueueBackend::new()))
.execution_context_factory(JsonExecutionContextFactory)
.worker_id("worker-a")
.lease_ttl_secs(30)
.auto_registry()
.build()?; // background loop claims and runs jobs for this worker idFields§
§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 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>,
) -> Self
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>, ) -> Self
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 more