Expand description
Redis QueueBackend for fleet-scale deployments (Mode 2 remote / multi-host).
When to use: broker-backed fleets where many enqueue hosts and workers share Redis.
Not a boson facade feature — depend on this crate directly. Mode 2 workers need unique
worker_id and lease_ttl_secs > 0.
Getting started: Mode 2. Full Compose / env tables: crate README.
Fleet URL precedence: BOSON_REDIS_POOL_ROUTING over BOSON_REDIS_URLS
(see connect_fleet_from_env).
§Mode 2 — Enqueue binary
Shared Redis with the worker. No claim loop in this process:
ⓘ
use std::sync::Arc;
use boson_backend_redis::{RedisQueueBackend, RedisQueueConfig};
use boson_core::JsonExecutionContextFactory;
use boson_runtime::{configure, Boson};
let backend = RedisQueueBackend::connect(RedisQueueConfig {
url: std::env::var("BOSON_REDIS_URL")
.unwrap_or_else(|_| "redis://127.0.0.1:6379".into()),
key_prefix: "boson".into(),
}).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?;Fleet routers: connect_fleet_from_env (same without_worker + configure pattern).
§Mode 2 — Worker binary
Same Redis URL / fleet, unique worker_id, and lease_ttl_secs > 0:
ⓘ
use std::sync::Arc;
use boson_backend_redis::{RedisQueueBackend, RedisQueueConfig};
use boson_core::JsonExecutionContextFactory;
use boson_runtime::Boson;
let backend = RedisQueueBackend::connect(RedisQueueConfig {
url: std::env::var("BOSON_REDIS_URL")
.unwrap_or_else(|_| "redis://127.0.0.1:6379".into()),
key_prefix: "boson".into(),
}).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()?;Other Mode 2 backends:
SQLite,
Postgres,
NATS.
Custom adapters: How to implement on QueueBackend.
Modules§
- keys
- Redis key naming for the Boson queue adapter.
Structs§
- Redis
Queue Backend - Redis-backed queue (ZSET ready queue + JSON job bodies).
- Redis
Queue Config - Connection settings for
crate::RedisQueueBackend.
Functions§
- connect_
fleet_ from_ env - Connect one Redis backend per fleet URL.
- install_
default_ redis_ backend - Install default Redis backend on global router (tests).