pub struct Registry { /* private fields */ }Implementations§
Source§impl Registry
impl Registry
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/socket_runner.rs (line 32)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19 let runtime = RunnerRuntime::new()?;
20
21 #[cfg(feature = "otel")]
22 {
23 let _guard = runtime.enter();
24 init_tracing("rrq-runner")?;
25 }
26
27 #[cfg(feature = "otel")]
28 let telemetry = OtelTelemetry;
29 #[cfg(not(feature = "otel"))]
30 let telemetry = NoopTelemetry;
31
32 let mut registry = Registry::new();
33 registry.register("echo", |request| async move {
34 ExecutionOutcome::success(
35 request.job_id.clone(),
36 request.request_id.clone(),
37 json!({
38 "job_id": request.job_id,
39 "params": request.params,
40 }),
41 )
42 });
43
44 let args: Vec<String> = std::env::args().skip(1).collect();
45 let tcp_socket = read_arg_value(&args, "--tcp-socket").ok_or_else(|| {
46 std::io::Error::new(
47 std::io::ErrorKind::InvalidInput,
48 "--tcp-socket must be provided",
49 )
50 })?;
51 let addr = parse_tcp_socket(&tcp_socket)?;
52 runtime.run_tcp_with(®istry, addr, &telemetry)
53}Sourcepub fn register<F, Fut>(&mut self, name: impl Into<String>, handler: F)where
F: Fn(ExecutionRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ExecutionOutcome> + Send + 'static,
pub fn register<F, Fut>(&mut self, name: impl Into<String>, handler: F)where
F: Fn(ExecutionRequest) -> Fut + Send + Sync + 'static,
Fut: Future<Output = ExecutionOutcome> + Send + 'static,
Examples found in repository?
examples/socket_runner.rs (lines 33-42)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19 let runtime = RunnerRuntime::new()?;
20
21 #[cfg(feature = "otel")]
22 {
23 let _guard = runtime.enter();
24 init_tracing("rrq-runner")?;
25 }
26
27 #[cfg(feature = "otel")]
28 let telemetry = OtelTelemetry;
29 #[cfg(not(feature = "otel"))]
30 let telemetry = NoopTelemetry;
31
32 let mut registry = Registry::new();
33 registry.register("echo", |request| async move {
34 ExecutionOutcome::success(
35 request.job_id.clone(),
36 request.request_id.clone(),
37 json!({
38 "job_id": request.job_id,
39 "params": request.params,
40 }),
41 )
42 });
43
44 let args: Vec<String> = std::env::args().skip(1).collect();
45 let tcp_socket = read_arg_value(&args, "--tcp-socket").ok_or_else(|| {
46 std::io::Error::new(
47 std::io::ErrorKind::InvalidInput,
48 "--tcp-socket must be provided",
49 )
50 })?;
51 let addr = parse_tcp_socket(&tcp_socket)?;
52 runtime.run_tcp_with(®istry, addr, &telemetry)
53}pub fn get(&self, name: &str) -> Option<Arc<dyn Handler>>
pub async fn execute(&self, request: ExecutionRequest) -> ExecutionOutcome
pub async fn execute_with<T: Telemetry + ?Sized>( &self, request: ExecutionRequest, telemetry: &T, ) -> ExecutionOutcome
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Registry
impl !RefUnwindSafe for Registry
impl Send for Registry
impl Sync for Registry
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl !UnwindSafe for Registry
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