Skip to main content

feldera_storage/
checkpoint_synchronizer.rs

1use std::sync::{Arc, LazyLock};
2
3use feldera_types::{
4    checkpoint::{CheckpointMetadata, CheckpointSyncMetrics},
5    config::SyncConfig,
6};
7
8use crate::StorageBackend;
9
10pub trait CheckpointSynchronizer: Sync {
11    fn push(
12        &self,
13        checkpoint: uuid::Uuid,
14        storage: Arc<dyn StorageBackend>,
15        remote_config: SyncConfig,
16    ) -> anyhow::Result<Option<CheckpointSyncMetrics>>;
17
18    fn pull(
19        &self,
20        storage: Arc<dyn StorageBackend>,
21        remote_config: SyncConfig,
22    ) -> anyhow::Result<(CheckpointMetadata, Option<CheckpointSyncMetrics>)>;
23}
24
25inventory::collect!(&'static dyn CheckpointSynchronizer);
26
27/// Lazily resolves the checkpoint synchronizer.
28///
29/// This panic is safe as all enterprise builds must include the checkpoint-sync
30/// crate.
31pub static SYNCHRONIZER: LazyLock<&'static dyn CheckpointSynchronizer> = LazyLock::new(|| {
32    *inventory::iter::<&dyn CheckpointSynchronizer>
33        .into_iter()
34        .next()
35        .expect("no checkpoint synchronizer found; are enterprise features enabled?")
36});