pub struct EventStream { /* private fields */ }Expand description
A reader over one session’s event stream, as values rather than as text.
What onevcs events TOKEN writes to stdout, handed back typed and attributed:
every Envelope it yields belongs to the session it was opened for, checked
rather than assumed, so a caller following several publications at once can tell
whose event it is holding. Reading again yields whatever has been appended
since, which is what --follow does with a loop around it.
A consumer that wants some of what a session writes opens it with an
EventFilter instead, and gets the same stream with the events it did not ask
for left out. Filtering belongs to the source rather than to whoever composes
several of them: a monitor and a planner read the same session under different
attention budgets, and neither of them should have to re-implement this.
Implementations§
Source§impl EventStream
impl EventStream
Sourcepub fn open(session: &SessionToken) -> Result<Self>
pub fn open(session: &SessionToken) -> Result<Self>
Open the stream one session writes.
A session that has emitted nothing has no stream, and is refused by name rather than answered with an empty reader that would never say why.
Sourcepub fn open_filtered(
session: &SessionToken,
filter: EventFilter,
) -> Result<Self>
pub fn open_filtered( session: &SessionToken, filter: EventFilter, ) -> Result<Self>
Open the stream one session writes, reading it through a filter.
The filter arrives as a value rather than as text so that a consumer
composing several sources — onepipeline follows sessions through this seam
— passes the one it was configured with straight through, instead of
spelling a spec for each source to parse again.
open is this with EventFilter::default, which
admits everything: an unfiltered stream is the same stream it always was.
A phase this session cannot produce is refused where it is named and
dropped where it is not, which is the difference between a consumer having
asked for something and a consumer having asked for everything.
Sourcepub fn session(&self) -> &SessionToken
pub fn session(&self) -> &SessionToken
The session this stream belongs to.