#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SupervisorEventKind {
ServiceStarted,
ServiceStopped,
ServiceRestartScheduled,
ServiceRestarted,
ServiceFailed,
ServiceRecovered,
ServiceOrphaned,
RestartBudgetExceeded,
ServiceQuarantined,
SupervisorProgressed,
SupervisorStalled,
SupervisorRecovered,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SupervisorEvent {
pub service_id: String,
pub kind: SupervisorEventKind,
pub timestamp_ms: u64,
pub attempt: u64,
pub reason: String,
pub previous_state: String,
pub new_state: String,
pub trace_id: String,
}
impl SupervisorEvent {
pub(crate) fn new(
service_id: impl Into<String>,
kind: SupervisorEventKind,
timestamp_ms: u64,
attempt: u64,
transition: (&str, &str),
reason: &str,
trace_id: String,
) -> Self {
Self {
service_id: service_id.into(),
kind,
timestamp_ms,
attempt,
reason: reason.to_string(),
previous_state: transition.0.to_string(),
new_state: transition.1.to_string(),
trace_id,
}
}
}