surreal_sync_core/checkpoint/
config.rs1#[derive(Debug, Clone)]
5pub enum CheckpointStorage {
6 Disabled,
8 Filesystem { dir: String },
10 SurrealDB {
12 table_name: String,
13 namespace: String,
14 database: String,
15 },
16}
17
18#[derive(Debug, Clone)]
22pub struct SyncConfig {
23 pub incremental: bool,
29
30 pub emit_checkpoints: bool,
34
35 pub checkpoint_storage: CheckpointStorage,
37}
38
39impl Default for SyncConfig {
40 fn default() -> Self {
41 Self {
42 incremental: false,
43 emit_checkpoints: true,
44 checkpoint_storage: CheckpointStorage::Filesystem {
45 dir: ".surreal-sync-checkpoints".to_string(),
46 },
47 }
48 }
49}
50
51impl SyncConfig {
52 pub fn new() -> Self {
54 Self::default()
55 }
56
57 pub fn full_sync_with_checkpoints(checkpoint_dir: String) -> Self {
59 Self {
60 incremental: false,
61 emit_checkpoints: true,
62 checkpoint_storage: CheckpointStorage::Filesystem {
63 dir: checkpoint_dir,
64 },
65 }
66 }
67
68 pub fn full_sync_with_surrealdb_checkpoints(
70 table_name: String,
71 namespace: String,
72 database: String,
73 ) -> Self {
74 Self {
75 incremental: false,
76 emit_checkpoints: true,
77 checkpoint_storage: CheckpointStorage::SurrealDB {
78 table_name,
79 namespace,
80 database,
81 },
82 }
83 }
84
85 pub fn incremental() -> Self {
87 Self {
88 incremental: true,
89 emit_checkpoints: false,
90 checkpoint_storage: CheckpointStorage::Disabled,
91 }
92 }
93
94 pub fn should_emit_checkpoints(&self) -> bool {
96 self.emit_checkpoints && !matches!(self.checkpoint_storage, CheckpointStorage::Disabled)
97 }
98}