pub struct DefaultRouteController { /* private fields */ }Expand description
Default implementation of RouteController.
Manages route lifecycle with support for:
- Starting/stopping individual routes
- Suspending and resuming routes
- Auto-startup with startup ordering
- Graceful shutdown
Implementations§
Source§impl DefaultRouteController
impl DefaultRouteController
Sourcepub fn new(registry: Arc<Mutex<Registry>>) -> Self
pub fn new(registry: Arc<Mutex<Registry>>) -> Self
Create a new DefaultRouteController with the given registry.
Sourcepub fn with_beans(
registry: Arc<Mutex<Registry>>,
beans: Arc<Mutex<BeanRegistry>>,
) -> Self
pub fn with_beans( registry: Arc<Mutex<Registry>>, beans: Arc<Mutex<BeanRegistry>>, ) -> Self
Create a new DefaultRouteController with shared bean registry.
Sourcepub fn with_languages(
registry: Arc<Mutex<Registry>>,
languages: SharedLanguageRegistry,
) -> Self
pub fn with_languages( registry: Arc<Mutex<Registry>>, languages: SharedLanguageRegistry, ) -> Self
Create a new DefaultRouteController with shared language registry.
Sourcepub fn set_self_ref(&mut self, self_ref: Arc<Mutex<dyn RouteController>>)
pub fn set_self_ref(&mut self, self_ref: Arc<Mutex<dyn RouteController>>)
Set the self-reference for creating ProducerContext.
This must be called after wrapping the controller in Arc<Mutex<>>.
Sourcepub fn set_runtime_handle(&mut self, runtime: Arc<dyn RuntimeHandle>)
pub fn set_runtime_handle(&mut self, runtime: Arc<dyn RuntimeHandle>)
Set runtime handle for ProducerContext creation.
Sourcepub fn self_ref_for_supervision(
&self,
) -> Option<Arc<Mutex<dyn RouteController>>>
pub fn self_ref_for_supervision( &self, ) -> Option<Arc<Mutex<dyn RouteController>>>
Get the self-reference, if set.
Used by SupervisingRouteController
to spawn the supervision loop.
Sourcepub fn runtime_handle_for_supervision(&self) -> Option<Arc<dyn RuntimeHandle>>
pub fn runtime_handle_for_supervision(&self) -> Option<Arc<dyn RuntimeHandle>>
Get runtime handle for supervision-triggered lifecycle commands, if set.
Sourcepub fn set_crash_notifier(&mut self, tx: Sender<CrashNotification>)
pub fn set_crash_notifier(&mut self, tx: Sender<CrashNotification>)
Set the crash notifier for supervision.
When set, the controller will send a CrashNotification whenever
a consumer crashes.
Sourcepub fn set_error_handler(&mut self, config: ErrorHandlerConfig)
pub fn set_error_handler(&mut self, config: ErrorHandlerConfig)
Set a global error handler applied to all routes without a per-route handler.
Sourcepub fn set_tracer_config(&mut self, config: &TracerConfig)
pub fn set_tracer_config(&mut self, config: &TracerConfig)
Configure tracing for this route controller.
Sourcepub fn add_route(
&mut self,
definition: RouteDefinition,
) -> Result<(), CamelError>
pub fn add_route( &mut self, definition: RouteDefinition, ) -> Result<(), CamelError>
Add a route definition to the controller.
Steps are resolved immediately using the registry.
§Errors
Returns an error if:
- A route with the same ID already exists
- Step resolution fails
Sourcepub fn compile_route_definition(
&self,
def: RouteDefinition,
) -> Result<BoxProcessor, CamelError>
pub fn compile_route_definition( &self, def: RouteDefinition, ) -> Result<BoxProcessor, CamelError>
Compile a RouteDefinition into a BoxProcessor without inserting into the route map.
Used by hot-reload to prepare a new pipeline for atomic swap without disrupting
the running route. The caller is responsible for swapping via swap_pipeline.
Sourcepub fn remove_route(&mut self, route_id: &str) -> Result<(), CamelError>
pub fn remove_route(&mut self, route_id: &str) -> Result<(), CamelError>
Remove a route from the controller map.
The route must be stopped before removal (status Stopped or Failed).
Returns an error if the route is still running or does not exist.
Does not cancel any running tasks — call stop_route first.
Sourcepub fn route_count(&self) -> usize
pub fn route_count(&self) -> usize
Returns the number of routes in the controller.
Sourcepub fn auto_startup_route_ids(&self) -> Vec<String>
pub fn auto_startup_route_ids(&self) -> Vec<String>
Returns route IDs that should auto-start, sorted by startup order (ascending).
Sourcepub fn shutdown_route_ids(&self) -> Vec<String>
pub fn shutdown_route_ids(&self) -> Vec<String>
Returns route IDs sorted by shutdown order (startup order descending).
Sourcepub fn swap_pipeline(
&self,
route_id: &str,
new_pipeline: BoxProcessor,
) -> Result<(), CamelError>
pub fn swap_pipeline( &self, route_id: &str, new_pipeline: BoxProcessor, ) -> Result<(), CamelError>
Atomically swap the pipeline of a route.
In-flight requests finish with the old pipeline (kept alive by Arc). New requests immediately use the new pipeline.
Sourcepub fn route_from_uri(&self, route_id: &str) -> Option<String>
pub fn route_from_uri(&self, route_id: &str) -> Option<String>
Returns the from_uri of a route, if it exists.
Sourcepub fn get_pipeline(&self, route_id: &str) -> Option<BoxProcessor>
pub fn get_pipeline(&self, route_id: &str) -> Option<BoxProcessor>
Get a clone of the current pipeline for a route.
This is useful for testing and introspection.
Returns None if the route doesn’t exist.
Trait Implementations§
Source§impl RouteController for DefaultRouteController
impl RouteController for DefaultRouteController
Source§fn start_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn start_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn stop_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stop_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn restart_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn restart_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn suspend_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn suspend_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn resume_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn resume_route<'life0, 'life1, 'async_trait>(
&'life0 mut self,
route_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), CamelError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§impl RouteControllerInternal for DefaultRouteController
impl RouteControllerInternal for DefaultRouteController
Source§fn add_route(&mut self, def: RouteDefinition) -> Result<(), CamelError>
fn add_route(&mut self, def: RouteDefinition) -> Result<(), CamelError>
Source§fn swap_pipeline(
&self,
route_id: &str,
pipeline: BoxProcessor,
) -> Result<(), CamelError>
fn swap_pipeline( &self, route_id: &str, pipeline: BoxProcessor, ) -> Result<(), CamelError>
Source§fn route_from_uri(&self, route_id: &str) -> Option<String>
fn route_from_uri(&self, route_id: &str) -> Option<String>
from_uri of a route by ID.Source§fn set_error_handler(&mut self, config: ErrorHandlerConfig)
fn set_error_handler(&mut self, config: ErrorHandlerConfig)
Source§fn set_self_ref(&mut self, self_ref: Arc<Mutex<dyn RouteController>>)
fn set_self_ref(&mut self, self_ref: Arc<Mutex<dyn RouteController>>)
ProducerContext.Source§fn set_runtime_handle(&mut self, runtime: Arc<dyn RuntimeHandle>)
fn set_runtime_handle(&mut self, runtime: Arc<dyn RuntimeHandle>)
Source§fn route_count(&self) -> usize
fn route_count(&self) -> usize
Source§fn auto_startup_route_ids(&self) -> Vec<String>
fn auto_startup_route_ids(&self) -> Vec<String>
Source§fn shutdown_route_ids(&self) -> Vec<String>
fn shutdown_route_ids(&self) -> Vec<String>
Source§fn set_tracer_config(&mut self, config: &TracerConfig)
fn set_tracer_config(&mut self, config: &TracerConfig)
TracerConfig.Source§fn compile_route_definition(
&self,
def: RouteDefinition,
) -> Result<BoxProcessor, CamelError>
fn compile_route_definition( &self, def: RouteDefinition, ) -> Result<BoxProcessor, CamelError>
RouteDefinition into a BoxProcessor without inserting it into the route map.
Used by hot-reload to prepare a new pipeline for atomic swap.