Skip to main content

backbone_core/config/
contexts_config.rs

1//! Cross-context communication configuration
2//!
3//! Defines event bus and context routing settings.
4
5use serde::{Deserialize, Serialize};
6
7/// Cross-context communication configuration
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct ContextsConfig {
10    /// Event bus type (in_memory, redis, kafka)
11    #[serde(default = "default_event_bus")]
12    pub event_bus: String,
13    /// Authentication context
14    #[serde(default = "default_auth_context")]
15    pub authentication: String,
16    /// File storage context
17    #[serde(default = "default_storage_context")]
18    pub file_storage: String,
19    /// Redis event bus configuration
20    #[serde(default)]
21    pub redis_event_bus: Option<RedisEventBusConfig>,
22}
23
24fn default_event_bus() -> String { "in_memory".to_string() }
25fn default_auth_context() -> String { "sapiens".to_string() }
26fn default_storage_context() -> String { "bucket".to_string() }
27
28impl Default for ContextsConfig {
29    fn default() -> Self {
30        Self {
31            event_bus: default_event_bus(),
32            authentication: default_auth_context(),
33            file_storage: default_storage_context(),
34            redis_event_bus: None,
35        }
36    }
37}
38
39/// Redis event bus configuration
40#[derive(Debug, Clone, Serialize, Deserialize)]
41pub struct RedisEventBusConfig {
42    /// Redis URL
43    pub url: String,
44    /// Channel prefix
45    #[serde(default)]
46    pub channel_prefix: Option<String>,
47    /// Max connections
48    #[serde(default)]
49    pub max_connections: Option<u32>,
50}