Skip to main content

Sequencer

Trait Sequencer 

Source
pub trait Sequencer: Send + Sync {
    type Meta: Send + Sync;

    // Required methods
    fn commit(
        &self,
        batches: &[CommitBatch<'_, Self::Meta>],
    ) -> Result<Vec<CommitOutcome>, ObjectLogError>;
    fn lookup(
        &self,
        partition: &PartitionKey,
        fetch_offset: i64,
    ) -> Result<Vec<IndexEntry>, ObjectLogError>;
    fn high_watermark(
        &self,
        partition: &PartitionKey,
    ) -> Result<i64, ObjectLogError>;
    fn log_start_offset(
        &self,
        partition: &PartitionKey,
    ) -> Result<i64, ObjectLogError>;
    fn truncate_before(
        &self,
        partition: &PartitionKey,
        offset: i64,
    ) -> Result<Vec<String>, ObjectLogError>;

    // Provided method
    fn supports_multi_object_commit(&self) -> bool { ... }
}
Expand description

The linearization point: assigns offsets to durably-stored batches and owns the offset→location index.

Synchronous on purpose — a lin-point is a critical section, not async I/O. The engine calls it from its flush worker (a dedicated thread / blocking task), so a blocking implementation (a Mutex, a SQL transaction) is fine.

Contract: commit is atomic across the whole slice (all supplied batches commit together or not at all), and the engine presents batches for any single PartitionKey in arrival order and never splits one partition across concurrent commit calls.

Required Associated Types§

Source

type Meta: Send + Sync

Sequencer-private per-batch metadata, forwarded uninterpreted by the engine. object-log’s default sequencers use (); a Kafka coordinator uses its producer-identity fields.

Required Methods§

Source

fn commit( &self, batches: &[CommitBatch<'_, Self::Meta>], ) -> Result<Vec<CommitOutcome>, ObjectLogError>

Assign offsets to durably uploaded batches and persist the index. By default these belong to one object; an opted-in implementation may receive several objects in one ordered call. Returns one CommitOutcome per input batch, in order. Atomic: on Err, nothing is committed.

Source

fn lookup( &self, partition: &PartitionKey, fetch_offset: i64, ) -> Result<Vec<IndexEntry>, ObjectLogError>

Resolve fetch_offset to the ordered index entries covering it onward.

Source

fn high_watermark( &self, partition: &PartitionKey, ) -> Result<i64, ObjectLogError>

The next offset to be assigned (index-only; no object reads).

Source

fn log_start_offset( &self, partition: &PartitionKey, ) -> Result<i64, ObjectLogError>

The first readable offset (advances on truncate_before).

Source

fn truncate_before( &self, partition: &PartitionKey, offset: i64, ) -> Result<Vec<String>, ObjectLogError>

Retention MECHANISM (not policy): drop index entries below offset and return object ids that now have no live references from any partition (objects are multiplexed and shared), for the engine to delete.

Provided Methods§

Source

fn supports_multi_object_commit(&self) -> bool

Opt in to atomic commits containing already-durable batches from several data objects, in creation order. Default preserves one-object calls for custom sequencers that rely on that boundary.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§