Skip to content

Commit

Permalink
Update librdkafka to version 2 (#675)
Browse files Browse the repository at this point in the history
* Update librdkafka to version 2

* GO FORMAT YOURSELF (clang-format)

---------

Co-authored-by: cow-bot <[email protected]>
  • Loading branch information
amues and cow-bot authored Feb 13, 2023
1 parent 0b5fa2f commit 4a5ad18
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
2 changes: 2 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- Adding _se00_ writer module (see [schema definitions here](https://github.com/ess-dmsc/streaming-data-types)).
- Adding _ev44_ writer module (see [schema definitions here](https://github.com/ess-dmsc/streaming-data-types)).
- Enable idempotence setting in the Kafka producer.
- Updated librdkakfa Conan package version to 2.0.2


## Version 5.2.0: Kafka improvements and other fixes

Expand Down
2 changes: 1 addition & 1 deletion conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ gtest/1.11.0
fmt/8.1.1
h5cpp/0.5.1
zlib/1.2.12
librdkafka/1.9.2
librdkafka/2.0.2
nlohmann_json/3.10.5
streaming-data-types/5b537f9@ess-dmsc/stable
cli11/2.2.0
Expand Down
2 changes: 1 addition & 1 deletion src/tests/ProducerTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FakeTopic : public RdKafka::Topic {
public:
FakeTopic() = default;
~FakeTopic() override = default;
const std::string name() const override { return ""; };
std::string name() const override { return ""; };
bool partition_available(int32_t /*partition*/) const override {
return true;
};
Expand Down
24 changes: 15 additions & 9 deletions src/tests/helpers/RdKafkaMocks.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class MockMetadata : public RdKafka::Metadata {
MAKE_CONST_MOCK0(topics, const RdKafka::Metadata::TopicMetadataVector *(),
override);
MAKE_CONST_MOCK0(orig_broker_id, int32_t(), override);
MAKE_CONST_MOCK0(orig_broker_name, const std::string(), override);
MAKE_CONST_MOCK0(orig_broker_name, std::string(), override);
};

class MockTopicMetadata : public RdKafka::TopicMetadata {
Expand All @@ -29,7 +29,7 @@ class MockTopicMetadata : public RdKafka::TopicMetadata {
public:
explicit MockTopicMetadata(const std::string &TopicName) : Name(TopicName) {}

const std::string topic() const override { return Name; }
std::string topic() const override { return Name; }

MAKE_CONST_MOCK0(partitions, const PartitionMetadataVector *(), override);
MAKE_CONST_MOCK0(err, RdKafka::ErrorCode(), override);
Expand Down Expand Up @@ -67,8 +67,8 @@ class MockKafkaConsumer : public RdKafka::KafkaConsumer {
}

public:
MAKE_CONST_MOCK0(name, const std::string(), override);
MAKE_CONST_MOCK0(memberid, const std::string(), override);
MAKE_CONST_MOCK0(name, std::string(), override);
MAKE_CONST_MOCK0(memberid, std::string(), override);
MAKE_MOCK1(poll, int(int), override);
MAKE_MOCK0(outq_len, int(), override);
MAKE_MOCK1(pause,
Expand All @@ -92,7 +92,7 @@ class MockKafkaConsumer : public RdKafka::KafkaConsumer {
RdKafka::Queue *(const RdKafka::TopicPartition *), override);
MAKE_MOCK1(set_log_queue, RdKafka::ErrorCode(RdKafka::Queue *), override);
MAKE_MOCK0(yield, void(), override);
MAKE_MOCK1(clusterid, const std::string(int), override);
MAKE_MOCK1(clusterid, std::string(int), override);
MAKE_MOCK0(c_ptr, rd_kafka_s *(), override);
MAKE_MOCK1(subscribe, RdKafka::ErrorCode(const std::vector<std::string> &),
override);
Expand Down Expand Up @@ -152,6 +152,9 @@ class MockKafkaConsumer : public RdKafka::KafkaConsumer {
RdKafka::Error *(const std::vector<RdKafka::TopicPartition *> &),
override);
MAKE_MOCK0(sasl_background_callbacks_enable, RdKafka::Error *(), override);
MAKE_MOCK2(sasl_set_credentials,
RdKafka::Error *(const std::string &, const std::string &),
override);
MAKE_MOCK0(get_sasl_queue, RdKafka::Queue *(), override);
MAKE_MOCK0(get_background_queue, RdKafka::Queue *(), override);
MAKE_MOCK1(close, RdKafka::Error *(RdKafka::Queue *), override);
Expand All @@ -167,16 +170,16 @@ class MockKafkaConsumer : public RdKafka::KafkaConsumer {

class MockTopic : public RdKafka::Topic {
public:
MAKE_CONST_MOCK0(name, const std::string(), override);
MAKE_CONST_MOCK0(name, std::string(), override);
MAKE_CONST_MOCK1(partition_available, bool(int32_t), override);
MAKE_MOCK2(offset_store, RdKafka::ErrorCode(int32_t, int64_t), override);
MAKE_MOCK0(c_ptr, rd_kafka_topic_s *(), override);
};

class MockProducer : public trompeloeil::mock_interface<RdKafka::Producer> {
public:
MAKE_CONST_MOCK0(name, const std::string(), override);
MAKE_CONST_MOCK0(memberid, const std::string(), override);
MAKE_CONST_MOCK0(name, std::string(), override);
MAKE_CONST_MOCK0(memberid, std::string(), override);
MAKE_MOCK1(poll, int(int), override);
MAKE_MOCK0(outq_len, int(), override);
MAKE_MOCK4(metadata,
Expand Down Expand Up @@ -204,7 +207,7 @@ class MockProducer : public trompeloeil::mock_interface<RdKafka::Producer> {
RdKafka::Queue *(const RdKafka::TopicPartition *), override);
MAKE_MOCK1(set_log_queue, RdKafka::ErrorCode(RdKafka::Queue *), override);
MAKE_MOCK0(yield, void(), override);
MAKE_MOCK1(clusterid, const std::string(int), override);
MAKE_MOCK1(clusterid, std::string(int), override);
MAKE_MOCK0(c_ptr, rd_kafka_s *(), override);
MAKE_MOCK2(create, RdKafka::Producer *(RdKafka::Conf *, std::string));
MAKE_MOCK7(produce,
Expand Down Expand Up @@ -241,6 +244,9 @@ class MockProducer : public trompeloeil::mock_interface<RdKafka::Producer> {
override);
MAKE_MOCK1(purge, RdKafka::ErrorCode(int), override);
MAKE_MOCK0(sasl_background_callbacks_enable, RdKafka::Error *(), override);
MAKE_MOCK2(sasl_set_credentials,
RdKafka::Error *(const std::string &, const std::string &),
override);
MAKE_MOCK0(get_sasl_queue, RdKafka::Queue *(), override);
MAKE_MOCK0(get_background_queue, RdKafka::Queue *(), override);
IMPLEMENT_MOCK1(init_transactions);
Expand Down

0 comments on commit 4a5ad18

Please sign in to comment.