mecha10_core/context/
mod.rs1mod aggregation;
19mod builder;
20mod config;
21mod infra_config;
22mod lifecycle;
23mod node_config;
24mod pubsub;
25mod receiver;
26mod state_mgmt;
27mod topics;
28
29pub use builder::ContextBuilder;
30pub use infra_config::{BridgeConfig, InfrastructureConfig, MinioConfig, MlflowConfig, PostgresConfig, RedisConfig};
31pub use node_config::split_base_and_custom;
32pub use receiver::Receiver;
33
34use std::sync::Arc;
35use tokio::sync::RwLock;
36
37pub struct Context {
38 node_id: String,
39
40 instance: Option<String>,
41
42 #[cfg(feature = "messaging")]
43 message_bus: Arc<RwLock<mecha10_messaging::MessageBus>>,
44
45 #[cfg(feature = "messaging")]
46 control_plane_bus: Arc<RwLock<Option<mecha10_messaging::MessageBus>>>,
47
48 #[cfg(feature = "messaging")]
49 redis_bridge: Arc<RwLock<Option<crate::redis_bridge::RedisBridge>>>,
50
51 shutdown: Arc<RwLock<bool>>,
52
53 state_manager: Arc<RwLock<Option<Arc<crate::state::ConcreteStateManager>>>>,
54}
55impl Clone for Context {
56 fn clone(&self) -> Self {
57 Self {
58 node_id: self.node_id.clone(),
59 instance: self.instance.clone(),
60 #[cfg(feature = "messaging")]
61 message_bus: Arc::clone(&self.message_bus),
62 #[cfg(feature = "messaging")]
63 control_plane_bus: Arc::clone(&self.control_plane_bus),
64 #[cfg(feature = "messaging")]
65 redis_bridge: Arc::clone(&self.redis_bridge),
66 shutdown: Arc::clone(&self.shutdown),
67 state_manager: Arc::clone(&self.state_manager),
68 }
69 }
70}