Skip to main content

RunnerRuntime

Struct RunnerRuntime 

Source
pub struct RunnerRuntime { /* private fields */ }

Implementations§

Source§

impl RunnerRuntime

Source

pub fn new() -> Result<Self, Box<dyn Error>>

Examples found in repository?
examples/socket_runner.rs (line 12)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let runtime = RunnerRuntime::new()?;
13
14    #[cfg(feature = "otel")]
15    {
16        let _guard = runtime.enter();
17        init_tracing("rrq-runner")?;
18    }
19
20    #[cfg(feature = "otel")]
21    let telemetry = OtelTelemetry;
22    #[cfg(not(feature = "otel"))]
23    let telemetry = NoopTelemetry;
24
25    let mut registry = Registry::new();
26    registry.register("echo", |request| async move {
27        ExecutionOutcome::success(
28            request.job_id.clone(),
29            request.request_id.clone(),
30            json!({
31                "job_id": request.job_id,
32                "params": request.params,
33            }),
34        )
35    });
36
37    let tcp_socket = std::env::var(ENV_RUNNER_TCP_SOCKET).map_err(|_| {
38        std::io::Error::new(
39            std::io::ErrorKind::InvalidInput,
40            "RRQ_RUNNER_TCP_SOCKET must be set",
41        )
42    })?;
43    let addr = parse_tcp_socket(&tcp_socket)?;
44    runtime.run_tcp_with(&registry, addr, &telemetry)
45}
Source

pub fn enter(&self) -> EnterGuard<'_>

Source

pub fn run_tcp( &self, registry: &Registry, addr: SocketAddr, ) -> Result<(), Box<dyn Error>>

Source

pub fn run_tcp_with<T: Telemetry + ?Sized>( &self, registry: &Registry, addr: SocketAddr, telemetry: &T, ) -> Result<(), Box<dyn Error>>

Examples found in repository?
examples/socket_runner.rs (line 44)
11fn main() -> Result<(), Box<dyn std::error::Error>> {
12    let runtime = RunnerRuntime::new()?;
13
14    #[cfg(feature = "otel")]
15    {
16        let _guard = runtime.enter();
17        init_tracing("rrq-runner")?;
18    }
19
20    #[cfg(feature = "otel")]
21    let telemetry = OtelTelemetry;
22    #[cfg(not(feature = "otel"))]
23    let telemetry = NoopTelemetry;
24
25    let mut registry = Registry::new();
26    registry.register("echo", |request| async move {
27        ExecutionOutcome::success(
28            request.job_id.clone(),
29            request.request_id.clone(),
30            json!({
31                "job_id": request.job_id,
32                "params": request.params,
33            }),
34        )
35    });
36
37    let tcp_socket = std::env::var(ENV_RUNNER_TCP_SOCKET).map_err(|_| {
38        std::io::Error::new(
39            std::io::ErrorKind::InvalidInput,
40            "RRQ_RUNNER_TCP_SOCKET must be set",
41        )
42    })?;
43    let addr = parse_tcp_socket(&tcp_socket)?;
44    runtime.run_tcp_with(&registry, addr, &telemetry)
45}

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more