Skip to main content

moltendb_core/engine/
config.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct DbConfig {
5    /// Path to the database file (e.g., "my_database.log")
6    pub path: String,
7    /// Enable tiered storage (hot + cold log)
8    pub tiered_mode: bool,
9    /// Force synchronous writes (no data loss, lower performance)
10    pub sync_mode: bool,
11    /// Max documents to keep in RAM per collection
12    pub hot_threshold: usize,
13    /// Rate limiting: max requests per window
14    pub rate_limit_requests: u32,
15    /// Rate limiting: window size in seconds
16    pub rate_limit_window: u64,
17    /// Max request body size in bytes
18    pub max_body_size: usize,
19    /// Optional encryption key (32 bytes)
20    #[serde(skip)]
21    pub encryption_key: Option<[u8; 32]>,
22    /// Optional script to run after backups
23    pub post_backup_script: Option<String>,
24}
25
26impl Default for DbConfig {
27    fn default() -> Self {
28        Self {
29            path: "molten.db".to_string(),
30            tiered_mode: false,
31            sync_mode: false,
32            hot_threshold: 50000,
33            rate_limit_requests: 1000,
34            rate_limit_window: 60,
35            max_body_size: 10 * 1024 * 1024,
36            encryption_key: None,
37            post_backup_script: None,
38        }
39    }
40}