use std::path::PathBuf;
use crate::schema::{AppendFsync, EvictionPolicy};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct ServerSection {
pub bind: [u8; 4],
pub port: u16,
pub threads: usize,
pub accept_shards: Option<usize>,
pub packed_rows: bool,
pub max_clients: usize,
pub data_dir: PathBuf,
}
impl Default for ServerSection {
fn default() -> Self {
Self {
bind: [127, 0, 0, 1],
port: 6004,
threads: 0,
accept_shards: None,
packed_rows: true,
max_clients: 10_000,
data_dir: PathBuf::from("."),
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct PersistenceSection {
pub aof: bool,
pub appendfsync: AppendFsync,
pub auto_aof_rewrite_percentage: u32,
pub auto_aof_rewrite_min_size: u64,
pub auto_aof_rewrite_bytes: u64,
pub auto_aof_rewrite_interval_secs: u64,
pub replay_resync: bool,
}
impl Default for PersistenceSection {
fn default() -> Self {
Self {
aof: true,
appendfsync: AppendFsync::EverySec,
auto_aof_rewrite_percentage: 100,
auto_aof_rewrite_min_size: 64 * 1024 * 1024,
auto_aof_rewrite_bytes: 0,
auto_aof_rewrite_interval_secs: 0,
replay_resync: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
#[non_exhaustive]
pub struct MemorySection {
pub maxmemory: u64,
pub maxmemory_policy: EvictionPolicy,
}
impl Default for MemorySection {
fn default() -> Self {
Self { maxmemory: 0, maxmemory_policy: EvictionPolicy::NoEviction }
}
}