Skip to content

create watch_prefix_sink() (was: Impl Stream for Subscriber) #1311

@rrichardson

Description

@rrichardson

Use Case: Use Subscriber as if it were a Stream of Events instead of a Future of a single event multiple times.

As the documentation for Future and Stream states:

 The Stream trait is similar to Future but can yield multiple values before completing, similar to the Iterator trait from the standard library:

It seems to me that the Future should actually be a Stream, since Subscriber is intended to return some unbounded stream of Events instead of a single event.

Proposed Change: Implement Stream for Subscriber and possibly remove the Future implementation.

Actually, looking at the impl very little code would actually change. I don't entirely understand the motivation for a channel of oneshot channels, but I'm sure there is a very good reason. ( If I had to make a wild-ass guess, I'd say that the inner one-shots are results of not-yet-completed transactions, and, in some cases, the transaction may be aborted, so it doesn't actually contain data)

Who Benefits From The Change(s)? Me. Also new users who are trying to understand how to subscribe to a stream of events.

Alternative Approaches

Keep the multi-use feature, and document it accordingly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions