use std::time::Duration;
#[derive(Debug, Clone)]
pub struct ChildSpec {
pub name: String,
pub restart_policy: RestartPolicy,
pub shutdown_timeout: Duration,
}
impl ChildSpec {
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
restart_policy: RestartPolicy::Permanent,
shutdown_timeout: Duration::from_secs(5),
}
}
pub fn restart_policy(mut self, policy: RestartPolicy) -> Self {
self.restart_policy = policy;
self
}
pub fn shutdown_timeout(mut self, timeout: Duration) -> Self {
self.shutdown_timeout = timeout;
self
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum RestartPolicy {
Permanent,
Temporary,
Transient,
}