use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, Default, JsonSchema)]
#[serde(default, deny_unknown_fields)]
pub struct RunnerRetryConfig {
#[schemars(range(min = 1, max = 20))]
pub max_attempts: Option<u32>,
#[schemars(range(min = 0, max = 600_000))]
pub base_backoff_ms: Option<u32>,
#[schemars(range(min = 1.0, max = 10.0))]
pub multiplier: Option<f64>,
#[schemars(range(min = 0, max = 600_000))]
pub max_backoff_ms: Option<u32>,
#[schemars(range(min = 0.0, max = 1.0))]
pub jitter_ratio: Option<f64>,
}
impl RunnerRetryConfig {
pub fn merge_from(&mut self, other: Self) {
if other.max_attempts.is_some() {
self.max_attempts = other.max_attempts;
}
if other.base_backoff_ms.is_some() {
self.base_backoff_ms = other.base_backoff_ms;
}
if other.multiplier.is_some() {
self.multiplier = other.multiplier;
}
if other.max_backoff_ms.is_some() {
self.max_backoff_ms = other.max_backoff_ms;
}
if other.jitter_ratio.is_some() {
self.jitter_ratio = other.jitter_ratio;
}
}
}