Skip to main content

OffsetCommitCallback

Trait OffsetCommitCallback 

Source
pub trait OffsetCommitCallback:
    Send
    + Sync
    + 'static {
    // Required method
    fn on_complete<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        offsets: &'life1 HashMap<TopicPartition, OffsetAndMetadata>,
        error: Option<&'life2 Error>,
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}
Expand description

A callback interface that the user can implement to trigger custom actions when a commit request completes. The callback may be executed in any thread calling poll().

§Translation notes

It runs on the task inside poll(), commit_*() or close().

Required Methods§

Source

fn on_complete<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, offsets: &'life1 HashMap<TopicPartition, OffsetAndMetadata>, error: Option<&'life2 Error>, ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

A callback method the user can implement to provide asynchronous handling of commit request completion. This method will be called when the commit request sent to the server has been acknowledged.

§Arguments
  • offsets - A map of the offsets and associated metadata that this callback applies to
  • error - The error raised during processing of the request, or None if the commit completed successfully
§Errors
  • Error::is_consumer_commit_failed_error if the commit failed and cannot be retried. This can only occur if you are using automatic group management with KafkaConsumer::subscribe, or if there is an active group with the same groupId which is using group management.
  • Error::is_rebalance_in_progress_error if the commit failed because it is in the middle of a rebalance. In such cases commit could be retried after the rebalance is completed with the KafkaConsumer::poll call.
  • Error::is_wakeup_error if KafkaConsumer::wakeup is called before or while this function is called
  • Error::is_interrupt_error if the calling thread is interrupted before or while this function is called
  • Error::is_authorization_error if not authorized to the topic or to the configured groupId. See the error for more details
  • Error::is_kafka_error for any other unrecoverable errors (e.g. if offset metadata is too large or if the committed offset is invalid).
§Translation notes

The errors above are those error may carry. An Err returned here propagates out of the call that ran the callback, as Java’s thrown exception does.

Implementors§