pub struct Producer { /* private fields */ }Expand description
Publishes an ordered log of binary payloads over a track, one payload per frame in a single group.
Cheaply clonable: clones share one underlying track and publishing state, so multiple owners append into a single ordered log.
Implementations§
Source§impl Producer
impl Producer
Sourcepub fn new(track: Producer, config: Config) -> Self
pub fn new(track: Producer, config: Config) -> Self
Create a producer that publishes to the given track.
Sourcepub fn consume(&self) -> Subscriber
pub fn consume(&self) -> Subscriber
Create a subscriber for the underlying track.
Still hands one back once a failed write has ended the log: the subscriber surfaces the abort on its first read, which is what tells a late reader the log is truncated.
Sourcepub fn is_used(&self) -> bool
pub fn is_used(&self) -> bool
Whether any consumer for the underlying track currently exists.
The demand signal for a producer serving on request: an unused track is cached state nobody is watching, safe to drop and recreate on the next request.
Sourcepub fn append(&mut self, payload: impl Into<Bytes>) -> Result<()>
pub fn append(&mut self, payload: impl Into<Bytes>) -> Result<()>
Append one payload to the log.
A payload that cannot be written ends the track: a log missing a record is not the lossless log this mode promises, so the failure is surfaced rather than papered over with a second group. The group is aborted rather than closed cleanly, so a consumer sees the failure instead of a log that merely looks complete. Every later append fails on the closed track.