Trait hedwig::Publisher

source ·
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§

source

type PublishError

The error type that may be encountered when publishing a message

source

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§

source

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§

source

fn publish_sink(self, validator: M::Validator) -> Self::PublishSink
where Self: Sized, S: Default,

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.

Implementors§

source§

impl<C, M, S, R> Publisher<M, S> for Publisher<C, R>
where C: GrpcService<BoxBody> + Clone + Send + 'static, C::Future: Send + 'static, C::Error: Into<StdError>, C::ResponseBody: Body<Data = Bytes> + Send + 'static, <C::ResponseBody as Body>::Error: Into<StdError> + Send, M: EncodableMessage + Send + 'static, S: Sink<M> + Send + 'static, R: RetryPolicy<[M], PubSubError> + Clone + 'static, R::RetryOp: Send + 'static, <R::RetryOp as RetryOperation<[M], PubSubError>>::Sleep: Send + 'static,

§

type PublishError = PublishError<M, <S as Sink<M>>::Error>

§

type PublishSink = PublishSink<C, M, S, R>

source§

impl<M, S> Publisher<M, S> for MockPublisher
where M: EncodableMessage, M::Error: StdError + 'static, S: Sink<M>, S::Error: StdError + 'static,