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