Skip to content

Commit 553582e

Browse files
committed
Runtime checking of librdkafka version
1 parent bbda10c commit 553582e

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

confluent_kafka/src/confluent_kafka.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,14 @@ rd_kafka_conf_t *common_conf_setup (rd_kafka_type_t ktype,
12101210
const void *, size_t, int32_t,
12111211
void *, void *) = partitioner_cb;
12121212

1213+
if (rd_kafka_version() < MIN_RD_KAFKA_VERSION) {
1214+
PyErr_Format(PyExc_RuntimeError,
1215+
"%s: librdkafka version %s (0x%x) detected",
1216+
MIN_VER_ERRSTR, rd_kafka_version_str(),
1217+
rd_kafka_version());
1218+
return NULL;
1219+
}
1220+
12131221
if (!kwargs) {
12141222
/* If no kwargs, fall back on single dict arg, if any. */
12151223
if (!args || !PyTuple_Check(args) || PyTuple_Size(args) < 1 ||

confluent_kafka/src/confluent_kafka.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,30 @@
2020

2121
#include <librdkafka/rdkafka.h>
2222

23-
#if RD_KAFKA_VERSION < 0x0090100
23+
24+
/**
25+
* Minimum required librdkafka version. This is checked both during
26+
* build-time (just below) and runtime (see confluent_kafka.c).
27+
* Make sure to keep the MIN_RD_KAFKA_VERSION, MIN_VER_ERRSTR and #error
28+
* defines and strings in sync.
29+
*/
30+
#define MIN_RD_KAFKA_VERSION 0x00090100
31+
32+
#ifdef __APPLE__
33+
#define MIN_VER_ERRSTR "confluent-kafka-python requires librdkafka v0.9.1 or later. Install the latest version of librdkafka from Homebrew by running `brew install librdkafka` or `brew upgrade librdkafka`"
34+
#else
35+
#define MIN_VER_ERRSTR "confluent-kafka-python requires librdkafka v0.9.1 or later. Install the latest version of librdkafka from the Confluent repositories, see http://docs.confluent.io/current/installation.html"
36+
#endif
37+
38+
#if RD_KAFKA_VERSION < MIN_RD_KAFKA_VERSION
2439
#ifdef __APPLE__
2540
#error "confluent-kafka-python requires librdkafka v0.9.1 or later. Install the latest version of librdkafka from Homebrew by running `brew install librdkafka` or `brew upgrade librdkafka`"
2641
#else
2742
#error "confluent-kafka-python requires librdkafka v0.9.1 or later. Install the latest version of librdkafka from the Confluent repositories, see http://docs.confluent.io/current/installation.html"
2843
#endif
2944
#endif
3045

46+
3147
#if PY_MAJOR_VERSION >= 3
3248
#define PY3
3349
#include <bytesobject.h>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy