use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CheckpointSettings {
#[serde(default = "default_checkpoint_interval")]
pub interval_secs: u64,
#[serde(default = "default_core_timeout")]
pub core_timeout_secs: u64,
#[serde(default = "default_wal_segment_target_mb")]
pub wal_segment_target_mb: u64,
#[serde(default = "default_compaction_interval")]
pub compaction_interval_secs: u64,
#[serde(default = "default_compaction_tombstone_threshold")]
pub compaction_tombstone_threshold: f64,
}
impl Default for CheckpointSettings {
fn default() -> Self {
Self {
interval_secs: default_checkpoint_interval(),
core_timeout_secs: default_core_timeout(),
wal_segment_target_mb: default_wal_segment_target_mb(),
compaction_interval_secs: default_compaction_interval(),
compaction_tombstone_threshold: default_compaction_tombstone_threshold(),
}
}
}
impl CheckpointSettings {
pub fn to_manager_config(&self) -> crate::control::checkpoint_manager::CheckpointManagerConfig {
crate::control::checkpoint_manager::CheckpointManagerConfig {
interval: std::time::Duration::from_secs(self.interval_secs),
core_timeout: std::time::Duration::from_secs(self.core_timeout_secs),
}
}
pub fn wal_segment_target_bytes(&self) -> u64 {
self.wal_segment_target_mb * 1024 * 1024
}
pub fn compaction_interval(&self) -> std::time::Duration {
std::time::Duration::from_secs(self.compaction_interval_secs)
}
}
fn default_checkpoint_interval() -> u64 {
300
}
fn default_core_timeout() -> u64 {
30
}
fn default_wal_segment_target_mb() -> u64 {
64
}
fn default_compaction_interval() -> u64 {
600
}
fn default_compaction_tombstone_threshold() -> f64 {
0.2
}