stackpatrol-core 0.2.5

Shared types and protocol definitions for StackPatrol CLI and control plane.
Documentation
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "snake_case", tag = "kind")]
pub enum Event {
    Heartbeat {
        uptime_secs: u64,
    },
    ServiceDown {
        name: String,
    },
    ServiceUp {
        name: String,
    },
    /// Disk usage crossed the warning threshold (default 10pp below `disk_high`).
    /// Heads-up alert before things go critical. Suppressed if the value is
    /// already in critical range — `DiskHigh` covers that case.
    DiskWarning {
        mount: String,
        percent: u8,
    },
    DiskHigh {
        mount: String,
        percent: u8,
    },
    /// Memory usage crossed the warning threshold (default 10pp below `memory_high`).
    MemoryWarning {
        percent: u8,
    },
    MemoryHigh {
        percent: u8,
    },
    /// 1-minute load crossed the warning threshold (default 75% of `load_1m_high`).
    LoadWarning {
        load_1m: f32,
    },
    LoadHigh {
        load_1m: f32,
    },
    HostUnreachable,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct EventEnvelope {
    pub server_name: String,
    pub timestamp: i64,
    pub event: Event,
}