Struct intrepid_model::EventConnection

source ·
pub struct EventConnection<Repo> {
    pub repo: Repo,
    pub own_stream_name: String,
    pub target_stream_name: String,
}
Expand description

A connection to an event repo. Event connections are meant to represent long running or repeated access to a log of events. They keep track of the last event they read and will only read events that have occurred since that event. This allows them to be used in a streaming context, where they can be run in the background or polled for new events.

Fields§

§repo: Repo

The underlying repository.

§own_stream_name: String

The name of the stream that this connection marks reads in. This is essentially the identity of the connection. Changing this will cause the connection to read from the beginning of the target stream.

§target_stream_name: String

The name of the stream that this connection is reading from. The connection will ignore events from other streams.

Implementations§

source§

impl<Repo> EventConnection<Repo>
where Repo: EventRepo + Send + Sync + 'static,

source

pub fn new( repo: Repo, target_stream_name: impl AsRef<str>, own_stream_name: impl AsRef<str>, ) -> Self

Create a new connection.

source

pub fn into_stream(self) -> impl Stream<Item = Result<Frame, EventRepoError>>

Consume the connection and return an async stream of events.

source

pub async fn publish<EventCandidate>( &self, event: EventCandidate, ) -> Result<(), EventRepoError>
where EventCandidate: IntoEvent + Send,

Publish an event to the target stream.

source

pub async fn process<FrameService>( &self, service: FrameService, ) -> Result<(), EventRepoError>
where FrameService: Service<Frame> + Send,

Process all pending events in the target stream.

Auto Trait Implementations§

§

impl<Repo> Freeze for EventConnection<Repo>
where Repo: Freeze,

§

impl<Repo> RefUnwindSafe for EventConnection<Repo>
where Repo: RefUnwindSafe,

§

impl<Repo> Send for EventConnection<Repo>
where Repo: Send,

§

impl<Repo> Sync for EventConnection<Repo>
where Repo: Sync,

§

impl<Repo> Unpin for EventConnection<Repo>
where Repo: Unpin,

§

impl<Repo> UnwindSafe for EventConnection<Repo>
where Repo: UnwindSafe,

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<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> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.