khenaidoo | ac63710 | 2019-01-14 15:44:34 -0500 | [diff] [blame^] | 1 | package kafka |
| 2 | |
| 3 | /** |
| 4 | * Copyright 2016-2018 Confluent Inc. |
| 5 | * |
| 6 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | * you may not use this file except in compliance with the License. |
| 8 | * You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | * See the License for the specific language governing permissions and |
| 16 | * limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | import ( |
| 20 | "fmt" |
| 21 | ) |
| 22 | |
| 23 | /* |
| 24 | #include <librdkafka/rdkafka.h> |
| 25 | |
| 26 | //Minimum required librdkafka version. This is checked both during |
| 27 | //build-time and runtime. |
| 28 | //Make sure to keep the MIN_RD_KAFKA_VERSION, MIN_VER_ERRSTR and #error |
| 29 | //defines and strings in sync. |
| 30 | // |
| 31 | |
| 32 | #define MIN_RD_KAFKA_VERSION 0x0000b0500 |
| 33 | |
| 34 | #ifdef __APPLE__ |
| 35 | #define MIN_VER_ERRSTR "confluent-kafka-go requires librdkafka v0.11.5 or later. Install the latest version of librdkafka from Homebrew by running `brew install librdkafka` or `brew upgrade librdkafka`" |
| 36 | #else |
| 37 | #define MIN_VER_ERRSTR "confluent-kafka-go requires librdkafka v0.11.5 or later. Install the latest version of librdkafka from the Confluent repositories, see http://docs.confluent.io/current/installation.html" |
| 38 | #endif |
| 39 | |
| 40 | #if RD_KAFKA_VERSION < MIN_RD_KAFKA_VERSION |
| 41 | #ifdef __APPLE__ |
| 42 | #error "confluent-kafka-go requires librdkafka v0.11.5 or later. Install the latest version of librdkafka from Homebrew by running `brew install librdkafka` or `brew upgrade librdkafka`" |
| 43 | #else |
| 44 | #error "confluent-kafka-go requires librdkafka v0.11.5 or later. Install the latest version of librdkafka from the Confluent repositories, see http://docs.confluent.io/current/installation.html" |
| 45 | #endif |
| 46 | #endif |
| 47 | */ |
| 48 | import "C" |
| 49 | |
| 50 | func versionCheck() error { |
| 51 | ver, verstr := LibraryVersion() |
| 52 | if ver < C.MIN_RD_KAFKA_VERSION { |
| 53 | return newErrorFromString(ErrNotImplemented, |
| 54 | fmt.Sprintf("%s: librdkafka version %s (0x%x) detected", |
| 55 | C.MIN_VER_ERRSTR, verstr, ver)) |
| 56 | } |
| 57 | return nil |
| 58 | } |