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: RepoThe underlying repository.
own_stream_name: StringThe 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: StringThe name of the stream that this connection is reading from. The connection will ignore events from other streams.
Implementations§
Source§impl<Repo> EventConnection<Repo>
impl<Repo> EventConnection<Repo>
Sourcepub fn new(
repo: Repo,
target_stream_name: impl AsRef<str>,
own_stream_name: impl AsRef<str>,
) -> Self
pub fn new( repo: Repo, target_stream_name: impl AsRef<str>, own_stream_name: impl AsRef<str>, ) -> Self
Create a new connection.
Sourcepub fn into_stream(self) -> impl Stream<Item = Result<Frame, EventRepoError>>
pub fn into_stream(self) -> impl Stream<Item = Result<Frame, EventRepoError>>
Consume the connection and return an async stream of events.
Sourcepub async fn publish<EventCandidate>(
&self,
event: EventCandidate,
) -> Result<(), EventRepoError>
pub async fn publish<EventCandidate>( &self, event: EventCandidate, ) -> Result<(), EventRepoError>
Publish an event to the target stream.