Trait sea_streamer::Producer

source ·
pub trait Producer: Clone + Send + Sync {
    type Error: Error;
    type SendFuture: Future<Output = Result<MessageHeader, StreamErr<Self::Error>>>;

    // Required methods
    fn send_to<S>(
        &self,
        stream: &StreamKey,
        payload: S
    ) -> Result<Self::SendFuture, StreamErr<Self::Error>>
       where S: Buffer;
    fn end(
        self
    ) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send;
    fn flush(
        &mut self
    ) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send;
    fn anchor(
        &mut self,
        stream: StreamKey
    ) -> Result<(), StreamErr<Self::Error>>;
    fn anchored(&self) -> Result<&StreamKey, StreamErr<Self::Error>>;

    // Provided method
    fn send<S>(
        &self,
        payload: S
    ) -> Result<Self::SendFuture, StreamErr<Self::Error>>
       where S: Buffer { ... }
}
Expand description

Common interface of producers, to be implemented by all backends.

Required Associated Types§

Required Methods§

source

fn send_to<S>( &self, stream: &StreamKey, payload: S ) -> Result<Self::SendFuture, StreamErr<Self::Error>>
where S: Buffer,

Send a message to a particular stream. This function is non-blocking. You don’t have to await the future if you are not interested in the Receipt.

source

fn end(self) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send

End this producer, only after flushing all it’s pending messages.

source

fn flush( &mut self ) -> impl Future<Output = Result<(), StreamErr<Self::Error>>> + Send

Flush all pending messages.

source

fn anchor(&mut self, stream: StreamKey) -> Result<(), StreamErr<Self::Error>>

Lock this producer to a particular stream. This function can only be called once. Subsequent calls should return StreamErr::AlreadyAnchored error.

source

fn anchored(&self) -> Result<&StreamKey, StreamErr<Self::Error>>

If the producer is already anchored, return a reference to the StreamKey. If the producer is not anchored, this will return StreamErr::NotAnchored error.

Provided Methods§

source

fn send<S>( &self, payload: S ) -> Result<Self::SendFuture, StreamErr<Self::Error>>
where S: Buffer,

Send a message to the already anchored stream. This function is non-blocking. You don’t have to await the future if you are not interested in the Receipt.

If the producer is not anchored, this will return StreamErr::NotAnchored error.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Producer for KafkaProducer

source§

impl Producer for StdioProducer

Implementors§