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

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

/// Disconnect strategy defines how both clients and server should behave in case of
/// disconnection between them.
///
/// This struct was generated based on the Go types of the official Nomad API.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, Builder)]
pub struct DisconnectStrategy {
    /// Defines for how long a disconnected client will keep its allocations running.
    #[serde(
        rename = "stop_on_client_after",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub stop_on_client_after: Option<chrono::TimeDelta>,

    /// A boolean field used to define if the allocations should be replaced while
    /// it's considered disconnected.
    #[serde(rename = "replace", skip_serializing_if = "Option::is_none")]
    pub replace: Option<bool>,

    /// Once the disconnected node starts reporting again, it will define which
    /// instances to keep: the original allocations, the replacement, the one
    /// running on the node with the best score as it is currently implemented,
    /// or the allocation that has been running continuously the longest.
    #[serde(rename = "reconcile", skip_serializing_if = "Option::is_none")]
    pub reconcile: Option<String>,

    /// Defines for how long the server will consider the unresponsive node as
    /// disconnected but alive instead of lost.
    #[serde(
        rename = "lost_after",
        skip_serializing_if = "Option::is_none",
        serialize_with = "crate::serialize_duration_option",
        deserialize_with = "crate::deserialize_duration_option",
        default
    )]
    pub lost_after: Option<chrono::TimeDelta>,
}
