Skip to main content

Sequencer

Trait Sequencer 

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

Show 14 methods // 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 methods fn supports_multi_object_commit(&self) -> bool { ... } fn supports_conditional_commit(&self) -> bool { ... } fn commit_conditionally( &self, batches: &[CommitBatch<'_, Self::Meta>], expected_heads: &[Option<i64>], ) -> Result<Vec<ConditionalCommitOutcome>, ObjectLogError> { ... } fn fence_epoch( &self, partition: &PartitionKey, expected: u64, new_epoch: u64, ) -> Result<(), ObjectLogError> { ... } fn partition_epoch(&self, partition: &PartitionKey) -> Option<u64> { ... } fn rejection_error( &self, partition: &PartitionKey, epoch: u64, reason: String, ) -> ObjectLogError { ... } fn acquire_authoritative_epoch( &self, partition: &PartitionKey, ) -> Result<AuthoritativePartitionState, ObjectLogError> { ... } fn authoritative_partition_state( &self, partition: &PartitionKey, ) -> Result<AuthoritativePartitionState, ObjectLogError> { ... } fn refresh_partition( &self, partition: &PartitionKey, ) -> Result<(), ObjectLogError> { ... }
}
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.

Publication scope belongs to the implementation. InMemorySequencer validates and commits the whole slice under one lock. Durable manifest publication linearizes each partition independently, so an error can follow a durable earlier partition; callers must not infer global rollback. The engine presents each 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.

An Err may follow indexed earlier partitions; unacknowledged publication remains ambiguous. A CommitOutcome::Rejected batch was not indexed, while other batches in the same call may already be durable.

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.

Source

fn supports_conditional_commit(&self) -> bool

Whether this sequencer implements native durable head conditions.

Source

fn commit_conditionally( &self, batches: &[CommitBatch<'_, Self::Meta>], expected_heads: &[Option<i64>], ) -> Result<Vec<ConditionalCommitOutcome>, ObjectLogError>

Opt-in head compare-and-append. Conditions are next log offsets, not record insertion counters or sparse hints. Partition publication remains independent; this is not a cross-partition transaction. The default rejects any condition before calling the legacy commit implementation.

Source

fn fence_epoch( &self, partition: &PartitionKey, expected: u64, new_epoch: u64, ) -> Result<(), ObjectLogError>

Move the stored fence epoch for partition from expected to new_epoch.

The default succeeds without storing anything. ManifestSequencer reads that partition’s durable index, fails when its epoch is neither expected nor new_epoch, and otherwise stores new_epoch, creating the index when it is missing. Once this returns, a writer that has not seen the new epoch cannot commit to the partition.

Source

fn partition_epoch(&self, partition: &PartitionKey) -> Option<u64>

👎Deprecated since 0.3.6:

the engine no longer reads fence epochs; implement rejection_error instead

The fence epoch this handle last read for partition, if it tracks one.

The default returns None.

Source

fn rejection_error( &self, partition: &PartitionKey, epoch: u64, reason: String, ) -> ObjectLogError

The error the engine reports for a batch this sequencer answered with CommitOutcome::Rejected. epoch is the fence epoch the batch was produced at.

Classifying a rejection is the sequencer’s policy; the engine only forwards the result. The default reports ObjectLogError::Sequencer with the rejection reason.

Source

fn acquire_authoritative_epoch( &self, partition: &PartitionKey, ) -> Result<AuthoritativePartitionState, ObjectLogError>

Acquire a fresh durable writer epoch and the matching bounds from this call’s successful CAS. This grants no ongoing writer exclusivity. An error may follow a durable epoch advance; never infer no effect. Unsupported implementations fail without legacy fence fallback.

Source

fn authoritative_partition_state( &self, partition: &PartitionKey, ) -> Result<AuthoritativePartitionState, ObjectLogError>

Read validated durable state directly; unsupported implementations fail without invoking legacy refresh or cached getters.

Source

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

Reload partition’s index from durable storage, so this handle sees commits made by other writers since it opened.

The default does nothing: a sequencer with a single writer is already current.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§