/*
 * This is an auto-generated file.
 * Any manual changes may be overwritten without notice!
 */

use derive_builder::Builder;
use serde::{Deserialize, Serialize};

/// Reschedule configures how Tasks are rescheduled  when they crash or fail.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct ReschedulePolicy {
    /// Unlimited allows rescheduling attempts until they succeed
    #[serde(rename = "unlimited", skip_serializing_if = "Option::is_none")]
    pub unlimited: Option<bool>,

    /// Attempts limits the number of rescheduling attempts that can occur in an interval.
    #[serde(rename = "attempts", skip_serializing_if = "Option::is_none")]
    pub attempts: Option<i64>,

    /// Interval is a duration in which we can limit the number of reschedule attempts.
    #[serde(
        rename = "interval",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub interval: Option<chrono::TimeDelta>,

    /// Delay is a minimum duration to wait between reschedule attempts.
    /// The delay function determines how much subsequent reschedule attempts are delayed by.
    #[serde(
        rename = "delay",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub delay: Option<chrono::TimeDelta>,

    /// DelayFunction determines how the delay progressively changes on subsequent reschedule
    /// attempts. Valid values are "exponential", "constant", and "fibonacci".
    #[serde(rename = "delay_function", skip_serializing_if = "Option::is_none")]
    pub delay_function: Option<String>,

    /// MaxDelay is an upper bound on the delay.
    #[serde(
        rename = "max_delay",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub max_delay: Option<chrono::TimeDelta>,
}
