camel_api/producer.rs
1//! Producer context for dependency injection.
2//!
3//! This module provides [`ProducerContext`] for holding shared dependencies
4//! that producers need access to, such as the route controller.
5
6use crate::route_controller::RouteController;
7use std::sync::Arc;
8use tokio::sync::Mutex;
9
10/// Context provided to producers for dependency injection.
11///
12/// `ProducerContext` holds references to shared infrastructure components
13/// that producers may need access to during message production.
14pub struct ProducerContext {
15 route_controller: Arc<Mutex<dyn RouteController>>,
16}
17
18impl ProducerContext {
19 /// Creates a new `ProducerContext` with the given route controller.
20 pub fn new(route_controller: Arc<Mutex<dyn RouteController>>) -> Self {
21 Self { route_controller }
22 }
23
24 /// Returns a reference to the route controller.
25 pub fn route_controller(&self) -> &Arc<Mutex<dyn RouteController>> {
26 &self.route_controller
27 }
28}