use std::time::Duration;
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct MeshOsConfig {
pub this_node: super::event::NodeId,
pub tick_interval: Duration,
pub event_queue_capacity: usize,
pub action_queue_capacity: usize,
pub backpressure: BackpressureConfig,
pub locality: LocalityConfig,
pub maintenance: MaintenanceConfig,
pub scheduler: super::scheduler::SchedulerConfig,
}
impl Default for MeshOsConfig {
fn default() -> Self {
Self {
this_node: 0,
tick_interval: Duration::from_millis(500),
event_queue_capacity: 1024,
action_queue_capacity: 1024,
backpressure: BackpressureConfig::default(),
locality: LocalityConfig::default(),
maintenance: MaintenanceConfig::default(),
scheduler: super::scheduler::SchedulerConfig::default(),
}
}
}
impl MeshOsConfig {
pub fn with_this_node(mut self, node: super::event::NodeId) -> Self {
self.this_node = node;
self
}
pub fn with_tick_interval(mut self, interval: Duration) -> Self {
self.tick_interval = interval;
self
}
pub fn with_event_queue_capacity(mut self, capacity: usize) -> Self {
self.event_queue_capacity = capacity;
self
}
pub fn with_action_queue_capacity(mut self, capacity: usize) -> Self {
self.action_queue_capacity = capacity;
self
}
pub fn with_backpressure(mut self, backpressure: BackpressureConfig) -> Self {
self.backpressure = backpressure;
self
}
pub fn with_locality(mut self, locality: LocalityConfig) -> Self {
self.locality = locality;
self
}
pub fn with_maintenance(mut self, maintenance: MaintenanceConfig) -> Self {
self.maintenance = maintenance;
self
}
pub fn with_scheduler(mut self, scheduler: super::scheduler::SchedulerConfig) -> Self {
self.scheduler = scheduler;
self
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct BackpressureConfig {
pub pull_cooldown: Duration,
pub drain_rate_per_zone_per_sec: u32,
pub replica_stabilization_window: Duration,
pub cluster_backpressure_threshold: usize,
pub cluster_backpressure_release: usize,
pub max_defer_count: u32,
}
impl Default for BackpressureConfig {
fn default() -> Self {
Self {
pull_cooldown: Duration::from_millis(250),
drain_rate_per_zone_per_sec: 10,
replica_stabilization_window: Duration::from_secs(60),
cluster_backpressure_threshold: 1000,
cluster_backpressure_release: 200,
max_defer_count: 16,
}
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct LocalityConfig {
pub degraded_rtt_threshold: Duration,
pub avoid_ttl: Duration,
}
impl Default for LocalityConfig {
fn default() -> Self {
Self {
degraded_rtt_threshold: Duration::from_millis(250),
avoid_ttl: Duration::from_secs(5 * 60),
}
}
}
#[derive(Clone, Debug)]
#[non_exhaustive]
pub struct MaintenanceConfig {
pub default_drain_deadline: Duration,
pub recovery_ramp_window: Duration,
}
impl Default for MaintenanceConfig {
fn default() -> Self {
Self {
default_drain_deadline: Duration::from_secs(10 * 60),
recovery_ramp_window: Duration::from_secs(5 * 60),
}
}
}