Skip to main content

CdcRing

Struct CdcRing 

Source
pub struct CdcRing { /* private fields */ }
Expand description

Fixed-capacity circular buffer for CDC events.

Events are appended with push and assigned a monotonically increasing sequence number. When the buffer is full the oldest slot is silently overwritten. Consumers read batches via read and are informed through CdcReadResult::gap when events they have not yet consumed were evicted.

Implementations§

Source§

impl CdcRing

Source

pub fn new(capacity: usize) -> Self

Create a new ring buffer that can hold up to capacity events.

§Panics

Panics if capacity is zero.

Source

pub fn push( &mut self, op: CdcOp, key: Vec<u8>, value: Option<Vec<u8>>, timestamp_ms: u64, )

Append a mutation event to the ring, assigning it the next sequence number.

If the buffer is full the oldest event is overwritten and start_seq advances accordingly.

Source

pub fn write_seq(&self) -> u64

Return the sequence number that will be assigned to the next pushed event.

Source

pub fn start_seq(&self) -> u64

Return the earliest sequence number still available in the buffer.

Source

pub fn len(&self) -> usize

Return the number of events currently retained in the buffer.

Source

pub fn is_empty(&self) -> bool

Return true if no events have been pushed yet.

Source

pub fn read(&self, from_seq: u64, limit: usize) -> CdcReadResult

Read up to limit events starting at from_seq.

If from_seq has already been evicted the read begins at the earliest available sequence and CdcReadResult::gap is set to true, signalling that the consumer missed events.

Source

pub fn get(&self, seq: u64) -> Option<&CdcEvent>

Look up a single event by its sequence number.

Returns None if seq has been evicted or has not been written yet.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.