Skip to main content

StreamRegistry

Struct StreamRegistry 

Source
pub struct StreamRegistry { /* private fields */ }
Expand description

In-memory registry of durable streams.

Implementations§

Source§

impl StreamRegistry

Source

pub fn new() -> StreamRegistry

Source

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.

Source

pub fn exists(&self, scope: &StreamScope, name: &str) -> bool

Whether (scope, name) is registered.

Source

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.

Source

pub fn describe( &self, scope: &StreamScope, name: &str, ) -> Option<StreamDescriptor>

Describe a single stream, or None if not registered.

Source

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.

Source

pub fn append_authorized( &self, principal_tenant: Option<&str>, target: StreamScope, name: impl Into<String>, key: Option<String>, payload: impl Into<String>, has_cross_tenant_cap: bool, now_ms: u128, ) -> Result<u64, StreamError>

Authorization-gated Self::append.

Source

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.

Source

pub fn read_since_authorized( &self, principal_tenant: Option<&str>, target: StreamScope, name: impl Into<String>, from: u64, limit: usize, has_cross_tenant_cap: bool, ) -> Result<Vec<StreamEvent>, StreamError>

Authorization-gated Self::read_since.

Source

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.

Source

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

Source§

fn clone(&self) -> StreamRegistry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for StreamRegistry

Source§

fn default() -> StreamRegistry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more