use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct FeatureStoreConfig {
pub online_cache_capacity: usize,
pub write_buffer_size: usize,
pub write_buffer_max_age_micros: u64,
pub default_ttl_seconds: u64,
pub freshness_threshold: f64,
pub sync_on_write: bool,
pub parallelism: usize,
pub compaction_threshold: f64,
}
impl Default for FeatureStoreConfig {
fn default() -> Self {
Self {
online_cache_capacity: 100_000,
write_buffer_size: 4096,
write_buffer_max_age_micros: 10_000,
default_ttl_seconds: 86_400,
freshness_threshold: 0.5,
sync_on_write: false,
parallelism: 0,
compaction_threshold: 0.5,
}
}
}
impl FeatureStoreConfig {
pub fn validate(&self) -> crate::error::Result<()> {
if self.online_cache_capacity == 0 {
return Err(crate::error::SynaError::InvalidInput(
"online_cache_capacity must be > 0".to_string(),
));
}
if self.write_buffer_size == 0 {
return Err(crate::error::SynaError::InvalidInput(
"write_buffer_size must be > 0".to_string(),
));
}
if self.freshness_threshold < 0.0 || self.freshness_threshold > 1.0 {
return Err(crate::error::SynaError::InvalidInput(
"freshness_threshold must be in [0.0, 1.0]".to_string(),
));
}
if self.compaction_threshold < 0.0 || self.compaction_threshold > 1.0 {
return Err(crate::error::SynaError::InvalidInput(
"compaction_threshold must be in [0.0, 1.0]".to_string(),
));
}
Ok(())
}
}