Skip to main content

laminar_core/cluster/control/leader_lease/
artifact_admission.rs

1use super::{
2    CheckpointArtifactInventory, ClusterCheckpointAuthorityError, LeaderLeaseStore, LeaderProof,
3};
4
5impl LeaderLeaseStore {
6    /// Read the unresolved cluster checkpoint artifact inventory, if any.
7    ///
8    /// # Errors
9    /// Fails when the durable authority head is unavailable or invalid.
10    pub async fn cluster_checkpoint_artifacts(
11        &self,
12    ) -> Result<Option<CheckpointArtifactInventory>, ClusterCheckpointAuthorityError> {
13        Ok(self
14            .cluster_checkpoint_artifact_admission()
15            .await?
16            .map(|(inventory, _)| inventory))
17    }
18
19    /// Read the unresolved cluster checkpoint artifact inventory and its admitting leader term.
20    ///
21    /// The returned proof identifies the term that admitted the inventory; callers must still
22    /// certify that term against their current assignment before acting on it.
23    ///
24    /// # Errors
25    /// Fails when the durable authority head is unavailable or invalid.
26    pub async fn cluster_checkpoint_artifact_admission(
27        &self,
28    ) -> Result<Option<(CheckpointArtifactInventory, LeaderProof)>, ClusterCheckpointAuthorityError>
29    {
30        Ok(self.load_record().await?.and_then(|head| {
31            head.active_checkpoint_artifacts
32                .zip(head.active_checkpoint_artifact_leader_proof)
33        }))
34    }
35}