use appcore_core::NodeId;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Heartbeat {
pub node_id: NodeId,
pub timestamp_ms: u64,
}
pub trait HeartbeatSource {
fn heartbeat(&self) -> Heartbeat;
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct StaticHeartbeatSource {
heartbeat: Heartbeat,
}
impl StaticHeartbeatSource {
pub fn new(node_id: NodeId, timestamp_ms: u64) -> Self {
Self {
heartbeat: Heartbeat {
node_id,
timestamp_ms,
},
}
}
}
impl HeartbeatSource for StaticHeartbeatSource {
fn heartbeat(&self) -> Heartbeat {
self.heartbeat.clone()
}
}
#[cfg(test)]
#[path = "heartbeat_tests.rs"]
mod tests;