pub struct QueueConfig {
pub default_queue: String,
pub max_concurrent_jobs: usize,
pub sleep_duration: Duration,
pub visibility_timeout: Duration,
}Expand description
Queue system configuration.
Fields§
§default_queue: StringDefault queue name.
max_concurrent_jobs: usizeMaximum number of concurrent jobs per worker.
sleep_duration: DurationHow long to sleep between poll cycles when no jobs are available.
visibility_timeout: DurationHow long a claimed job stays invisible before being reclaimed by the reaper.
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” disables the DB worker loop (defaults to “sync”)QUEUE_DEFAULT: Default queue name (defaults to “default”)QUEUE_MAX_CONCURRENT: Max concurrent jobs per worker (defaults to 10)QUEUE_VISIBILITY_TIMEOUT_SECS: Seconds before claimed jobs are reclaimed (defaults to 300)
§Example
ⓘ
use ferro_queue::QueueConfig;
// In bootstrap.rs
let config = QueueConfig::from_env();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 in the
calling process instead of being written to the database.
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 max_concurrent_jobs(self, count: usize) -> Self
pub fn max_concurrent_jobs(self, count: usize) -> Self
Set max concurrent jobs.
Sourcepub fn with_sleep_duration(self, d: Duration) -> Self
pub fn with_sleep_duration(self, d: Duration) -> Self
Set the sleep duration between poll cycles.
Sourcepub fn with_visibility_timeout(self, d: Duration) -> Self
pub fn with_visibility_timeout(self, d: Duration) -> Self
Set the visibility timeout for claimed 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 (const: unstable) · 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 UnsafeUnpin 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