Expand description
Service adapters for integrating existing Janus modules with the
JanusSupervisor.
The existing Janus services (Forward, Backward, CNS, Data) expose a
start_module(state: Arc<JanusState>) -> Result<()> entry point that
internally polls state.is_shutdown_requested() for lifecycle control.
The supervisor, however, manages services through the JanusService
trait which passes a CancellationToken for shutdown signalling.
This module provides ModuleAdapter — a bridge that:
- Wraps any
start_module-style async function into aJanusService - Bridges the supervisor’s
CancellationToken→JanusState::request_shutdown() - Propagates errors back to the supervisor for restart decisions
§Example
ⓘ
use janus_core::supervisor::adapters::ModuleAdapter;
use janus_core::supervisor::RestartPolicy;
let data_adapter = ModuleAdapter::new(
"data",
state.clone(),
|s| Box::pin(janus_data::start_module(s)),
RestartPolicy::OnFailure,
);
supervisor.spawn_service(Box::new(data_adapter));Structs§
- ApiModule
Adapter - A convenience wrapper for the API module which is always started
immediately (it doesn’t wait for
start_services()) and should always be restarted on failure. - Module
Adapter - Adapts an existing
start_module(Arc<JanusState>) -> Result<()>function into aJanusServicethat the supervisor can manage.
Type Aliases§
- Module
Start Fn - A boxed async function that takes
Arc<JanusState>and returns aResult.