pub trait Publisher<M: EncodableMessage, S: Sink<M> = Drain<M>> {
type PublishError;
type PublishSink: Sink<M, Error = Self::PublishError>;
// Required method
fn publish_sink_with_responses(
self,
validator: M::Validator,
response_sink: S
) -> Self::PublishSink;
// Provided method
fn publish_sink(self, validator: M::Validator) -> Self::PublishSink
where Self: Sized,
S: Default { ... }
}
Expand description
Message publishers.
Message publishers validate, encode, and deliver messages to an endpoint, possibly a remote one. Message publishers may also additionally validate a message for publisher-specific requirements (e.g. size).
Required Associated Types§
sourcetype PublishError
type PublishError
The error type that may be encountered when publishing a message
sourcetype PublishSink: Sink<M, Error = Self::PublishError>
type PublishSink: Sink<M, Error = Self::PublishError>
The Sink
type provided by the publisher to accept messages,
validate them, then publish them to the destination.
Required Methods§
sourcefn publish_sink_with_responses(
self,
validator: M::Validator,
response_sink: S
) -> Self::PublishSink
fn publish_sink_with_responses( self, validator: M::Validator, response_sink: S ) -> Self::PublishSink
Create a new sink to accept messages.
This creates a sink like publish_sink
while additionally
listening for successful responses; after a message has been successfully published, it
will be passed to the given response sink to complete any necessary work (e.g.
acknowledging success or collecting metrics)
Provided Methods§
sourcefn publish_sink(self, validator: M::Validator) -> Self::PublishSink
fn publish_sink(self, validator: M::Validator) -> Self::PublishSink
Create a new sink to accept messages.
The sink will use the given validator to validate and/or encode messages, possibly batch
them together, then publish them to their destination. The details of the internal encoding
and batching may vary by Publisher
implementation.