feldera_storage/
checkpoint_synchronizer.rs

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