pub trait ConsumerRebalanceListener: Send + Sync {
// Required methods
fn on_partitions_revoked<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn on_partitions_assigned<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided method
fn on_partitions_lost<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Callbacks for the partitions that a rebalance takes from or gives to the
consumer. Kafka’s ConsumerRebalanceListener.
The consumer calls them inside Consumer::poll and
Consumer::close, in this order:
- Eager protocol:
on_partitions_revokedwith all owned partitions before theJoinGroup, thenon_partitions_assignedwith the new assignment. - Cooperative protocol: after the
SyncGroup,on_partitions_revokedwith the partitions that left the assignment, only when there are some, thenon_partitions_assignedwith the added partitions, also when there are none. on_partitions_lostin place ofon_partitions_revokedwhen the member lost its generation:UNKNOWN_MEMBER_ID,FENCED_INSTANCE_IDormax_poll_interval.
Each list is sorted by topic and partition. A callback can use the
consumer, for example to commit with Consumer::commit_sync from
on_partitions_revoked. An error from a callback makes that poll return
ConsumerError::RebalanceListenerFailed after the rebalance step.
Required Methods§
Sourcefn on_partitions_revoked<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_partitions_revoked<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Sourcefn on_partitions_assigned<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_partitions_assigned<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Provided Methods§
Sourcefn on_partitions_lost<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_partitions_lost<'life0, 'life1, 'life2, 'async_trait>(
&'life0 mut self,
consumer: &'life1 Consumer,
partitions: &'life2 [(String, i32)],
) -> Pin<Box<dyn Future<Output = Result<(), RebalanceListenerError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Kafka’s onPartitionsLost. The default calls
on_partitions_revoked, as in Kafka.
§Errors
An error that poll returns.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".