use super::*;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct TransportPosture {
pub auth: bool,
pub wire_strict: bool,
pub mesh_declared: bool,
}
impl TransportPosture {
pub const fn new(auth: bool, wire_strict: bool, mesh_declared: bool) -> Self {
Self {
auth,
wire_strict,
mesh_declared,
}
}
pub fn is_safe(&self) -> bool {
(self.auth && self.wire_strict) || self.mesh_declared
}
pub fn highlight(&self) -> Option<&'static str> {
if !self.auth && !self.mesh_declared {
Some("AUTH MISSING")
} else {
None
}
}
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RoutingMode {
#[default]
Direct,
SingleEndpoint,
}
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct TopologyFence {
committed_epoch: ClusterEpoch,
}
impl TopologyFence {
pub const fn new(committed_epoch: ClusterEpoch) -> Self {
Self { committed_epoch }
}
pub fn committed_epoch(&self) -> ClusterEpoch {
self.committed_epoch
}
pub fn admit(&self, msg_epoch: ClusterEpoch) -> bool {
msg_epoch >= self.committed_epoch
}
pub fn commit(&mut self, epoch: ClusterEpoch) {
if epoch > self.committed_epoch {
self.committed_epoch = epoch;
}
}
}