mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka.git
synced 2025-11-03 03:58:04 +00:00
Added time_point overloads for creating timestamps. (#128)
* Added time_point overloads for creating timestamps. * aliased std::chrono types
This commit is contained in:
committed by
Matias Fontanini
parent
ad9a1e4a49
commit
57268e666c
@@ -24,6 +24,8 @@ using std::condition_variable;
|
||||
using std::chrono::system_clock;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::time_point;
|
||||
using std::chrono::duration_cast;
|
||||
using std::ref;
|
||||
|
||||
using namespace cppkafka;
|
||||
@@ -164,7 +166,7 @@ TEST_CASE("simple production", "[producer]") {
|
||||
SECTION("message with key") {
|
||||
const string payload = "Hello world! 2";
|
||||
const string key = "such key";
|
||||
const milliseconds timestamp{15};
|
||||
auto timestamp = system_clock::now();
|
||||
Producer producer(config);
|
||||
producer.produce(MessageBuilder(KAFKA_TOPICS[0]).partition(partition)
|
||||
.key(key)
|
||||
@@ -181,7 +183,7 @@ TEST_CASE("simple production", "[producer]") {
|
||||
CHECK(message.get_partition() == partition);
|
||||
CHECK(!!message.get_error() == false);
|
||||
REQUIRE(!!message.get_timestamp() == true);
|
||||
CHECK(message.get_timestamp()->get_timestamp() == timestamp);
|
||||
CHECK(message.get_timestamp()->get_timestamp() == duration_cast<milliseconds>(timestamp.time_since_epoch()));
|
||||
}
|
||||
|
||||
#if (RD_KAFKA_VERSION >= RD_KAFKA_HEADERS_SUPPORT_VERSION)
|
||||
|
||||
Reference in New Issue
Block a user