pub struct RealAdminInterfaceApi { /* private fields */ }
Expand description

The admin interface that external connections can use to make requests to the conductor The concrete (non-mock) implementation of the AdminInterfaceApi

Implementations§

Create an admin interface api.

Examples found in repository?
src/conductor/conductor.rs (line 376)
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
        pub(crate) async fn add_admin_interfaces(
            self: Arc<Self>,
            configs: Vec<AdminInterfaceConfig>,
        ) -> ConductorResult<()> {
            let admin_api = RealAdminInterfaceApi::new(self.clone());
            let stop_tx = self.task_manager.share_ref(|tm| {
                tm.as_ref()
                    .expect("Task manager not started yet")
                    .task_stop_broadcaster()
                    .clone()
            });

            // Closure to process each admin config item
            let spawn_from_config = |AdminInterfaceConfig { driver, .. }| {
                let admin_api = admin_api.clone();
                let stop_tx = stop_tx.clone();
                async move {
                    match driver {
                        InterfaceDriver::Websocket { port } => {
                            let (listener_handle, listener) =
                                spawn_websocket_listener(port).await?;
                            let port = listener_handle.local_addr().port().unwrap_or(port);
                            let handle: ManagedTaskHandle = spawn_admin_interface_task(
                                listener_handle,
                                listener,
                                admin_api.clone(),
                                stop_tx.subscribe(),
                            )?;
                            InterfaceResult::Ok((port, handle))
                        }
                    }
                }
            };

            // spawn interface tasks, collect their JoinHandles,
            // panic on errors.
            let handles: Result<Vec<_>, _> =
                future::join_all(configs.into_iter().map(spawn_from_config))
                    .await
                    .into_iter()
                    .collect();
            // Exit if the admin interfaces fail to be created
            let handles = handles.map_err(Box::new)?;

            {
                let mut ports = Vec::new();

                // First, register the keepalive task, to ensure the conductor doesn't shut down
                // in the absence of other "real" tasks
                self.manage_task(ManagedTaskAdd::ignore(
                    tokio::spawn(keep_alive_task(stop_tx.subscribe())),
                    "keepalive task",
                ))
                .await?;

                // Now that tasks are spawned, register them with the TaskManager
                for (port, handle) in handles {
                    ports.push(port);
                    self.manage_task(ManagedTaskAdd::ignore(
                        handle,
                        &format!("admin interface, port {}", port),
                    ))
                    .await?
                }
                for p in ports {
                    self.add_admin_port(p);
                }
            }
            Ok(())
        }

Trait Implementations§

Call an admin function to modify this Conductor’s behavior
Deal with error cases produced by handle_admin_request_inner
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Which request is being made
Which response is sent to the above request
Handle a request on this API

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
TODO: once 1.33.0 is the minimum supported compiler version, remove Any::type_id_compat and use StdAny::type_id instead. https://github.com/rust-lang/rust/issues/27745
The archived version of the pointer metadata for this type.
Converts some archived metadata to the pointer metadata for itself.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Deserializes using the given deserializer

Returns the argument unchanged.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The type for metadata in pointers and references to Self.
Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
upcast ref
upcast mut ref
upcast boxed dyn
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more