use core_types::Timestamp;
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum AlertSeverity {
Info,
Warn,
Error,
Critical,
}
impl AlertSeverity {
pub fn as_str(&self) -> &'static str {
match self {
Self::Info => "info",
Self::Warn => "warn",
Self::Error => "error",
Self::Critical => "critical",
}
}
}
#[derive(Clone, Debug)]
pub struct Alert {
pub source: String,
pub code: String,
pub message: String,
pub severity: AlertSeverity,
pub timestamp: Timestamp,
}
impl Alert {
pub fn new(
source: impl Into<String>,
code: impl Into<String>,
message: impl Into<String>,
severity: AlertSeverity,
timestamp: Timestamp,
) -> Self {
Self {
source: source.into(),
code: code.into(),
message: message.into(),
severity,
timestamp,
}
}
}