use serde::{Deserialize, Serialize};
use crate::config::validation::require_nonzero;
use crate::errors::OrionError;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default)]
pub struct EngineConfig {
pub circuit_breaker: crate::connector::circuit_breaker::CircuitBreakerConfig,
pub health_check_timeout_secs: u64,
pub reload_timeout_secs: u64,
pub max_channel_call_depth: u32,
pub default_channel_call_timeout_ms: u64,
pub global_http_timeout_secs: u64,
pub max_pool_cache_entries: usize,
pub cache_cleanup_interval_secs: u64,
}
impl Default for EngineConfig {
fn default() -> Self {
Self {
circuit_breaker: Default::default(),
health_check_timeout_secs: 2,
reload_timeout_secs: 10,
max_channel_call_depth: 10,
default_channel_call_timeout_ms: 30_000,
global_http_timeout_secs: 30,
max_pool_cache_entries: 100,
cache_cleanup_interval_secs: 60,
}
}
}
impl EngineConfig {
pub(crate) fn validate(&self) -> Result<(), OrionError> {
require_nonzero(
u64::from(self.max_channel_call_depth),
"engine.max_channel_call_depth",
)?;
require_nonzero(
self.default_channel_call_timeout_ms,
"engine.default_channel_call_timeout_ms",
)?;
require_nonzero(
self.health_check_timeout_secs,
"engine.health_check_timeout_secs",
)?;
require_nonzero(self.reload_timeout_secs, "engine.reload_timeout_secs")?;
Ok(())
}
}