mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-10-31 18:47:48 +00:00
Use erase directly
Added revoke() member function
This commit is contained in:
@@ -102,10 +102,17 @@ public:
|
|||||||
* belonging to the provided partition list and calls reset_state().
|
* belonging to the provided partition list and calls reset_state().
|
||||||
* To be used with static consumers.
|
* To be used with static consumers.
|
||||||
*
|
*
|
||||||
* \param partitions Revoked topic partitions. If the partition list is empty
|
* \param partitions Revoked topic partitions.
|
||||||
* all partitions will be revoked.
|
|
||||||
*/
|
*/
|
||||||
virtual void revoke(const TopicPartitionList& partitions = {});
|
virtual void revoke(const TopicPartitionList& partitions);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Removes all partitions queues associated with the supplied partitions.
|
||||||
|
*
|
||||||
|
* This method contains a default implementation. It removes all the queues
|
||||||
|
* currently assigned and calls reset_state(). To be used with static consumers.
|
||||||
|
*/
|
||||||
|
virtual void revoke();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -99,23 +99,17 @@ void PollStrategyBase::assign(TopicPartitionList& partitions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PollStrategyBase::revoke(const TopicPartitionList& partitions) {
|
void PollStrategyBase::revoke(const TopicPartitionList& partitions) {
|
||||||
if (partitions.empty()) {
|
|
||||||
//revoke everything
|
|
||||||
partition_queues_.clear();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
for (const auto &partition : partitions) {
|
for (const auto &partition : partitions) {
|
||||||
// get the queue associated with this partition
|
partition_queues_.erase(partition);
|
||||||
auto toppar_it = partition_queues_.find(partition);
|
|
||||||
if (toppar_it != partition_queues_.end()) {
|
|
||||||
// remove this queue from the list
|
|
||||||
partition_queues_.erase(toppar_it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
reset_state();
|
reset_state();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PollStrategyBase::revoke() {
|
||||||
|
partition_queues_.clear();
|
||||||
|
reset_state();
|
||||||
|
}
|
||||||
|
|
||||||
void PollStrategyBase::on_assignment(TopicPartitionList& partitions) {
|
void PollStrategyBase::on_assignment(TopicPartitionList& partitions) {
|
||||||
assign(partitions);
|
assign(partitions);
|
||||||
// call original consumer callback if any
|
// call original consumer callback if any
|
||||||
|
|||||||
Reference in New Issue
Block a user