Function hedwig::publish::sink::publisher_sink[][src]

pub fn publisher_sink<P>(
    publisher: P,
    batch_size: usize
) -> PublisherSink<P, P::PublishStream> where
    P: Publisher
This is supported on crate features publish and sink only.
Expand description

A sink which ingests validated messages and publishes them to the given publisher.

This sink internally batches elements to publish multiple messages at once. The batch_size argument can be adjusted to control the number of elements stored in these batches. poll_ready will check whether inserting an additional element would exceed this size limit, and trigger a flush before returning Ready if so. Users may call poll_flush to empty this batch at any time.

Unlike some sinks, this sink’s polling functions can be resumed after encountering an error, so long as the underlying publisher’s errors are not terminal. Transient errors, for example, can be ignored and polling can be resumed to continue publishing.

The sink can accept new elements while a flush is in progress, so long as the internal batch has additional capacity – i.e. poll_ready may return Ready while poll_flush returns Pending. Together with the resume-on-error support mentioned above and the data in the FailedMessage error type, this behavior can be used to retry failed messages by re-submitting them to this same sink.