use std::time::Duration;
#[derive(Debug)]
pub struct EffectPolicies {
pub track_history: bool,
pub max_history_size: usize,
pub allow_cross_thread_coordination: bool,
pub coordination_timeout: Duration,
#[allow(dead_code)] pub enforce_strict_ordering: bool,
pub enable_effect_isolation: bool,
pub max_concurrent_effects_per_thread: usize,
#[allow(dead_code)] pub enable_automatic_rollback: bool,
}
impl Default for EffectPolicies {
fn default() -> Self {
Self {
track_history: true,
max_history_size: 10000,
allow_cross_thread_coordination: true,
coordination_timeout: Duration::from_secs(5),
enforce_strict_ordering: true,
enable_effect_isolation: true,
max_concurrent_effects_per_thread: 100,
enable_automatic_rollback: true,
}
}
}
impl EffectPolicies {
pub fn no_history() -> Self {
Self {
track_history: false,
max_history_size: 0,
allow_cross_thread_coordination: true,
coordination_timeout: Duration::from_secs(5),
enforce_strict_ordering: true,
enable_effect_isolation: true,
max_concurrent_effects_per_thread: 100,
enable_automatic_rollback: true,
}
}
pub fn minimal() -> Self {
Self {
track_history: false,
max_history_size: 0,
allow_cross_thread_coordination: false,
coordination_timeout: Duration::from_millis(100),
enforce_strict_ordering: false,
enable_effect_isolation: false,
max_concurrent_effects_per_thread: 10,
enable_automatic_rollback: false,
}
}
pub fn high_concurrency() -> Self {
Self {
track_history: false,
max_history_size: 1000,
allow_cross_thread_coordination: true,
coordination_timeout: Duration::from_millis(500),
enforce_strict_ordering: false,
enable_effect_isolation: true,
max_concurrent_effects_per_thread: 1000,
enable_automatic_rollback: true,
}
}
}