pub struct ConsumerCursor {
pub consumer_id: String,
pub partition_key: String,
pub current_offset: u64,
}Expand description
Partition-specific durable read position for one consumer.
Fields§
§consumer_id: StringStable consumer identifier.
partition_key: StringDurable channel partition key, formatted as channel_id:partition_index.
current_offset: u64Current persisted read offset for this consumer and partition.
Implementations§
Source§impl ConsumerCursor
impl ConsumerCursor
Sourcepub fn new(
consumer_id: impl Into<String>,
partition_key: impl Into<String>,
) -> Self
pub fn new( consumer_id: impl Into<String>, partition_key: impl Into<String>, ) -> Self
Creates a fresh cursor at offset zero.
Sourcepub fn from_persisted(
consumer_id: impl Into<String>,
partition_key: impl Into<String>,
current_offset: u64,
) -> Self
pub fn from_persisted( consumer_id: impl Into<String>, partition_key: impl Into<String>, current_offset: u64, ) -> Self
Creates a cursor from an offset read from durable storage.
Sourcepub async fn resume(
consumer_id: impl Into<String>,
partition_key: impl Into<String>,
store: &dyn DurableStore,
) -> Result<Self, DurabilityError>
pub async fn resume( consumer_id: impl Into<String>, partition_key: impl Into<String>, store: &dyn DurableStore, ) -> Result<Self, DurabilityError>
Resumes a cursor by reading the CAS-backed offset value.
§Errors
Propagates store read errors from DurableStore::read_value.
Sourcepub fn consumer_id(&self) -> &str
pub fn consumer_id(&self) -> &str
Returns the stable consumer identifier.
Sourcepub fn partition_key(&self) -> &str
pub fn partition_key(&self) -> &str
Returns the durable channel partition key, formatted as channel_id:partition_index.
Sourcepub const fn current_offset(&self) -> u64
pub const fn current_offset(&self) -> u64
Returns the current persisted read offset.
Sourcepub fn cursor_key(&self) -> String
pub fn cursor_key(&self) -> String
Returns the haematite CAS key used for this cursor.
Sourcepub async fn checkpoint(
&mut self,
store: &dyn DurableStore,
new_offset: u64,
) -> Result<(), DurabilityError>
pub async fn checkpoint( &mut self, store: &dyn DurableStore, new_offset: u64, ) -> Result<(), DurabilityError>
Persists a new cursor position with compare-and-swap.
§Errors
Returns DurabilityError::CursorRegression when new_offset is lower than this
cursor’s current offset, and propagates store CAS errors including stale checkpoints.
Trait Implementations§
Source§impl Clone for ConsumerCursor
impl Clone for ConsumerCursor
Source§fn clone(&self) -> ConsumerCursor
fn clone(&self) -> ConsumerCursor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConsumerCursor
impl Debug for ConsumerCursor
impl Eq for ConsumerCursor
Source§impl PartialEq for ConsumerCursor
impl PartialEq for ConsumerCursor
Source§fn eq(&self, other: &ConsumerCursor) -> bool
fn eq(&self, other: &ConsumerCursor) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for ConsumerCursor
Auto Trait Implementations§
impl Freeze for ConsumerCursor
impl RefUnwindSafe for ConsumerCursor
impl Send for ConsumerCursor
impl Sync for ConsumerCursor
impl Unpin for ConsumerCursor
impl UnsafeUnpin for ConsumerCursor
impl UnwindSafe for ConsumerCursor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.