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:
- Write replicated data (
submit) - Check for duplicates (
is_current) - Query Merkle tree for cold path repair
This trait allows testing with mocks and decouples us from sync-engine internals.
Required Methods§
Sourcefn submit(
&self,
item: SyncItem,
) -> Pin<Box<dyn Future<Output = SyncResult<()>> + Send + '_>>
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).
Sourcefn delete(
&self,
key: String,
) -> Pin<Box<dyn Future<Output = SyncResult<bool>> + Send + '_>>
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().
Sourcefn delete_replicated(
&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 + '_>>
Delete a replicated item (does NOT emit CDC events).
Use this for items received via replication to prevent CDC loops.
Sourcefn is_current(
&self,
key: &str,
content_hash: &str,
) -> 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 + '_>>
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).
Sourcefn get_merkle_root(&self) -> BoxFuture<'_, Option<[u8; 32]>>
fn get_merkle_root(&self) -> BoxFuture<'_, Option<[u8; 32]>>
Get the Merkle root hash (for cold path comparison).
Provided Methods§
Sourcefn should_accept_writes(&self) -> bool
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).
Sourcefn get_clean_branches(&self) -> BoxFuture<'_, Vec<(String, [u8; 32])>>
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.
Sourcefn is_branch_clean(&self, _prefix: &str) -> BoxFuture<'_, bool>
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.
impl SyncEngineRef for SyncEngine
Implementation of SyncEngineRef for the real SyncEngine.
This allows the replication engine to drive the real storage backend directly.