Skip to main content

CdcStorage

Trait CdcStorage 

Source
pub trait CdcStorage:
    Send
    + Sync
    + Clone
    + 'static {
    // Required methods
    fn write(&self, cdc: &Cdc) -> CdcStorageResult<()>;
    fn read(&self, version: CommitVersion) -> CdcStorageResult<Option<Cdc>>;
    fn read_range(
        &self,
        start: Bound<CommitVersion>,
        end: Bound<CommitVersion>,
        batch_size: u64,
    ) -> CdcStorageResult<CdcBatch>;
    fn count(&self, version: CommitVersion) -> CdcStorageResult<usize>;
    fn min_version(&self) -> CdcStorageResult<Option<CommitVersion>>;
    fn max_version(&self) -> CdcStorageResult<Option<CommitVersion>>;
    fn drop_before(
        &self,
        version: CommitVersion,
    ) -> CdcStorageResult<DropBeforeResult>;

    // Provided methods
    fn exists(&self, version: CommitVersion) -> CdcStorageResult<bool> { ... }
    fn range(
        &self,
        start: Bound<CommitVersion>,
        end: Bound<CommitVersion>,
    ) -> CdcStorageResult<CdcBatch> { ... }
    fn scan(&self, batch_size: u64) -> CdcStorageResult<CdcBatch> { ... }
}
Expand description

Trait for CDC storage backends.

CDC storage stores fully resolved change data capture entries keyed by CommitVersion. Unlike MVCC storage, CDC entries are immutable and use simple version keys.

Implementations must be thread-safe and cloneable to support concurrent access from multiple consumers and the CDC generation pipeline.

Required Methods§

Source

fn write(&self, cdc: &Cdc) -> CdcStorageResult<()>

Write a CDC entry (fully resolved values).

The entry is keyed by its version. If an entry already exists at this version, it will be overwritten (this should only happen during recovery/replay).

Source

fn read(&self, version: CommitVersion) -> CdcStorageResult<Option<Cdc>>

Read a CDC entry by version.

Returns None if no entry exists at the given version.

Source

fn read_range( &self, start: Bound<CommitVersion>, end: Bound<CommitVersion>, batch_size: u64, ) -> CdcStorageResult<CdcBatch>

Read CDC entries in a version range.

Returns entries in ascending version order up to batch_size entries. The CdcBatch.has_more flag indicates if more entries exist beyond the batch.

Source

fn count(&self, version: CommitVersion) -> CdcStorageResult<usize>

Count CDC changes at a specific version.

Returns 0 if no entry exists at the given version.

Source

fn min_version(&self) -> CdcStorageResult<Option<CommitVersion>>

Get the minimum (oldest) CDC version in storage.

Returns None if storage is empty.

Source

fn max_version(&self) -> CdcStorageResult<Option<CommitVersion>>

Get the maximum (newest) CDC version in storage.

Returns None if storage is empty.

Source

fn drop_before( &self, version: CommitVersion, ) -> CdcStorageResult<DropBeforeResult>

Delete all CDC entries with version strictly less than the given version. Returns the count and entry information for stats tracking.

Provided Methods§

Source

fn exists(&self, version: CommitVersion) -> CdcStorageResult<bool>

Check if a CDC entry exists at the given version.

Source

fn range( &self, start: Bound<CommitVersion>, end: Bound<CommitVersion>, ) -> CdcStorageResult<CdcBatch>

Convenience method with default batch size.

Source

fn scan(&self, batch_size: u64) -> CdcStorageResult<CdcBatch>

Scan all CDC entries with the given batch size.

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.

Implementations on Foreign Types§

Source§

impl<T: CdcStorage> CdcStorage for Arc<T>

Blanket implementation for CdcStore compatibility with existing traits.

Implementors§