pub struct TaskExecutionContext { /* private fields */ }Expand description
Task execution context passed to product task implementations.
Implementations§
Source§impl TaskExecutionContext
impl TaskExecutionContext
Sourcepub fn new(
lease: TaskLease,
renewal_timeout: Duration,
shutdown_token: CancellationToken,
) -> Self
pub fn new( lease: TaskLease, renewal_timeout: Duration, shutdown_token: CancellationToken, ) -> Self
Creates a task execution context.
Sourcepub const fn lease_guard(&self) -> &TaskLeaseGuard
pub const fn lease_guard(&self) -> &TaskLeaseGuard
Returns the lease guard used by progress and heartbeat updates.
Sourcepub fn ensure_active(&self) -> Result<()>
pub fn ensure_active(&self) -> Result<()>
Returns success only while the worker should continue task execution.
§Errors
Returns TaskCoreError when the lease has been lost or shutdown was requested.
Sourcepub async fn sleep_or_shutdown(&self, duration: Duration) -> Result<()>
pub async fn sleep_or_shutdown(&self, duration: Duration) -> Result<()>
Sleeps until duration elapses or shutdown is requested.
§Errors
Returns TaskCoreError when shutdown wins before the requested sleep completes.
Sourcepub async fn shutdown_requested(&self) -> Result<()>
pub async fn shutdown_requested(&self) -> Result<()>
Waits for shutdown and then returns the shutdown-requested lease error.
§Errors
Returns TaskCoreError when shutdown or lease loss has been observed.
Trait Implementations§
Source§impl Clone for TaskExecutionContext
impl Clone for TaskExecutionContext
Source§fn clone(&self) -> TaskExecutionContext
fn clone(&self) -> TaskExecutionContext
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 TaskExecutionContext
impl RefUnwindSafe for TaskExecutionContext
impl Send for TaskExecutionContext
impl Sync for TaskExecutionContext
impl Unpin for TaskExecutionContext
impl UnwindSafe for TaskExecutionContext
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