pub struct Compactor {
replica_id: String,
config: CompactionConfig,
snapshots: SnapshotManager,
stability: StabilityMonitor,
pruner: Pruner,
stats: CompactionStats,
current_time: u64,
}Expand description
High-level compactor that orchestrates all compaction operations.
Fields§
§replica_id: StringOur replica ID.
config: CompactionConfigConfiguration.
snapshots: SnapshotManagerSnapshot manager.
stability: StabilityMonitorStability monitor.
pruner: PrunerPruner.
stats: CompactionStatsStatistics.
current_time: u64Current logical time.
Implementations§
Source§impl Compactor
impl Compactor
Sourcepub fn with_config(
replica_id: impl Into<String>,
config: CompactionConfig,
) -> Self
pub fn with_config( replica_id: impl Into<String>, config: CompactionConfig, ) -> Self
Create a compactor with custom configuration.
Sourcepub fn replica_id(&self) -> &str
pub fn replica_id(&self) -> &str
Get the replica ID.
Sourcepub fn config(&self) -> &CompactionConfig
pub fn config(&self) -> &CompactionConfig
Get the configuration.
Sourcepub fn snapshots(&self) -> &SnapshotManager
pub fn snapshots(&self) -> &SnapshotManager
Get the snapshot manager.
Sourcepub fn snapshots_mut(&mut self) -> &mut SnapshotManager
pub fn snapshots_mut(&mut self) -> &mut SnapshotManager
Get mutable snapshot manager.
Sourcepub fn stability(&self) -> &StabilityMonitor
pub fn stability(&self) -> &StabilityMonitor
Get the stability monitor.
Sourcepub fn stability_mut(&mut self) -> &mut StabilityMonitor
pub fn stability_mut(&mut self) -> &mut StabilityMonitor
Get mutable stability monitor.
Sourcepub fn pruner_mut(&mut self) -> &mut Pruner
pub fn pruner_mut(&mut self) -> &mut Pruner
Get mutable pruner.
Sourcepub fn stats(&self) -> &CompactionStats
pub fn stats(&self) -> &CompactionStats
Get statistics.
Sourcepub fn update_local_frontier(&mut self, vv: VersionVector, heads: Vec<Hash>)
pub fn update_local_frontier(&mut self, vv: VersionVector, heads: Vec<Hash>)
Update local frontier (call after state changes).
Sourcepub fn process_peer_update(&mut self, update: FrontierUpdate)
pub fn process_peer_update(&mut self, update: FrontierUpdate)
Process a frontier update from a peer.
Sourcepub fn create_frontier_update(&self) -> FrontierUpdate
pub fn create_frontier_update(&self) -> FrontierUpdate
Create a frontier update for broadcasting.
Sourcepub fn should_snapshot(&self) -> bool
pub fn should_snapshot(&self) -> bool
Check if a snapshot should be created.
Sourcepub fn create_snapshot<F>(
&mut self,
superseded_roots: Vec<Hash>,
state_serializer: F,
) -> Result<Hash, CompactionError>
pub fn create_snapshot<F>( &mut self, superseded_roots: Vec<Hash>, state_serializer: F, ) -> Result<Hash, CompactionError>
Create a snapshot from the current state.
The state_serializer function should serialize the current CRDT state.
Sourcepub fn should_compact<S: DAGStore>(&self, _store: &S) -> bool
pub fn should_compact<S: DAGStore>(&self, _store: &S) -> bool
Check if compaction should be performed.
Sourcepub fn compact<S, F>(
&mut self,
store: &mut S,
state_serializer: F,
) -> Result<CompactionResult, CompactionError>
pub fn compact<S, F>( &mut self, store: &mut S, state_serializer: F, ) -> Result<CompactionResult, CompactionError>
Perform compaction (snapshot + prune if needed).
Sourcepub fn tick<S, F>(
&mut self,
store: &mut S,
state_serializer: F,
time: u64,
) -> Result<Option<CompactionResult>, CompactionError>
pub fn tick<S, F>( &mut self, store: &mut S, state_serializer: F, time: u64, ) -> Result<Option<CompactionResult>, CompactionError>
Perform automatic maintenance (GC stale peers, auto-compact if needed).
Sourcepub fn bootstrap_from_snapshot(
&mut self,
snapshot: Snapshot,
) -> Result<(Vec<u8>, VersionVector), CompactionError>
pub fn bootstrap_from_snapshot( &mut self, snapshot: Snapshot, ) -> Result<(Vec<u8>, VersionVector), CompactionError>
Bootstrap from a snapshot.
Returns the deserialized state data and the version vector.
Sourcepub fn get_bootstrap_snapshot(&self) -> Option<&Snapshot>
pub fn get_bootstrap_snapshot(&self) -> Option<&Snapshot>
Get the best snapshot for bootstrapping a new replica.