pub struct CoreRuntime { /* private fields */ }
Expand description
Holds shared state/components needed to back instances of workers and clients. More than one may be instantiated, but typically only one is needed. More than one runtime instance may be useful if multiple different telemetry settings are required.
Implementations§
Source§impl CoreRuntime
impl CoreRuntime
Sourcepub fn new<F>(
telemetry_options: TelemetryOptions,
tokio_builder: TokioRuntimeBuilder<F>,
) -> Result<Self, Error>
pub fn new<F>( telemetry_options: TelemetryOptions, tokio_builder: TokioRuntimeBuilder<F>, ) -> Result<Self, Error>
Create a new core runtime with the provided telemetry options and tokio runtime builder. Also initialize telemetry for the thread this is being called on.
Note that this function will call the tokio::runtime::Builder::enable_all builder option on the Tokio runtime builder, and will call tokio::runtime::Builder::on_thread_start to ensure telemetry subscribers are set on every tokio thread.
Important: You need to call this before calling any async functions on workers or clients, otherwise the tracing subscribers will not be properly attached.
§Panics
If a tokio runtime has already been initialized. To re-use an existing runtime, call CoreRuntime::new_assume_tokio.
Sourcepub fn new_assume_tokio(
telemetry_options: TelemetryOptions,
) -> Result<Self, Error>
pub fn new_assume_tokio( telemetry_options: TelemetryOptions, ) -> Result<Self, Error>
Sourcepub fn new_assume_tokio_initialized_telem(telemetry: TelemetryInstance) -> Self
pub fn new_assume_tokio_initialized_telem(telemetry: TelemetryInstance) -> Self
Sourcepub fn tokio_handle(&self) -> Handle
pub fn tokio_handle(&self) -> Handle
Get a handle to the tokio runtime used by this Core runtime.
Sourcepub fn telemetry(&self) -> &TelemetryInstance
pub fn telemetry(&self) -> &TelemetryInstance
Return a reference to the owned TelemetryInstance
Sourcepub fn telemetry_mut(&mut self) -> &mut TelemetryInstance
pub fn telemetry_mut(&mut self) -> &mut TelemetryInstance
Return a mutable reference to the owned TelemetryInstance
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for CoreRuntime
impl !RefUnwindSafe for CoreRuntime
impl Send for CoreRuntime
impl Sync for CoreRuntime
impl Unpin for CoreRuntime
impl !UnwindSafe for CoreRuntime
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request