Skip to main content

SyncEngine

Trait SyncEngine 

Source
pub trait SyncEngine: Send + Sync {
    type Error: Error + Send + Sync + 'static;

    // Required methods
    fn sync_once(
        &self,
    ) -> impl Future<Output = Result<SyncResult, Self::Error>> + Send;
    fn status(
        &self,
    ) -> impl Future<Output = Result<SyncStatus, Self::Error>> + Send;
}
Expand description

Applies CDC events from the OLTP engine to the OLAP engine.

The sync loop (in rhei-sync) calls SyncEngine::sync_once repeatedly on a configurable interval. A crate::SyncMode controls whether the OLAP table is kept as a mirror (Destructive) or an append-only temporal store (Temporal / SCD Type 2).

§Contract for implementors

  • sync_once must be idempotent with respect to network/storage failures: a partially-applied cycle must be recoverable by re-running with the same watermark.
  • status must be cheap and non-blocking.

Required Associated Types§

Source

type Error: Error + Send + Sync + 'static

Engine-specific error type returned by all fallible methods.

Required Methods§

Source

fn sync_once( &self, ) -> impl Future<Output = Result<SyncResult, Self::Error>> + Send

Poll the CDC log and apply any new events to the OLAP engine.

Returns a SyncResult summarising the work done. If there are no new events, the result will have all counters set to zero and last_seq = None.

§Errors

Returns Err(Self::Error) if either the CDC consumer or the OLAP engine encounters an unrecoverable failure.

Source

fn status(&self) -> impl Future<Output = Result<SyncStatus, Self::Error>> + Send

Return a snapshot of the current replication state.

§Errors

Returns Err(Self::Error) if the underlying status query fails.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§