Skip to content

Commit

Permalink
Add support for timestamp in delivery report
Browse files Browse the repository at this point in the history
  • Loading branch information
webmakersteve committed Jun 17, 2018
1 parent 9cd5cab commit e0ff088
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/callbacks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ void DeliveryReportDispatcher::Flush() {
delete persistent;
}

if (event.timestamp > -1) {
Nan::Set(jsobj, Nan::New("timestamp").ToLocalChecked(),
Nan::New<v8::Number>(event.timestamp));
}

if (event.m_include_payload) {
if (event.payload) {
Nan::MaybeLocal<v8::Object> buff = Nan::NewBuffer(
Expand Down Expand Up @@ -359,6 +364,14 @@ DeliveryReport::DeliveryReport(RdKafka::Message &message, bool include_payload)
partition = message.partition();
offset = message.offset();

if (message.timestamp().type !=
RdKafka::MessageTimestamp::MSG_TIMESTAMP_NOT_AVAILABLE) {
timestamp = message.timestamp().timestamp;
} else {
timestamp = -1;
}


// Key length.
key_len = message.key_len();

Expand Down
1 change: 1 addition & 0 deletions src/callbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class DeliveryReport {
std::string topic_name;
int32_t partition;
int64_t offset;
int64_t timestamp;

// Opaque token used. Local value
void* opaque;
Expand Down

0 comments on commit e0ff088

Please sign in to comment.