pub struct StreamRegistry { /* private fields */ }Expand description
In-memory registry of durable streams.
Implementations§
Source§impl StreamRegistry
impl StreamRegistry
pub fn new() -> StreamRegistry
Sourcepub fn create_stream(
&self,
scope: StreamScope,
name: impl Into<String>,
retention: StreamRetention,
) -> Result<(), StreamError>
pub fn create_stream( &self, scope: StreamScope, name: impl Into<String>, retention: StreamRetention, ) -> Result<(), StreamError>
Declare a new stream. Returns
StreamError::AlreadyExists if (scope, name) is already
registered. The new stream is immediately discoverable via
Self::list_streams.
Sourcepub fn exists(&self, scope: &StreamScope, name: &str) -> bool
pub fn exists(&self, scope: &StreamScope, name: &str) -> bool
Whether (scope, name) is registered.
Sourcepub fn list_streams(&self, scope: &StreamScope) -> Vec<StreamDescriptor>
pub fn list_streams(&self, scope: &StreamScope) -> Vec<StreamDescriptor>
Snapshot every stream in scope. Used by introspection
surfaces (e.g. a future red.streams virtual table). Order
is unspecified; callers that need stable order should sort
on name.
Sourcepub fn describe(
&self,
scope: &StreamScope,
name: &str,
) -> Option<StreamDescriptor>
pub fn describe( &self, scope: &StreamScope, name: &str, ) -> Option<StreamDescriptor>
Describe a single stream, or None if not registered.
Sourcepub fn append(
&self,
scope: StreamScope,
name: impl Into<String>,
key: Option<String>,
payload: impl Into<String>,
now_ms: u128,
) -> Result<u64, StreamError>
pub fn append( &self, scope: StreamScope, name: impl Into<String>, key: Option<String>, payload: impl Into<String>, now_ms: u128, ) -> Result<u64, StreamError>
Append an event. Returns the engine-assigned offset. Retention pruning runs after the append, so the new event is always retained even if it pushes the head past the cap — only older events are dropped.
Authorization-gated Self::append.
Sourcepub fn read_since(
&self,
scope: &StreamScope,
name: &str,
from: u64,
limit: usize,
) -> Result<Vec<StreamEvent>, StreamError>
pub fn read_since( &self, scope: &StreamScope, name: &str, from: u64, limit: usize, ) -> Result<Vec<StreamEvent>, StreamError>
Read up to limit events with offset >= from. Pure read —
does not create pending delivery state, does not advance
any consumer’s saved offset, and does not require ACK/NACK.
If from is below the current head (because retention has
pruned older events), the returned slice simply starts at
the head with no error.
Authorization-gated Self::read_since.
Sourcepub fn save_offset(
&self,
scope: &StreamScope,
name: &str,
consumer: &str,
offset: u64,
) -> Result<u64, StreamError>
pub fn save_offset( &self, scope: &StreamScope, name: &str, consumer: &str, offset: u64, ) -> Result<u64, StreamError>
Persist a consumer’s offset on (scope, name). Monotonic:
if offset is less than or equal to the currently saved
value, the save is a no-op and the existing value is
returned. Otherwise the new value is stored and returned.
This makes the operation safe to retry on duplicate or
stale “I’m done with offset N” notifications — a consumer
can never rewind past events it already finished.
Sourcepub fn get_offset(
&self,
scope: &StreamScope,
name: &str,
consumer: &str,
) -> Result<u64, StreamError>
pub fn get_offset( &self, scope: &StreamScope, name: &str, consumer: &str, ) -> Result<u64, StreamError>
Retrieve a consumer’s saved offset for (scope, name).
Returns 0 for consumers that have never saved — 0 is
the reserved “no progress yet” sentinel since the first
real event is at offset 1.
Trait Implementations§
Source§impl Clone for StreamRegistry
impl Clone for StreamRegistry
Source§fn clone(&self) -> StreamRegistry
fn clone(&self) -> StreamRegistry
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Default for StreamRegistry
impl Default for StreamRegistry
Source§fn default() -> StreamRegistry
fn default() -> StreamRegistry
Auto Trait Implementations§
impl Freeze for StreamRegistry
impl !RefUnwindSafe for StreamRegistry
impl Send for StreamRegistry
impl Sync for StreamRegistry
impl Unpin for StreamRegistry
impl UnsafeUnpin for StreamRegistry
impl !UnwindSafe for StreamRegistry
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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> 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