Skip to main content

MetadataEventLog

Trait MetadataEventLog 

Source
pub trait MetadataEventLog: Send + Sync {
    // Required methods
    fn partition_count(&self) -> i32;
    fn publish<'life0, 'async_trait>(
        &'life0 self,
        partition: i32,
        event: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<i64, MetadataLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn subscribe(
        &self,
        assignment: Vec<PartitionStart>,
    ) -> (MetadataEventStream, Arc<dyn AssignmentHandle>);
    fn high_water_marks<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, MetadataLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn publish_keyed<'life0, 'async_trait>(
        &'life0 self,
        _partition: i32,
        _key: Bytes,
        _event: Option<Bytes>,
    ) -> Pin<Box<dyn Future<Output = Result<i64, MetadataLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn publish_keyed_group<'life0, 'async_trait>(
        &'life0 self,
        events: Vec<KeyedEvent>,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, MetadataLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn low_water_marks<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, MetadataLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn visit_range<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        partition: i32,
        start: i64,
        end: i64,
        visit: &'life1 mut RangeVisitor<'life2>,
    ) -> Pin<Box<dyn Future<Output = Result<(), MetadataLogError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

Publish/subscribe transport that backs the __remote_log_metadata topic.

Implementations must guarantee:

  • publish(p, _) resolves to a monotonically-increasing offset within partition p, and the assigned offset is also what every subscriber observes for that record.
  • The stream returned by subscribe replays each assigned partition’s backlog from its start_offset and then forwards new records as they are published for currently-assigned partitions. Subscribers attached after some records were already published still see the history at/after their start offset.
  • Records are delivered in publish order on a per-partition basis.

Required Methods§

Source

fn partition_count(&self) -> i32

Number of partitions the log holds. It is stable for the lifetime of the log. The manager hashes user partitions into [0, partition_count()).

Source

fn publish<'life0, 'async_trait>( &'life0 self, partition: i32, event: Bytes, ) -> Pin<Box<dyn Future<Output = Result<i64, MetadataLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append event to partition. Resolves to the assigned offset.

§Errors

Returns MetadataLogError if the transport refused the write. That happens when the partition is out of range, or when the log has been closed.

Source

fn subscribe( &self, assignment: Vec<PartitionStart>, ) -> (MetadataEventStream, Arc<dyn AssignmentHandle>)

Start to consume the given partitions, each from its start offset, which is inclusive. Returns the event stream and a handle to mutate the live assignment.

The stream replays each assigned partition’s backlog from its start_offset, then forwards live appends for the currently assigned partitions. Records are delivered in publish order on a per-partition basis.

Source

fn high_water_marks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, MetadataLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

One past the highest written offset for each partition, indexed by partition.

§Errors

Returns MetadataLogError only on an underlying store failure. An empty partition is 0, not an error.

Provided Methods§

Source

fn publish_keyed<'life0, 'async_trait>( &'life0 self, _partition: i32, _key: Bytes, _event: Option<Bytes>, ) -> Pin<Box<dyn Future<Output = Result<i64, MetadataLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append a keyed value or tombstone to a compacted metadata topic.

The default rejects keyed publication. A transport used for compaction must override this method.

Source

fn publish_keyed_group<'life0, 'async_trait>( &'life0 self, events: Vec<KeyedEvent>, ) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, MetadataLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Append a group of keyed records and wait until every one of them is acknowledged. Resolves to their offsets, in the order given.

Records for the same partition are appended in the order given. A transport that pipelines writes submits the whole group before it waits, so the group costs one acknowledgment round trip rather than one per record. It still waits for every submitted record before it returns, so none is left in flight after an error.

The default publishes the records one at a time through Self::publish_keyed and stops at the first failure.

§Errors

Returns the first MetadataLogError that any record met. Any subset of the group may then have been appended.

Source

fn low_water_marks<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<i64>, MetadataLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Earliest retained offset for each partition, indexed by partition.

Append-only implementations retain offset zero. Compacted transports override this so a replay does not wait forever on deleted offsets.

Source

fn visit_range<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, partition: i32, start: i64, end: i64, visit: &'life1 mut RangeVisitor<'life2>, ) -> Pin<Box<dyn Future<Output = Result<(), MetadataLogError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Pass every retained record of partition whose offset lies in [start, end) to visit, in offset order.

The read neither subscribes nor writes, so a reader that holds only READ and DESCRIBE on the topic can use it. A transport hands records over as it fetches them and holds at most one fetched page, so the range can be larger than memory. A compacted transport steps over the offsets compaction removed and still returns once it reaches end. An empty range visits nothing.

A networked transport retries transient failures, such as a leader change, without a bound of its own. Bound the read with a deadline.

The default reports that the transport does not serve range reads.

§Errors

Returns MetadataLogError::PartitionOutOfRange for a partition outside the log, the first error that visit returns, and MetadataLogError when the store fails or stops short of end.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§