From a2a46f0ec801f1e6d8cf896d3e72278b149c5ea1 Mon Sep 17 00:00:00 2001 From: suxiaolin Date: Sun, 3 Nov 2019 16:12:57 +0800 Subject: [PATCH 1/6] remove rt lib if mac os --- cmake/FindRdKafka.cmake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmake/FindRdKafka.cmake b/cmake/FindRdKafka.cmake index 9634c93..d577665 100644 --- a/cmake/FindRdKafka.cmake +++ b/cmake/FindRdKafka.cmake @@ -55,7 +55,11 @@ try_compile(RdKafka_FOUND ${CMAKE_CURRENT_BINARY_DIR} if (RdKafka_FOUND) add_library(RdKafka::rdkafka ${RDKAFKA_LIBRARY_TYPE} IMPORTED GLOBAL) - set(RDKAFKA_DEPENDENCIES pthread rt ssl crypto dl z) + if (UNIX AND NOT APPLE) + set(RDKAFKA_DEPENDENCIES pthread rt ssl crypto dl z) + else() + set(RDKAFKA_DEPENDENCIES pthread ssl crypto dl z) + endif() set_target_properties(RdKafka::rdkafka PROPERTIES IMPORTED_NAME RdKafka IMPORTED_LOCATION "${RdKafka_LIBRARY_PATH}" From 544972e48fbc99391d31ea05f3a542e89aef3a09 Mon Sep 17 00:00:00 2001 From: Benjamin Naecker Date: Wed, 28 Apr 2021 14:13:56 -0700 Subject: [PATCH 2/6] Adds support for building on Solaris-based systems --- include/cppkafka/detail/endianness.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cppkafka/detail/endianness.h b/include/cppkafka/detail/endianness.h index 21594c1..0b7d41d 100644 --- a/include/cppkafka/detail/endianness.h +++ b/include/cppkafka/detail/endianness.h @@ -14,7 +14,7 @@ #endif -#if defined(__linux__) || defined(__CYGWIN__) +#if defined(__linux__) || defined(__CYGWIN__) || defined(__sun) # include From dabb2d3aa86b8793cf31241e6a347f4b97894f4b Mon Sep 17 00:00:00 2001 From: Mikhail Filimonov Date: Tue, 1 Jun 2021 23:36:25 +0200 Subject: [PATCH 3/6] Fix for failover issue. When the consumer enters the group and gets no assignment (for ex. there is not enough partitions in the topic), librdkafka waits for the rebalancing sequence to be finished by calling assign with the empty list of partitions (just as was passed by librdkafka to rebalance callback). But cppkafka instead pass nullptr instead of an empty list (which means unassign). And consumer stuck forever in that state, not being able to pick the partition during the next rebalance (failover), because the previous rebalance sequence was not finished. Fixes https://github.com/mfontanini/cppkafka/issues/273 , https://github.com/ClickHouse/ClickHouse/issues/21118 , etc. --- src/consumer.cpp | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/consumer.cpp b/src/consumer.cpp index 5522ca9..38f156a 100644 --- a/src/consumer.cpp +++ b/src/consumer.cpp @@ -124,15 +124,9 @@ void Consumer::unsubscribe() { void Consumer::assign(const TopicPartitionList& topic_partitions) { rd_kafka_resp_err_t error; - if (topic_partitions.empty()) { - error = rd_kafka_assign(get_handle(), nullptr); - check_error(error); - } - else { - TopicPartitionsListPtr topic_list_handle = convert(topic_partitions); - error = rd_kafka_assign(get_handle(), topic_list_handle.get()); - check_error(error, topic_list_handle.get()); - } + TopicPartitionsListPtr topic_list_handle = convert(topic_partitions); + error = rd_kafka_assign(get_handle(), topic_list_handle.get()); + check_error(error, topic_list_handle.get()); } void Consumer::unassign() { From 5a119f689f8a4d90d10a9635e7ee2bee5c127de1 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Wed, 2 Jun 2021 16:41:09 -0700 Subject: [PATCH 4/6] Bump version to 0.4.0 --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3caed5b..c4e44e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,8 +10,8 @@ include(CMakePackageConfigHelpers) # Set the version number. set(CPPKAFKA_VERSION_MAJOR 0) -set(CPPKAFKA_VERSION_MINOR 3) -set(CPPKAFKA_VERSION_REVISION 1) +set(CPPKAFKA_VERSION_MINOR 4) +set(CPPKAFKA_VERSION_REVISION 0) set(CPPKAFKA_VERSION "${CPPKAFKA_VERSION_MAJOR}.${CPPKAFKA_VERSION_MINOR}.${CPPKAFKA_VERSION_REVISION}") set(RDKAFKA_MIN_VERSION "0.9.4") set(RDKAFKA_MIN_VERSION_HEX 0x00090400) From 025d8ed7e1140e765987bd762044a7fe44fdbda0 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 7 Apr 2022 19:37:08 +0200 Subject: [PATCH 5/6] do not try to export template declaration it doesn't make sense to export a template declaration --- include/cppkafka/utils/buffered_producer.h | 2 +- include/cppkafka/utils/compacted_topic_processor.h | 4 ++-- include/cppkafka/utils/consumer_dispatcher.h | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/cppkafka/utils/buffered_producer.h b/include/cppkafka/utils/buffered_producer.h index c5d8b78..18ab312 100644 --- a/include/cppkafka/utils/buffered_producer.h +++ b/include/cppkafka/utils/buffered_producer.h @@ -84,7 +84,7 @@ namespace cppkafka { */ template >> -class CPPKAFKA_API BufferedProducer { +class BufferedProducer { public: enum class FlushMethod { Sync, ///< Empty the buffer and wait for acks from the broker. diff --git a/include/cppkafka/utils/compacted_topic_processor.h b/include/cppkafka/utils/compacted_topic_processor.h index 166dcfe..94bf949 100644 --- a/include/cppkafka/utils/compacted_topic_processor.h +++ b/include/cppkafka/utils/compacted_topic_processor.h @@ -44,7 +44,7 @@ namespace cppkafka { * \brief Events generated by a CompactedTopicProcessor */ template -class CPPKAFKA_API CompactedTopicEvent { +class CompactedTopicEvent { public: /** * \brief Event type enum @@ -111,7 +111,7 @@ private: }; template -class CPPKAFKA_API CompactedTopicProcessor { +class CompactedTopicProcessor { public: /** * The type of events generated by this processor diff --git a/include/cppkafka/utils/consumer_dispatcher.h b/include/cppkafka/utils/consumer_dispatcher.h index 05b1875..33bcc5b 100644 --- a/include/cppkafka/utils/consumer_dispatcher.h +++ b/include/cppkafka/utils/consumer_dispatcher.h @@ -70,7 +70,7 @@ namespace cppkafka { * * EOF: void(BasicConsumerDispatcher::EndOfFile, TopicPartition) */ template -class CPPKAFKA_API BasicConsumerDispatcher { +class BasicConsumerDispatcher { public: /** * Tag to indicate a timeout occurred From fc97759d93b296a486f21a37ab1678e534dc138f Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Thu, 7 Apr 2022 19:44:15 +0200 Subject: [PATCH 6/6] set min C++ standard to C++11 do not hardcode -std=c++11, but let CMake set the minimum required C++ standard of cppkafka if consumer do not force CMAKE_CXX_STANDARD --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4e44e6..bf3e85d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,7 +28,7 @@ if (NOT CMAKE_CXX_FLAGS) add_definitions("-DNOGDI=1") add_definitions("-DNOMINMAX=1") else() - set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") + set(CMAKE_CXX_FLAGS "-Wall") endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5b8649b..ce0bd13 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -36,6 +36,7 @@ set(NAMESPACE "${PROJECT_NAME}::") set(TARGET_EXPORT_NAME ${PROJECT_NAME}Targets) add_library(${TARGET_NAME} ${CPPKAFKA_LIBRARY_TYPE} ${SOURCES}) +target_compile_features(${TARGET_NAME} PUBLIC cxx_std_11) target_include_directories(${TARGET_NAME} PUBLIC $) set_target_properties(${TARGET_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INSTALL_LIBDIR}"