Skip to main content

laminar_core/checkpoint/
authority.rs

1//! Feature-neutral authority values for durable checkpoint protocol records.
2
3use uuid::Uuid;
4
5/// Exact process incarnation that owns one leader term.
6#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
7pub struct LeaderProofOwner {
8    /// Stable cluster node identity.
9    pub node_id: u64,
10    /// Boot-unique process identity.
11    pub boot_id: Uuid,
12    /// Durable process term for the stable node identity.
13    pub process_term: u64,
14}
15
16impl LeaderProofOwner {
17    /// Whether every identity dimension has a canonical production value.
18    #[must_use]
19    pub fn is_canonical(&self) -> bool {
20        self.node_id != 0 && !self.boot_id.is_nil() && self.process_term != 0
21    }
22}
23
24/// Authority captured for one exact leader term.
25#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
26pub struct LeaderProof {
27    /// Exact process incarnation that owns the leader term.
28    pub owner: LeaderProofOwner,
29    /// Durable fencing token for that ownership term.
30    pub fencing_token: u64,
31}
32
33impl LeaderProof {
34    /// Whether the exact owner and fencing token have canonical production values.
35    #[must_use]
36    pub fn is_canonical(&self) -> bool {
37        self.owner.is_canonical() && self.fencing_token != 0
38    }
39}