Trait sea_streamer_types::Consumer

source ·
pub trait Consumer: Sized + Send + Sync {
    type Error: Error;
    type Message<'a>: Message
       where Self: 'a;
    type NextFuture<'a>: Future<Output = StreamResult<Self::Message<'a>, Self::Error>>
       where Self: 'a;
    type Stream<'a>: Stream<Item = StreamResult<Self::Message<'a>, Self::Error>>
       where Self: 'a;

    // Required methods
    fn seek(
        &mut self,
        to: Timestamp
    ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send;
    fn rewind(
        &mut self,
        offset: SeqPos
    ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send;
    fn assign(
        &mut self,
        ss: (StreamKey, ShardId)
    ) -> StreamResult<(), Self::Error>;
    fn unassign(
        &mut self,
        ss: (StreamKey, ShardId)
    ) -> StreamResult<(), Self::Error>;
    fn next(&self) -> Self::NextFuture<'_>;
    fn stream<'a, 'b: 'a>(&'b mut self) -> Self::Stream<'a>;
}
Expand description

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

Required Associated Types§

source

type Error: Error

source

type Message<'a>: Message where Self: 'a

source

type NextFuture<'a>: Future<Output = StreamResult<Self::Message<'a>, Self::Error>> where Self: 'a

source

type Stream<'a>: Stream<Item = StreamResult<Self::Message<'a>, Self::Error>> where Self: 'a

Required Methods§

source

fn seek( &mut self, to: Timestamp ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send

Seek all streams to an arbitrary point in time. It will start consuming from the earliest message with a timestamp later than to.

If the consumer is not already assigned, shard ZERO will be used.

source

fn rewind( &mut self, offset: SeqPos ) -> impl Future<Output = StreamResult<(), Self::Error>> + Send

Rewind all streams to a particular sequence number.

If the consumer is not already assigned, shard ZERO will be used.

source

fn assign(&mut self, ss: (StreamKey, ShardId)) -> StreamResult<(), Self::Error>

Assign this consumer to a particular shard. Can be called multiple times to assign to multiple shards. Returns error StreamKeyNotFound if the stream is not currently subscribed.

It will only take effect on the next Consumer::seek or Consumer::rewind.

source

fn unassign( &mut self, ss: (StreamKey, ShardId) ) -> StreamResult<(), Self::Error>

Unassign a shard. Returns error StreamKeyNotFound if the stream is not currently subscribed. Returns error StreamKeyEmpty if all streams have been unassigned.

source

fn next(&self) -> Self::NextFuture<'_>

Poll and receive one message: it awaits until there are new messages. This method can be called from multiple threads.

source

fn stream<'a, 'b: 'a>(&'b mut self) -> Self::Stream<'a>

Returns an async stream. You cannot create multiple streams from the same consumer, nor perform any operation while streaming.

Object Safety§

This trait is not object safe.

Implementors§