Skip to main content

ProjectionCheckpointStore

Trait ProjectionCheckpointStore 

Source
pub trait ProjectionCheckpointStore {
    // Required methods
    async fn load_projection_checkpoint(
        &self,
        name: &str,
    ) -> Result<GlobalProjectionCheckpoint, EngineError>;
    async fn save_projection_checkpoint(
        &self,
        name: &str,
        checkpoint: &GlobalProjectionCheckpoint,
    ) -> Result<(), EngineError>;

    // Provided method
    async fn advance_projection_cursors(
        &self,
        name: &str,
        _previous: &GlobalProjectionCheckpoint,
        current: &GlobalProjectionCheckpoint,
    ) -> Result<(), EngineError> { ... }
}
Expand description

Persist and load named GlobalProjectionCheckpoint values.

Implement this trait on your event store to enable ProjectionRunner::catch_up_persistent, which avoids full replays on restart by persisting cursor progress after each catch-up cycle.

The SlateDB implementation stores one key per (projection, stream) pair under the cp/{name}/{stream_id} key space (raw u64 LE — no JSON). This bounds each catch_up_persistent cycle to O(changed_streams) writes instead of O(total_streams), which matters for MABIS deployments tracking tens of thousands of streams. Other backing stores may choose any suitable serialisation.

Required Methods§

Source

async fn load_projection_checkpoint( &self, name: &str, ) -> Result<GlobalProjectionCheckpoint, EngineError>

Load a previously saved checkpoint by name.

Returns an empty GlobalProjectionCheckpoint (all cursors zero) when no checkpoint has been persisted for name yet — this triggers a full replay from the beginning.

§Errors

Returns EngineError::Store on storage failure.

Source

async fn save_projection_checkpoint( &self, name: &str, checkpoint: &GlobalProjectionCheckpoint, ) -> Result<(), EngineError>

Persist checkpoint under name, overwriting any previously stored value.

§Errors

Returns EngineError::Store on storage failure.

Provided Methods§

Source

async fn advance_projection_cursors( &self, name: &str, _previous: &GlobalProjectionCheckpoint, current: &GlobalProjectionCheckpoint, ) -> Result<(), EngineError>

Persist only the cursors that advanced since previous.

The default implementation ignores previous and saves the full current checkpoint. Override in storage backends that support per-key atomic writes (e.g. SlateDB WriteBatch) for O(changed) write cost instead of O(total streams).

§Errors

Returns EngineError::Store on storage failure.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§