pub struct WorkerContext { /* private fields */ }Expand description
Context provided to worker handlers
Implementations§
Source§impl WorkerContext
impl WorkerContext
pub fn new( worker_name: String, run_id: String, config: Arc<AppConfig>, message_tx: Option<UnboundedSender<Value>>, ) -> Self
pub fn with_data(self, data: Value) -> Self
pub fn worker_name(&self) -> &str
pub fn run_id(&self) -> &str
pub fn config(&self) -> &Arc<AppConfig> ⓘ
pub fn payload(&self) -> Option<&Value>
pub async fn set_state( &self, key: impl Into<String>, value: Value, ) -> Result<()>
pub async fn get_state(&self, key: &str) -> Option<Value>
pub async fn clear_state(&self) -> Result<()>
pub fn is_development(&self) -> bool
pub fn is_production(&self) -> bool
pub fn log(&self, level: Level, message: &str)
pub fn info(&self, message: &str)
pub fn debug(&self, message: &str)
pub fn warn(&self, message: &str)
pub fn error(&self, message: &str)
pub async fn sleep(&self, duration: Duration)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for WorkerContext
impl !UnwindSafe for WorkerContext
impl Freeze for WorkerContext
impl Send for WorkerContext
impl Sync for WorkerContext
impl Unpin for WorkerContext
impl UnsafeUnpin 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
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