pub struct Writer<E: Clock + Storage + Metrics, V: CodecShared> { /* private fields */ }Expand description
Writer handle for enqueueing items.
This handle can be cloned to allow multiple tasks to enqueue items concurrently. All clones share the same underlying queue and notification channel.
Implementations§
Source§impl<E: Clock + Storage + Metrics, V: CodecShared> Writer<E, V>
impl<E: Clock + Storage + Metrics, V: CodecShared> Writer<E, V>
Sourcepub async fn enqueue(&self, item: V) -> Result<u64, Error>
pub async fn enqueue(&self, item: V) -> Result<u64, Error>
Enqueue an item, returning its position. The lock is held for the full append + commit, so no reader can see the item until it is durable.
§Errors
Returns an error if the underlying storage operation fails.
Sourcepub async fn enqueue_bulk(
&self,
items: impl IntoIterator<Item = V>,
) -> Result<Range<u64>, Error>
pub async fn enqueue_bulk( &self, items: impl IntoIterator<Item = V>, ) -> Result<Range<u64>, Error>
Enqueue a batch of items with a single commit, returning positions
[start, end). The lock is held for the full batch, so no reader can
see any item until the entire batch is durable.
§Errors
Returns an error if any append or the final commit fails.
Sourcepub async fn append(&self, item: V) -> Result<u64, Error>
pub async fn append(&self, item: V) -> Result<u64, Error>
Append an item without committing, returning its position. The item
is immediately visible to the reader but is not durable until
Self::commit is called or the underlying journal auto-syncs at a
section boundary (see variable::Journal
invariant 1).
§Errors
Returns an error if the underlying storage operation fails.
Trait Implementations§
Auto Trait Implementations§
impl<E, V> Freeze for Writer<E, V>
impl<E, V> !RefUnwindSafe for Writer<E, V>
impl<E, V> Send for Writer<E, V>
impl<E, V> Sync for Writer<E, V>
impl<E, V> Unpin for Writer<E, V>
impl<E, V> UnsafeUnpin for Writer<E, V>
impl<E, V> !UnwindSafe for Writer<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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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