Allow checking if an Event is valid

This commit is contained in:
Matias Fontanini
2018-10-21 11:36:16 -07:00
parent e73c997a0c
commit c7e1dcb60a
2 changed files with 11 additions and 0 deletions

View File

@@ -143,6 +143,13 @@ public:
* * RD_KAFKA_EVENT_OFFSET_COMMIT * * RD_KAFKA_EVENT_OFFSET_COMMIT
*/ */
TopicPartitionList get_topic_partition_list() const; TopicPartitionList get_topic_partition_list() const;
/**
* Check whether this event is valid
*
* /return true iff this event has a valid (non-null) handle inside
*/
operator bool() const;
private: private:
using HandlePtr = std::unique_ptr<rd_kafka_event_t, decltype(&rd_kafka_event_destroy)>; using HandlePtr = std::unique_ptr<rd_kafka_event_t, decltype(&rd_kafka_event_destroy)>;

View File

@@ -90,4 +90,8 @@ TopicPartitionList Event::get_topic_partition_list() const {
return convert(toppars_handle); return convert(toppars_handle);
} }
Event::operator bool() const {
return !!handle_;
}
} // cppkafka } // cppkafka