use std::time::Duration;
use super::{DEFAULT_CHANNEL_CAPACITY, DEFAULT_INTER_AGENT_DELAY, DEFAULT_SHUTDOWN_TIMEOUT};
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum BackendLogLevel {
Error,
#[default]
Warn,
Info,
Debug,
}
impl BackendLogLevel {
#[must_use]
pub fn as_str(self) -> &'static str {
match self {
Self::Error => "error",
Self::Warn => "warn",
Self::Info => "info",
Self::Debug => "debug",
}
}
}
impl std::fmt::Display for BackendLogLevel {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.as_str())
}
}
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(default)]
pub struct RuntimeConfig {
pub channel_capacity: usize,
pub shutdown_timeout: Duration,
pub inter_agent_delay: Duration,
pub backend_log_level: BackendLogLevel,
}
impl Default for RuntimeConfig {
fn default() -> Self {
Self {
channel_capacity: DEFAULT_CHANNEL_CAPACITY,
shutdown_timeout: DEFAULT_SHUTDOWN_TIMEOUT,
inter_agent_delay: DEFAULT_INTER_AGENT_DELAY,
backend_log_level: BackendLogLevel::default(),
}
}
}