pub use self::exporter::{ExportConsistencyReport, ExportResult, V2ExportConfig, V2Exporter};
pub use self::manifest::{ExportManifest, ManifestSerializer, ManifestValidator};
pub use self::snapshot::{
SnapshotExportConfig, SnapshotExportResult, SnapshotExporter, SnapshotValidationReport,
};
pub mod exporter;
pub mod manifest;
pub mod snapshot;
pub struct ExportFactory;
impl ExportFactory {
pub fn create_exporter(
graph_path: &std::path::Path,
export_config: V2ExportConfig,
) -> crate::backend::native::types::NativeResult<V2Exporter> {
V2Exporter::from_graph_file(graph_path, export_config)
}
pub fn create_checkpoint_aligned_exporter(
graph_path: &std::path::Path,
export_dir: &std::path::Path,
) -> crate::backend::native::types::NativeResult<V2Exporter> {
let config = V2ExportConfig {
export_path: export_dir.join("export"),
include_wal_tail: false,
compression_enabled: false,
checksum_validation: true,
};
Self::create_exporter(graph_path, config)
}
pub fn create_full_exporter(
graph_path: &std::path::Path,
export_dir: &std::path::Path,
) -> crate::backend::native::types::NativeResult<V2Exporter> {
let config = V2ExportConfig {
export_path: export_dir.join("export"),
include_wal_tail: true,
compression_enabled: false,
checksum_validation: true,
};
Self::create_exporter(graph_path, config)
}
pub fn create_snapshot_exporter(
graph_path: &std::path::Path,
export_dir: &std::path::Path,
snapshot_id: Option<String>,
) -> crate::backend::native::types::NativeResult<SnapshotExporter> {
let config = SnapshotExportConfig {
export_path: export_dir.join("snapshot"),
snapshot_id: snapshot_id.unwrap_or_else(|| {
format!(
"snapshot_{}",
std::time::SystemTime::now()
.duration_since(std::time::UNIX_EPOCH)
.unwrap_or_default()
.as_secs()
)
}),
include_statistics: true,
min_stable_duration: std::time::Duration::from_secs(0),
checksum_validation: true,
};
SnapshotExporter::new(graph_path, config)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub enum ExportMode {
CheckpointAligned,
LsnBounded,
Full,
Snapshot,
}
#[cfg(test)]
mod tests {
use super::*;
use tempfile::tempdir;
#[test]
fn test_export_factory_creation() {
let temp_dir = tempdir().unwrap();
let graph_path = temp_dir.path().join("test.v2");
let export_dir = temp_dir.path().join("export");
let result = ExportFactory::create_checkpoint_aligned_exporter(&graph_path, &export_dir);
assert!(result.is_err() || result.is_ok()); }
}