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