use std::path::PathBuf;
use std::time::Duration;
pub const DEFAULT_IDLE_TIMEOUT: Duration = Duration::from_secs(30 * 60);
#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
pub enum Transport {
#[cfg(unix)]
#[cfg_attr(unix, default)]
Uds,
#[cfg_attr(not(unix), default)]
Tcp,
}
#[derive(Debug, Clone)]
pub struct ServerConfig {
pub socket_path: PathBuf,
pub kindling_home: PathBuf,
pub pid_path: PathBuf,
pub port_path: PathBuf,
pub idle_timeout: Duration,
pub transport: Transport,
}
impl ServerConfig {
pub fn new(kindling_home: PathBuf) -> Self {
Self {
socket_path: kindling_home.join("kindling.sock"),
pid_path: kindling_home.join("kindling.pid"),
port_path: kindling_home.join("kindling.port"),
kindling_home,
idle_timeout: DEFAULT_IDLE_TIMEOUT,
transport: Transport::default(),
}
}
pub fn from_default_home() -> Option<Self> {
kindling_store::default_kindling_home().map(Self::new)
}
}