Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for calling rd_kafka_queue_io_event_enable() from the C++ world #1483

Merged
merged 1 commit into from
Oct 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions src-cpp/QueueImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,8 @@ RdKafka::Message *RdKafka::QueueImpl::consume (int timeout_ms) {
int RdKafka::QueueImpl::poll (int timeout_ms) {
return rd_kafka_queue_poll_callback(queue_, timeout_ms);
}

void RdKafka::QueueImpl::io_event_enable (int fd, const void *payload,
size_t size) {
rd_kafka_queue_io_event_enable(queue_, fd, payload, size);
}
17 changes: 17 additions & 0 deletions src-cpp/rdkafkacpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,23 @@ class RD_EXPORT Queue {
virtual int poll (int timeout_ms) = 0;

virtual ~Queue () = 0;

/**
* @brief Enable IO event triggering for queue.
*
* To ease integration with IO based polling loops this API
* allows an application to create a separate file-descriptor
* that librdkafka will write \p payload (of size \p size) to
* whenever a new element is enqueued on a previously empty queue.
*
* To remove event triggering call with \p fd = -1.
*
* librdkafka will maintain a copy of the \p payload.
*
* @remark When using forwarded queues the IO event must only be enabled
* on the final forwarded-to (destination) queue.
*/
virtual void io_event_enable (int fd, const void *payload, size_t size) = 0;
};

/**@}*/
Expand Down
1 change: 1 addition & 0 deletions src-cpp/rdkafkacpp_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ class QueueImpl : virtual public Queue {
ErrorCode forward (Queue *queue);
Message *consume (int timeout_ms);
int poll (int timeout_ms);
void io_event_enable(int fd, const void *payload, size_t size);

rd_kafka_queue_t *queue_;
};
Expand Down