pub struct ShutdownTracker { /* private fields */ }Expand description
Extracted TaskTracker and ShutdownToken to more easily allow tracking nested tasks without having to pass whole ShutdownManager around.
Implementations§
Source§impl ShutdownTracker
impl ShutdownTracker
Sourcepub fn spawn<F>(&self, task: F) -> JoinHandle<<F as Future>::Output>
pub fn spawn<F>(&self, task: F) -> JoinHandle<<F as Future>::Output>
Spawn the provided future on the current Tokio runtime, and track it in the underlying TaskTracker.
Sourcepub fn try_spawn_named<F>(
&self,
task: F,
name: &str,
) -> JoinHandle<<F as Future>::Output>
pub fn try_spawn_named<F>( &self, task: F, name: &str, ) -> JoinHandle<<F as Future>::Output>
Spawn the provided future on the current Tokio runtime, and track it in the underlying TaskTracker. Furthermore, attach a name to the spawned task to more easily track it within a tokio console
Note that is no different from spawn if the underlying binary
has not been built with RUSTFLAGS="--cfg tokio_unstable" and --features="tokio-tracing"
Sourcepub fn spawn_on<F>(
&self,
task: F,
handle: &Handle,
) -> JoinHandle<<F as Future>::Output>
pub fn spawn_on<F>( &self, task: F, handle: &Handle, ) -> JoinHandle<<F as Future>::Output>
Spawn the provided future on the provided Tokio runtime, and track it in the underlying TaskTracker.
Sourcepub fn spawn_local<F>(&self, task: F) -> JoinHandle<<F as Future>::Output>
pub fn spawn_local<F>(&self, task: F) -> JoinHandle<<F as Future>::Output>
Spawn the provided future on the current LocalSet, and track it in the underlying TaskTracker.
Sourcepub fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T>
pub fn spawn_blocking<F, T>(&self, task: F) -> JoinHandle<T>
Spawn the provided blocking task on the current Tokio runtime, and track it in the underlying TaskTracker.
Sourcepub fn spawn_blocking_on<F, T>(&self, task: F, handle: &Handle) -> JoinHandle<T>
pub fn spawn_blocking_on<F, T>(&self, task: F, handle: &Handle) -> JoinHandle<T>
Spawn the provided blocking task on the provided Tokio runtime, and track it in the underlying TaskTracker.
Sourcepub fn try_spawn_named_with_shutdown<F>(
&self,
task: F,
name: &str,
) -> JoinHandle<Result<<F as Future>::Output, Cancelled>>
pub fn try_spawn_named_with_shutdown<F>( &self, task: F, name: &str, ) -> JoinHandle<Result<<F as Future>::Output, Cancelled>>
Spawn the provided future on the current Tokio runtime that will get cancelled once a global shutdown signal is detected, and track it in the underlying TaskTracker.
Note that to fully use the naming feature, such as tracking within a tokio console,
the underlying binary has to be built with RUSTFLAGS="--cfg tokio_unstable" and --features="tokio-tracing"
Sourcepub fn spawn_with_shutdown<F>(
&self,
task: F,
) -> JoinHandle<Result<<F as Future>::Output, Cancelled>>
pub fn spawn_with_shutdown<F>( &self, task: F, ) -> JoinHandle<Result<<F as Future>::Output, Cancelled>>
Spawn the provided future on the current Tokio runtime that will get cancelled once a global shutdown signal is detected, and track it in the underlying TaskTracker.
Source§impl ShutdownTracker
impl ShutdownTracker
Sourcepub fn new_from_external_shutdown_token(
shutdown_token: ShutdownToken,
) -> ShutdownTracker
pub fn new_from_external_shutdown_token( shutdown_token: ShutdownToken, ) -> ShutdownTracker
Create new instance of the ShutdownTracker using an external shutdown token. This could be useful in situations where shutdown is being managed by an external entity that is not ShutdownManager, but interface requires providing a ShutdownTracker, such as client-core tasks
Sourcepub async fn wait_for_tracker(&self)
pub async fn wait_for_tracker(&self)
Waits until the underlying TaskTracker is both closed and empty.
If the underlying TaskTracker is already closed and empty when this method is called, then it returns immediately.
Sourcepub fn close_tracker(&self) -> bool
pub fn close_tracker(&self) -> bool
Close the underlying TaskTracker.
This allows wait_for_tracker futures to complete. It does not prevent you from spawning new tasks.
Returns true if this closed the underlying TaskTracker, or false if it was already closed.
Sourcepub fn reopen_tracker(&self) -> bool
pub fn reopen_tracker(&self) -> bool
Reopen the underlying TaskTracker.
This prevents wait_for_tracker futures from completing even if the underlying TaskTracker is empty.
Returns true if this reopened the underlying TaskTracker, or false if it was already open.
Sourcepub fn is_tracker_closed(&self) -> bool
pub fn is_tracker_closed(&self) -> bool
Returns true if the underlying TaskTracker is closed.
Sourcepub fn tracked_tasks(&self) -> usize
pub fn tracked_tasks(&self) -> usize
Returns the number of tasks tracked by the underlying TaskTracker.
Sourcepub fn is_tracker_empty(&self) -> bool
pub fn is_tracker_empty(&self) -> bool
Returns true if there are no tasks in the underlying TaskTracker.
Sourcepub fn child_shutdown_token(&self) -> ShutdownToken
pub fn child_shutdown_token(&self) -> ShutdownToken
Obtain a ShutdownToken that is a child of the root token
Sourcepub fn clone_shutdown_token(&self) -> ShutdownToken
pub fn clone_shutdown_token(&self) -> ShutdownToken
Obtain a ShutdownToken on the same hierarchical structure as the root token
Sourcepub fn child_tracker(&self) -> ShutdownTracker
pub fn child_tracker(&self) -> ShutdownTracker
Create a child ShutdownTracker that inherits cancellation from this tracker but has its own TaskTracker for managing sub-tasks.
This enables hierarchical task management where:
- Parent cancellation flows to all children
- Each level tracks its own tasks independently
- Components can wait for their specific sub-tasks to complete
Trait Implementations§
Source§impl Clone for ShutdownTracker
impl Clone for ShutdownTracker
Source§fn clone(&self) -> ShutdownTracker
fn clone(&self) -> ShutdownTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShutdownTracker
impl Debug for ShutdownTracker
Source§impl Default for ShutdownTracker
impl Default for ShutdownTracker
Source§fn default() -> ShutdownTracker
fn default() -> ShutdownTracker
Auto Trait Implementations§
impl Freeze for ShutdownTracker
impl RefUnwindSafe for ShutdownTracker
impl Send for ShutdownTracker
impl Sync for ShutdownTracker
impl Unpin for ShutdownTracker
impl UnwindSafe for ShutdownTracker
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Deprecatable for T
impl<T> Deprecatable for T
fn deprecate(self) -> Deprecated<Self>where
Self: Sized,
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>
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>
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 moreSource§impl<T> OptionalSet for T
impl<T> OptionalSet for T
Source§fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
fn with_optional<F, T>(self, f: F, val: Option<T>) -> Self
Some), the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_validated_optional<F, T, V, E>(
self,
f: F,
value: Option<T>,
validate: V,
) -> Result<Self, E>
fn with_validated_optional<F, T, V, E>( self, f: F, value: Option<T>, validate: V, ) -> Result<Self, E>
Some) it is validated and then the provided closure is applied.
Otherwise self is returned with no modifications.Source§fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
fn with_optional_env<F, T>(self, f: F, val: Option<T>, env_var: &str) -> Self
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the FromStr implementation and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.Source§fn with_optional_custom_env<F, T, G>(
self,
f: F,
val: Option<T>,
env_var: &str,
parser: G,
) -> Self
fn with_optional_custom_env<F, T, G>( self, f: F, val: Option<T>, env_var: &str, parser: G, ) -> Self
Some), the provided closure is applied.
Otherwise, if the environment was configured and the corresponding variable was set,
the value is parsed using the provided parser and the closure is applied on that instead.
Finally, if none of those were available, self is returned with no modifications.Source§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.