pub struct MemorySeeker { /* private fields */ }Expand description
A clonable handle repositioning one MemorySubscriber, minted by
Seekable::seeker before the subscription’s stream is opened.
The scope is that one subscription instance: other subscribers of the same name are
unaffected. After the bus shuts down, seek reports
MemoryError::ShutDown like any other aliased handle.
§Examples
use ruststream::Seeker;
use ruststream::memory::prelude::*;
use serde::Deserialize;
#[derive(Deserialize)]
struct Job {
id: u64,
poisoned_until: Option<usize>,
}
/// Skips forward past a region the producer marked poisoned.
#[subscriber("jobs")]
async fn work(job: &Job, Ctx(seeker): Ctx<SeekHandle>) -> HandlerOutcome {
if let Some(resume_at) = job.poisoned_until {
if seeker
.seek(MemoryPosition::sequence(resume_at))
.await
.is_err()
{
return HandlerOutcome::retry();
}
}
tracing::info!(job.id, "done");
HandlerOutcome::ack()
}
fn app() -> RustStream {
let broker = MemoryBroker::retaining(Retention::Messages(nonzero!(1024)));
RustStream::new(AppInfo::new("jobs", "0.1.0")).with_broker(broker, |b| {
b.include(work);
})
}Trait Implementations§
Source§impl Clone for MemorySeeker
impl Clone for MemorySeeker
Source§impl Debug for MemorySeeker
impl Debug for MemorySeeker
Source§impl Seeker for MemorySeeker
impl Seeker for MemorySeeker
Source§fn seek(
&self,
to: MemoryPosition,
) -> impl Future<Output = Result<(), MemoryError>>
fn seek( &self, to: MemoryPosition, ) -> impl Future<Output = Result<(), MemoryError>>
Records the reposition and wakes the subscription; the stream applies it at the top of its next poll, so once this resolves the next delivery reflects the new position.
Under a TestApp the reposition counts as in-flight work
until the subscription applies it, so driving the service to a standstill waits for the
replay instead of racing the poll that produces it.
§Errors
Returns MemoryError::ShutDown through a handle aliasing a shut-down bus, and
MemoryError::PositionEvicted for a sequence the retention bound has already dropped.
Source§type Position = MemoryPosition
type Position = MemoryPosition
Kafka partition offsets, a Redis entry id, a byte
offset), constructed by the broker crate or captured from a delivered message via
Positioned::position.Source§type Error = MemoryError
type Error = MemoryError
Auto Trait Implementations§
impl !RefUnwindSafe for MemorySeeker
impl !UnwindSafe for MemorySeeker
impl Freeze for MemorySeeker
impl Send for MemorySeeker
impl Sync for MemorySeeker
impl Unpin for MemorySeeker
impl UnsafeUnpin for MemorySeeker
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<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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request