Skip to main content

AssignmentControl

Trait AssignmentControl 

Source
pub trait AssignmentControl: Send + Sync {
    // Required methods
    async fn assignment(&self) -> ClientResult<HashSet<MessageQueue>>;
    async fn assign(
        &self,
        message_queues: Vec<MessageQueue>,
    ) -> ClientResult<()>;
    async fn set_sub_expression_for_assign(
        &self,
        topic: &str,
        sub_expression: &str,
    ) -> ClientResult<()>;
    async fn seek(
        &self,
        message_queue: &MessageQueue,
        offset: i64,
    ) -> ClientResult<()>;
    async fn pause(&self, message_queues: Vec<MessageQueue>);
    async fn resume(&self, message_queues: Vec<MessageQueue>);
    async fn seek_to_begin(
        &self,
        message_queue: &MessageQueue,
    ) -> ClientResult<()>;
    async fn seek_to_end(
        &self,
        message_queue: &MessageQueue,
    ) -> ClientResult<()>;
    async fn is_paused(&self, message_queue: &MessageQueue) -> bool;
}

Required Methods§

Source

async fn assignment(&self) -> ClientResult<HashSet<MessageQueue>>

Returns the set of MessageQueues currently assigned to this consumer.

This function does not block the calling thread.

§Errors

Returns an error if the consumer is not in the running state.

Source

async fn assign(&self, message_queues: Vec<MessageQueue>) -> ClientResult<()>

Manually assigns the given MessageQueues to this consumer, bypassing broker rebalance.

Any previously assigned queues not present in message_queues are removed. This function does not block the calling thread.

§Arguments
  • message_queues - The complete set of queues to assign to this consumer.
§Errors

Returns an error if message_queues is empty or the assignment cannot be applied.

Source

async fn set_sub_expression_for_assign( &self, topic: &str, sub_expression: &str, ) -> ClientResult<()>

Sets the subscription filter expression applied when fetching from manually assigned queues.

This function does not block the calling thread.

§Arguments
  • topic - The topic for which the filter expression applies.
  • sub_expression - A tag expression or SQL-92 predicate used to filter messages.
§Errors

Returns an error if the expression is blank, the consumer has already started, or the subscription cannot be switched to manual assignment mode.

Source

async fn seek( &self, message_queue: &MessageQueue, offset: i64, ) -> ClientResult<()>

Seeks the fetch position of the specified MessageQueue to the given offset.

The next poll invocation will return messages starting from offset. This function does not block the calling thread.

§Arguments
  • message_queue - The queue whose fetch position is to be updated.
  • offset - The target offset. Must be within the queue’s valid range.
§Errors

Returns an error if the queue is not currently assigned to this consumer, or if the specified offset is out of the valid range.

Source

async fn pause(&self, message_queues: Vec<MessageQueue>)

Suspends message fetching for the specified MessageQueues.

Paused queues are excluded from subsequent poll results until resume is called. This function does not block the calling thread.

§Arguments
  • message_queues - The queues to pause.
Source

async fn resume(&self, message_queues: Vec<MessageQueue>)

Resumes message fetching for the specified MessageQueues.

This function does not block the calling thread.

§Arguments
  • message_queues - The queues to resume.
Source

async fn seek_to_begin(&self, message_queue: &MessageQueue) -> ClientResult<()>

Seeks the fetch position of the specified MessageQueue to its earliest available offset.

This function does not block the calling thread.

§Arguments
  • message_queue - The queue to seek to the beginning.
§Errors

Returns an error if the queue is not assigned to this consumer or if the earliest offset cannot be retrieved from the broker.

Source

async fn seek_to_end(&self, message_queue: &MessageQueue) -> ClientResult<()>

Seeks the fetch position of the specified MessageQueue to its latest available offset.

The next poll call will return only messages published after this point. This function does not block the calling thread.

§Arguments
  • message_queue - The queue to seek to the end.
§Errors

Returns an error if the queue is not assigned to this consumer or if the latest offset cannot be retrieved from the broker.

Source

async fn is_paused(&self, message_queue: &MessageQueue) -> bool

Checks whether a specific MessageQueue is currently paused.

A paused queue will not be fetched from during poll operations until it is resumed.

This function does not block the calling thread.

§Arguments
  • message_queue - The queue to check.
§Returns

true if the queue is paused, false otherwise.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§