pub struct Reader<E: Context, V: CodecShared> { /* private fields */ }Expand description
Delivers a Queue’s committed items and tracks their acknowledgement.
Acknowledgements are in-memory, and Queue::sync prunes items below the ack floor.
Implementations§
Source§impl<E: Context, V: CodecShared> Reader<E, V>
impl<E: Context, V: CodecShared> Reader<E, V>
Sourcepub async fn recv(&mut self) -> Result<Option<(u64, V)>, Error>
pub async fn recv(&mut self) -> Result<Option<(u64, V)>, Error>
Receive the next unacknowledged item, waiting if necessary.
This method is designed for use with select!. It will:
- Return immediately if an unacked item has been published
- Wait for the queue to publish new items otherwise
- Return
Noneonce the queue is dropped and every published item has been delivered
§Errors
Returns an error if the underlying storage operation fails.
Sourcepub async fn try_recv(&mut self) -> Result<Option<(u64, V)>, Error>
pub async fn try_recv(&mut self) -> Result<Option<(u64, V)>, Error>
Try to dequeue the next unacknowledged item without waiting.
Returns None immediately if no unacked item has been published.
§Errors
Returns an error if the underlying storage operation fails.
Sourcepub fn is_acked(&self, position: u64) -> bool
pub fn is_acked(&self, position: u64) -> bool
Returns whether a specific position has been acknowledged.
Sourcepub fn ack(&mut self, position: u64) -> Result<(), Error>
pub fn ack(&mut self, position: u64) -> Result<(), Error>
Mark the item at position as processed (in-memory only). The item is skipped on
subsequent receives. If this creates a contiguous run from the ack floor, the floor
advances.
§Errors
Returns Error::PositionOutOfRange if position has not been published.
Sourcepub fn ack_up_to(&mut self, up_to: u64) -> Result<(), Error>
pub fn ack_up_to(&mut self, up_to: u64) -> Result<(), Error>
Acknowledge all items in [ack_floor, up_to) by advancing the floor directly. More
efficient than calling Self::ack in a loop.
§Errors
Returns Error::PositionOutOfRange if up_to exceeds the published items.
Sourcepub const fn ack_floor(&self) -> u64
pub const fn ack_floor(&self) -> u64
Returns the current ack floor.
All items at positions less than this value are considered acknowledged.
Sourcepub const fn read_position(&self) -> u64
pub const fn read_position(&self) -> u64
Returns the current read position.
This is the position of the next item Self::try_recv will check.
Auto Trait Implementations§
impl<E, V> !RefUnwindSafe for Reader<E, V>
impl<E, V> !UnwindSafe for Reader<E, V>
impl<E, V> Freeze for Reader<E, V>
impl<E, V> Send for Reader<E, V>
impl<E, V> Sync for Reader<E, V>
impl<E, V> Unpin for Reader<E, V>
impl<E, V> UnsafeUnpin for Reader<E, V>
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more