ralph/contracts/config/
retry.rs1use schemars::JsonSchema;
10use serde::{Deserialize, Serialize};
11
12#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
18#[serde(default, deny_unknown_fields)]
19pub struct RunnerRetryConfig {
20 #[schemars(range(min = 1, max = 20))]
22 pub max_attempts: Option<u32>,
23
24 #[schemars(range(min = 0, max = 600_000))]
26 pub base_backoff_ms: Option<u32>,
27
28 #[schemars(range(min = 1.0, max = 10.0))]
30 pub multiplier: Option<f64>,
31
32 #[schemars(range(min = 0, max = 600_000))]
34 pub max_backoff_ms: Option<u32>,
35
36 #[schemars(range(min = 0.0, max = 1.0))]
38 pub jitter_ratio: Option<f64>,
39}
40
41impl RunnerRetryConfig {
42 pub fn merge_from(&mut self, other: Self) {
44 if other.max_attempts.is_some() {
45 self.max_attempts = other.max_attempts;
46 }
47 if other.base_backoff_ms.is_some() {
48 self.base_backoff_ms = other.base_backoff_ms;
49 }
50 if other.multiplier.is_some() {
51 self.multiplier = other.multiplier;
52 }
53 if other.max_backoff_ms.is_some() {
54 self.max_backoff_ms = other.max_backoff_ms;
55 }
56 if other.jitter_ratio.is_some() {
57 self.jitter_ratio = other.jitter_ratio;
58 }
59 }
60}