pub struct QueueConfig {
pub redis_url: String,
pub default_queue: String,
pub prefix: String,
pub block_timeout: Duration,
pub max_concurrent_jobs: usize,
pub delayed_job_poll_interval: Duration,
}Expand description
Queue system configuration.
Fields§
§redis_url: StringRedis connection URL.
default_queue: StringDefault queue name.
prefix: StringPrefix for queue keys in Redis.
block_timeout: DurationHow long to block waiting for jobs (in seconds).
max_concurrent_jobs: usizeMaximum number of concurrent jobs per worker.
delayed_job_poll_interval: DurationHow often to check for delayed jobs.
Implementations§
Source§impl QueueConfig
impl QueueConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Create configuration from environment variables.
Reads the following environment variables:
QUEUE_CONNECTION: “sync” or “redis” (defaults to “sync”)QUEUE_DEFAULT: Default queue name (defaults to “default”)QUEUE_PREFIX: Key prefix in Redis (defaults to “ferro_queue”)QUEUE_BLOCK_TIMEOUT: Seconds to block waiting for jobs (defaults to 5)QUEUE_MAX_CONCURRENT: Max concurrent jobs per worker (defaults to 10)REDIS_URL: Full Redis URL (takes precedence if set)REDIS_HOST: Redis host (defaults to “127.0.0.1”)REDIS_PORT: Redis port (defaults to 6379)REDIS_PASSWORD: Redis password (optional)REDIS_DATABASE: Redis database number (defaults to 0)
§Example
ⓘ
use ferro_queue::QueueConfig;
// In bootstrap.rs
let config = QueueConfig::from_env();
Queue::init(config).await?;Sourcepub fn is_sync_mode() -> bool
pub fn is_sync_mode() -> bool
Check if sync queue mode is configured.
When QUEUE_CONNECTION=sync, jobs are processed immediately instead of being pushed to Redis.
Sourcepub fn default_queue(self, queue: impl Into<String>) -> Self
pub fn default_queue(self, queue: impl Into<String>) -> Self
Set the default queue name.
Sourcepub fn block_timeout(self, timeout: Duration) -> Self
pub fn block_timeout(self, timeout: Duration) -> Self
Set the block timeout.
Sourcepub fn max_concurrent_jobs(self, count: usize) -> Self
pub fn max_concurrent_jobs(self, count: usize) -> Self
Set max concurrent jobs.
Sourcepub fn delayed_key(&self, queue: &str) -> String
pub fn delayed_key(&self, queue: &str) -> String
Get the Redis key for delayed jobs.
Sourcepub fn reserved_key(&self, queue: &str) -> String
pub fn reserved_key(&self, queue: &str) -> String
Get the Redis key for reserved jobs.
Sourcepub fn failed_key(&self) -> String
pub fn failed_key(&self) -> String
Get the Redis key for failed jobs.
Trait Implementations§
Source§impl Clone for QueueConfig
impl Clone for QueueConfig
Source§fn clone(&self) -> QueueConfig
fn clone(&self) -> QueueConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QueueConfig
impl Debug for QueueConfig
Auto Trait Implementations§
impl Freeze for QueueConfig
impl RefUnwindSafe for QueueConfig
impl Send for QueueConfig
impl Sync for QueueConfig
impl Unpin for QueueConfig
impl UnwindSafe for QueueConfig
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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