Skip to main content

link_cli/engine/
maintenance.rs

1//! Optional bounded namespace maintenance; ordinary atomic stores need not implement it.
2use super::cluster::{AtomicJournalStore, JournalVersion};
3use crate::LinkError;
4
5#[derive(Clone, Copy, Debug)]
6pub struct JournalScanOptions {
7    pub max_keys: usize,
8    /// Decoded UTF-8 key bytes, eight generation bytes, and record bytes plus
9    /// one separator per record. Container overhead also depends on record count.
10    pub max_bytes: usize,
11    pub page_keys: usize,
12    /// Omit record payloads; returned versions contain empty entries.
13    pub keys_only: bool,
14}
15impl Default for JournalScanOptions {
16    fn default() -> Self {
17        Self {
18            max_keys: 4096,
19            max_bytes: 8_388_608,
20            page_keys: 128,
21            keys_only: false,
22        }
23    }
24}
25#[derive(Clone, Debug, PartialEq, Eq)]
26pub struct JournalNamespaceEntry {
27    pub key: String,
28    pub version: JournalVersion,
29}
30/// Scans return the COMPLETE namespace at one linearizable point or an error,
31/// never partial success. Every generation must be nonzero and never reused,
32/// including after deletion. A delete error has an unknown outcome: do not retry
33/// blindly. This capability supplies no object-liveness or reclamation policy.
34pub trait JournalMaintenanceStore: AtomicJournalStore {
35    fn scan_namespace(
36        &mut self,
37        options: JournalScanOptions,
38    ) -> Result<Vec<JournalNamespaceEntry>, LinkError>;
39    fn compare_delete(&mut self, key: &str, expected_generation: u64) -> Result<bool, LinkError>;
40}