Compactor

Struct Compactor 

Source
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: String

Our replica ID.

§config: CompactionConfig

Configuration.

§snapshots: SnapshotManager

Snapshot manager.

§stability: StabilityMonitor

Stability monitor.

§pruner: Pruner

Pruner.

§stats: CompactionStats

Statistics.

§current_time: u64

Current logical time.

Implementations§

Source§

impl Compactor

Source

pub fn new(replica_id: impl Into<String>) -> Self

Create a new compactor.

Source

pub fn with_config( replica_id: impl Into<String>, config: CompactionConfig, ) -> Self

Create a compactor with custom configuration.

Source

pub fn replica_id(&self) -> &str

Get the replica ID.

Source

pub fn config(&self) -> &CompactionConfig

Get the configuration.

Source

pub fn snapshots(&self) -> &SnapshotManager

Get the snapshot manager.

Source

pub fn snapshots_mut(&mut self) -> &mut SnapshotManager

Get mutable snapshot manager.

Source

pub fn stability(&self) -> &StabilityMonitor

Get the stability monitor.

Source

pub fn stability_mut(&mut self) -> &mut StabilityMonitor

Get mutable stability monitor.

Source

pub fn pruner(&self) -> &Pruner

Get the pruner.

Source

pub fn pruner_mut(&mut self) -> &mut Pruner

Get mutable pruner.

Source

pub fn stats(&self) -> &CompactionStats

Get statistics.

Source

pub fn set_time(&mut self, time: u64)

Update the current time.

Source

pub fn update_local_frontier(&mut self, vv: VersionVector, heads: Vec<Hash>)

Update local frontier (call after state changes).

Source

pub fn process_peer_update(&mut self, update: FrontierUpdate)

Process a frontier update from a peer.

Source

pub fn create_frontier_update(&self) -> FrontierUpdate

Create a frontier update for broadcasting.

Source

pub fn should_snapshot(&self) -> bool

Check if a snapshot should be created.

Source

pub fn create_snapshot<F>( &mut self, superseded_roots: Vec<Hash>, state_serializer: F, ) -> Result<Hash, CompactionError>
where F: FnOnce() -> Result<Vec<u8>, String>,

Create a snapshot from the current state.

The state_serializer function should serialize the current CRDT state.

Source

pub fn should_compact<S: DAGStore>(&self, _store: &S) -> bool

Check if compaction should be performed.

Source

pub fn compact<S, F>( &mut self, store: &mut S, state_serializer: F, ) -> Result<CompactionResult, CompactionError>
where S: DAGStore + PrunableStore, F: FnOnce() -> Result<Vec<u8>, String>,

Perform compaction (snapshot + prune if needed).

Source

pub fn tick<S, F>( &mut self, store: &mut S, state_serializer: F, time: u64, ) -> Result<Option<CompactionResult>, CompactionError>
where S: DAGStore + PrunableStore, F: FnOnce() -> Result<Vec<u8>, String>,

Perform automatic maintenance (GC stale peers, auto-compact if needed).

Source

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.

Source

pub fn get_bootstrap_snapshot(&self) -> Option<&Snapshot>

Get the best snapshot for bootstrapping a new replica.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.