pub struct WorkerContext {
pub config: WorkerConfig,
pub started_at: DateTime<Utc>,
pub execution_metadata: HashMap<String, String>,
pub attempt: u32,
pub previous_exception: Option<String>,
}
Expand description
Context information provided to workers during job execution
Fields§
§config: WorkerConfig
Worker configuration
started_at: DateTime<Utc>
When the job execution started
execution_metadata: HashMap<String, String>
Metadata for the current execution
attempt: u32
Attempt number (for retries)
previous_exception: Option<String>
Previous exception if this is a retry
Implementations§
Source§impl WorkerContext
impl WorkerContext
Sourcepub fn new(config: WorkerConfig) -> Self
pub fn new(config: WorkerConfig) -> Self
Create a new worker context
Sourcepub fn retry_from(
config: WorkerConfig,
attempt: u32,
previous_exception: Option<String>,
) -> Self
pub fn retry_from( config: WorkerConfig, attempt: u32, previous_exception: Option<String>, ) -> Self
Create a retry context from a previous attempt
Sourcepub fn add_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
pub fn add_metadata(&mut self, key: impl Into<String>, value: impl Into<String>)
Add execution metadata
Sourcepub fn is_timed_out(&self) -> bool
pub fn is_timed_out(&self) -> bool
Check if the job has timed out
Trait Implementations§
Source§impl Clone for WorkerContext
impl Clone for WorkerContext
Source§fn clone(&self) -> WorkerContext
fn clone(&self) -> WorkerContext
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 moreAuto Trait Implementations§
impl Freeze for WorkerContext
impl RefUnwindSafe for WorkerContext
impl Send for WorkerContext
impl Sync for WorkerContext
impl Unpin for WorkerContext
impl UnwindSafe for WorkerContext
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