manta_server/service/infra_backend.rs
1//! Dispatcher-meta methods on `InfraContext`.
2//!
3//! `InfraContext<'a>` itself is defined in
4//! [`crate::server::common::app_context`]; this file extends it with
5//! the two helpers every service-layer module needs that aren't
6//! per-domain trait methods on the backend dispatcher:
7//!
8//! - [`InfraContext::backend_kind`] — stable label for tracing /
9//! diagnostics, no I/O.
10//! - [`InfraContext::backend_clone`] — owned copy for use inside
11//! `'static`-bound spawned tasks (`tokio::spawn`, `JoinSet::spawn`).
12//!
13//! Earlier revisions of this module hosted per-domain wrappers
14//! (auth/bos/bss/cfs/delete_configurations/hsm/ims/migrate/pcs/redfish/
15//! sat) that re-exported each backend trait method on `InfraContext`.
16//! Those were removed; service code now imports the trait directly
17//! and calls `infra.backend.<method>(...)`. The result is fewer
18//! abstraction layers between a service function and the backend
19//! contract it's actually targeting.
20
21use crate::server::common::app_context::InfraContext;
22
23impl InfraContext<'_> {
24 /// Stable label for the active backend (`csm`, `ochami`, ...).
25 ///
26 /// Cheap, infallible — forwards to
27 /// [`crate::dispatcher::StaticBackendDispatcher::backend_kind`].
28 /// Used as a structured `tracing` field across the service and
29 /// backend_dispatcher layers.
30 pub fn backend_kind(&self) -> &'static str {
31 self.backend.backend_kind()
32 }
33
34 /// Return an owned clone of the backend dispatcher.
35 ///
36 /// `InfraContext<'a>` is borrowed, so it can't cross into a
37 /// `'static`-bound spawned future (`tokio::spawn`, `JoinSet::spawn`).
38 /// Service code that fans out per-node work needs an owned dispatcher
39 /// inside each spawned task — that's what this returns. Cloning is
40 /// cheap because `StaticBackendDispatcher` is `Arc`-shaped under the
41 /// hood.
42 pub fn backend_clone(&self) -> crate::dispatcher::StaticBackendDispatcher {
43 self.backend.clone()
44 }
45}