1use std::time::Duration;
4
5#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
7pub struct RuntimeConfig {
8 pub thread_count: Option<usize>,
13
14 pub signal_delivery: SignalDeliveryConfig,
16
17 pub outbox_enabled: bool,
19}
20
21#[derive(Clone, Copy, Debug, Eq, PartialEq)]
23pub struct SignalDeliveryConfig {
24 pub ready_timeout: Duration,
26
27 pub max_enqueue_attempts: u32,
29
30 pub initial_backoff: Duration,
32
33 pub max_backoff: Duration,
35}
36
37impl Default for SignalDeliveryConfig {
38 fn default() -> Self {
39 Self::new(
40 Duration::from_millis(50),
41 8,
42 Duration::from_millis(1),
43 Duration::from_millis(8),
44 )
45 }
46}
47
48impl SignalDeliveryConfig {
49 #[must_use]
51 pub const fn new(
52 ready_timeout: Duration,
53 max_enqueue_attempts: u32,
54 initial_backoff: Duration,
55 max_backoff: Duration,
56 ) -> Self {
57 Self {
58 ready_timeout,
59 max_enqueue_attempts,
60 initial_backoff,
61 max_backoff,
62 }
63 }
64}
65
66impl RuntimeConfig {
67 #[must_use]
69 pub fn new(thread_count: Option<usize>) -> Self {
70 Self {
71 thread_count,
72 signal_delivery: SignalDeliveryConfig::default(),
73 outbox_enabled: false,
74 }
75 }
76
77 #[must_use]
79 pub const fn with_signal_delivery(mut self, signal_delivery: SignalDeliveryConfig) -> Self {
80 self.signal_delivery = signal_delivery;
81 self
82 }
83
84 #[must_use]
86 pub const fn with_outbox_enabled(mut self, enabled: bool) -> Self {
87 self.outbox_enabled = enabled;
88 self
89 }
90}