mecha10_core/context/
infra_config.rs1use serde::Deserialize;
7
8#[derive(Debug, Deserialize, Clone)]
10pub struct InfrastructureConfig {
11 pub redis: RedisConfig,
13 #[serde(default)]
16 pub control_plane_redis: Option<RedisConfig>,
17 #[serde(default)]
20 pub bridge: Option<BridgeConfig>,
21 #[serde(default)]
22 pub postgres: Option<PostgresConfig>,
23 #[serde(default)]
24 pub mlflow: Option<MlflowConfig>,
25 #[serde(default)]
26 pub minio: Option<MinioConfig>,
27}
28
29#[derive(Debug, Deserialize, Clone)]
30pub struct RedisConfig {
31 pub url: String,
32 #[serde(default = "default_max_connections")]
33 pub max_connections: usize,
34 #[serde(default = "default_connection_timeout")]
35 pub connection_timeout_ms: u64,
36}
37
38impl Default for RedisConfig {
39 fn default() -> Self {
40 Self {
41 url: "redis://localhost:6379".to_string(),
42 max_connections: default_max_connections(),
43 connection_timeout_ms: default_connection_timeout(),
44 }
45 }
46}
47
48#[derive(Debug, Deserialize, Clone)]
49pub struct PostgresConfig {
50 pub host: String,
51 pub port: u16,
52 pub database: String,
53 pub username: String,
54 pub password: String,
55 #[serde(default = "default_max_connections")]
56 pub max_connections: usize,
57}
58
59#[derive(Debug, Deserialize, Clone)]
60pub struct MlflowConfig {
61 pub tracking_uri: String,
62 pub artifact_location: String,
63}
64
65#[derive(Debug, Deserialize, Clone)]
66pub struct MinioConfig {
67 pub endpoint: String,
68 pub access_key: String,
69 pub secret_key: String,
70 #[serde(default)]
71 pub secure: bool,
72}
73
74#[derive(Debug, Deserialize, Clone)]
76pub struct BridgeConfig {
77 #[serde(default = "default_bridge_enabled")]
79 pub enabled: bool,
80
81 #[serde(default = "default_local_topics")]
84 pub local_topics: Vec<String>,
85
86 #[serde(default = "default_bridged_topics")]
89 pub bridged_topics: Vec<String>,
90
91 #[serde(default)]
94 pub robot_id: Option<String>,
95}
96
97impl Default for BridgeConfig {
98 fn default() -> Self {
99 Self {
100 enabled: default_bridge_enabled(),
101 local_topics: default_local_topics(),
102 bridged_topics: default_bridged_topics(),
103 robot_id: None,
104 }
105 }
106}
107
108fn default_bridge_enabled() -> bool {
109 true
110}
111
112fn default_local_topics() -> Vec<String> {
113 vec![
114 "/sensor/camera/*".to_string(),
116 "/sensor/lidar/*".to_string(),
117 "/sensor/imu/*".to_string(),
118 ]
119}
120
121fn default_bridged_topics() -> Vec<String> {
122 vec![
123 "/system/*".to_string(),
125 "/telemetry/*".to_string(),
126 "/logs/*".to_string(),
127 "/fleet/*".to_string(),
128 ]
129}
130
131fn default_max_connections() -> usize {
132 10
133}
134
135fn default_connection_timeout() -> u64 {
136 5000
137}