pub struct TerminationManager { /* private fields */ }Expand description
Manages graceful termination before Lambda timeout.
Created from a Lambda context, this struct calculates how much time remains before the Lambda deadline and provides an async signal that fires before the hard timeout, giving the runtime time to flush pending checkpoints.
Implementations§
Source§impl TerminationManager
impl TerminationManager
Sourcepub fn from_lambda_context(ctx: &Context) -> Self
pub fn from_lambda_context(ctx: &Context) -> Self
Creates a new manager from the Lambda context deadline.
Calculates remaining_time_ms from ctx.deadline() - now.
The safety margin defaults to 5000ms (5 seconds).
Sourcepub async fn wait_for_timeout(&self)
pub async fn wait_for_timeout(&self)
Returns a future that resolves when the timeout margin is reached.
If the remaining time is already less than the safety margin, this resolves immediately.
Sourcepub fn remaining_ms(&self) -> u64
pub fn remaining_ms(&self) -> u64
Returns the remaining time before the safety margin in milliseconds.
Returns 0 if the remaining time is already less than the safety margin.
Auto Trait Implementations§
impl Freeze for TerminationManager
impl RefUnwindSafe for TerminationManager
impl Send for TerminationManager
impl Sync for TerminationManager
impl Unpin for TerminationManager
impl UnsafeUnpin for TerminationManager
impl UnwindSafe for TerminationManager
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> 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 moreCreates a shared type from an unshared type.