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 delete_replicated(
        &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 methods
    fn should_accept_writes(&self) -> bool { ... }
    fn get_clean_branches(&self) -> BoxFuture<'_, Vec<(String, [u8; 32])>> { ... }
    fn is_branch_clean(&self, _prefix: &str) -> BoxFuture<'_, 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.

Note: This emits CDC events. For replicated deletes, use delete_replicated().

Source

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

Delete a replicated item (does NOT emit CDC events).

Use this for items received via replication to prevent CDC loops.

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).

Source

fn get_clean_branches(&self) -> BoxFuture<'_, Vec<(String, [u8; 32])>>

Get clean branches (no pending merkle recalcs) with their hashes.

Returns branches that are safe to compare with peers. Branches with pending writes should be skipped during cold path sync.

Source

fn is_branch_clean(&self, _prefix: &str) -> BoxFuture<'_, bool>

Check if a specific branch is clean (no pending merkle recalcs).

Returns true if the branch has no dirty items and is safe to compare.

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 delete_replicated( &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>>>

Source§

fn get_clean_branches(&self) -> BoxFuture<'_, Vec<(String, [u8; 32])>>

Source§

fn is_branch_clean(&self, prefix: &str) -> BoxFuture<'_, bool>

Implementors§