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    /// Max keys allowed per request (default: 1000)
20    pub max_keys_per_request: usize,
21    /// Optional encryption key (32 bytes)
22    #[serde(skip)]
23    pub encryption_key: Option<[u8; 32]>,
24    /// Optional script to run after backups
25    pub post_backup_script: Option<String>,
26}
27
28impl Default for DbConfig {
29    fn default() -> Self {
30        Self {
31            path: "molten.db".to_string(),
32            tiered_mode: false,
33            sync_mode: false,
34            hot_threshold: 50000,
35            rate_limit_requests: 1000,
36            rate_limit_window: 60,
37            max_body_size: 10 * 1024 * 1024,
38            max_keys_per_request: 1000,
39            encryption_key: None,
40            post_backup_script: None,
41        }
42    }
43}