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