SyncEngineRef

Trait SyncEngineRef 

Source
pub trait SyncEngineRef:
    Send
    + Sync
    + 'static {
    // Required methods
    fn submit(
        &self,
        item: SyncItem,
    ) -> Pin<Box<dyn Future<Output = SyncResult<()>> + Send + '_>>;
    fn delete(
        &self,
        key: String,
    ) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>;
    fn is_current(
        &self,
        key: &str,
        content_hash: &str,
    ) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>;
    fn get_merkle_root(&self) -> BoxFuture<'_, Option<[u8; 32]>>;
    fn get_merkle_children(
        &self,
        path: &str,
    ) -> BoxFuture<'_, Vec<(String, [u8; 32])>>;
    fn get(&self, key: &str) -> BoxFuture<'_, Option<Vec<u8>>>;

    // Provided method
    fn should_accept_writes(&self) -> bool { ... }
}
Expand description

Trait defining what we need from sync-engine.

The daemon provides an implementation of this trait, allowing us to:

  1. Write replicated data (submit)
  2. Check for duplicates (is_current)
  3. Query Merkle tree for cold path repair

This trait allows testing with mocks and decouples us from sync-engine internals.

Required Methods§

Source

fn submit( &self, item: SyncItem, ) -> Pin<Box<dyn Future<Output = SyncResult<()>> + Send + '_>>

Submit an item to the local sync-engine.

This is how we write replicated data from peers. The SyncItem contains all necessary fields (key, content, hash, version).

Source

fn delete( &self, key: String, ) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>

Delete an item from the local sync-engine.

Source

fn is_current( &self, key: &str, content_hash: &str, ) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>

Check if we already have content with this hash.

Returns true if the item exists AND its content hash matches. Used for CDC deduplication (loop prevention).

Source

fn get_merkle_root(&self) -> BoxFuture<'_, Option<[u8; 32]>>

Get the Merkle root hash (for cold path comparison).

Source

fn get_merkle_children( &self, path: &str, ) -> BoxFuture<'_, Vec<(String, [u8; 32])>>

Get children of a Merkle path (for cold path drill-down).

Source

fn get(&self, key: &str) -> BoxFuture<'_, Option<Vec<u8>>>

Fetch an item by key (for cold path repair).

Provided Methods§

Source

fn should_accept_writes(&self) -> bool

Check if the sync-engine is accepting writes (backpressure check).

Returns false when the engine is under critical pressure (>= 90% memory). Callers should pause ingestion when this returns false to avoid wasting CPU on events that will be rejected.

Default implementation returns true (always accept).

Implementations on Foreign Types§

Source§

impl SyncEngineRef for SyncEngine

Implementation of SyncEngineRef for the real SyncEngine.

This allows the replication engine to drive the real storage backend directly.

Source§

fn should_accept_writes(&self) -> bool

Source§

fn submit( &self, item: SyncItem, ) -> Pin<Box<dyn Future<Output = SyncResult<()>> + Send + '_>>

Source§

fn delete( &self, key: String, ) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>

Source§

fn is_current( &self, key: &str, content_hash: &str, ) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>

Source§

fn get_merkle_root(&self) -> BoxFuture<'_, Option<[u8; 32]>>

Source§

fn get_merkle_children( &self, path: &str, ) -> BoxFuture<'_, Vec<(String, [u8; 32])>>

Source§

fn get(&self, key: &str) -> BoxFuture<'_, Option<Vec<u8>>>

Implementors§