Struct TokioHooks
#[non_exhaustive]pub struct TokioHooks { /* private fields */ }dial9 only.Expand description
User-provided callbacks to run alongside dial9’s internal Tokio runtime hooks.
All callbacks are composed with dial9’s internal hooks: dial9 always runs first, then the user callbacks fire in registration order. This applies to all 8 hooks.
Registering the same hook multiple times (either within one closure or
across multiple with_tokio_hooks calls) stacks the callbacks — all
registered callbacks will fire.
§Example
use dial9_tokio_telemetry::telemetry::{TokioHooks, TracedRuntime, NullWriter};
let mut builder = tokio::runtime::Builder::new_multi_thread();
builder.worker_threads(4).enable_all();
let (runtime, guard) = TracedRuntime::builder()
.with_tokio_hooks(|h| {
h.on_thread_start(|| println!("started"));
h.on_thread_stop(|| println!("stopping"));
})
.build_and_start_with_writer(builder, NullWriter)
.unwrap();Implementations§
§impl TokioHooks
impl TokioHooks
pub fn on_thread_start(
&mut self,
f: impl Fn() + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_thread_start( &mut self, f: impl Fn() + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run when a runtime worker thread starts.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_thread_stop(
&mut self,
f: impl Fn() + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_thread_stop( &mut self, f: impl Fn() + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run when a runtime worker thread stops.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_thread_park(
&mut self,
f: impl Fn() + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_thread_park( &mut self, f: impl Fn() + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run when a runtime worker thread parks.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_thread_unpark(
&mut self,
f: impl Fn() + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_thread_unpark( &mut self, f: impl Fn() + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run when a runtime worker thread unparks.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_task_spawn(
&mut self,
f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_task_spawn( &mut self, f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run when a task is spawned.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_task_terminate(
&mut self,
f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_task_terminate( &mut self, f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run when a task terminates.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_before_task_poll(
&mut self,
f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_before_task_poll( &mut self, f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run before a task is polled.
Multiple callbacks can be registered; they fire in registration order.
pub fn on_after_task_poll(
&mut self,
f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static,
) -> &mut TokioHooks
pub fn on_after_task_poll( &mut self, f: impl Fn(&TaskMeta<'_>) + Send + Sync + 'static, ) -> &mut TokioHooks
Register a callback to run after a task is polled.
Multiple callbacks can be registered; they fire in registration order.
Trait Implementations§
§impl Clone for TokioHooks
impl Clone for TokioHooks
§fn clone(&self) -> TokioHooks
fn clone(&self) -> TokioHooks
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for TokioHooks
impl Debug for TokioHooks
§impl Default for TokioHooks
impl Default for TokioHooks
§fn default() -> TokioHooks
fn default() -> TokioHooks
Auto Trait Implementations§
impl !RefUnwindSafe for TokioHooks
impl !UnwindSafe for TokioHooks
impl Freeze for TokioHooks
impl Send for TokioHooks
impl Sync for TokioHooks
impl Unpin for TokioHooks
impl UnsafeUnpin for TokioHooks
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§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 more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more