#kafka #rdkafka

sys rdkafka-sys

Native bindings to the librdkafka library

16 releases (2 stable)

✓ Uses Rust 2018 edition

new 1.2.2 Dec 4, 2019
1.0.0 Apr 26, 2019
0.11.6-1 Feb 25, 2019
0.11.6-0 Dec 15, 2018
0.9.2-0 Nov 26, 2016

#3 in #kafka

Download history 2059/week @ 2019-08-21 1752/week @ 2019-08-28 1813/week @ 2019-09-04 2151/week @ 2019-09-11 2160/week @ 2019-09-18 2400/week @ 2019-09-25 2718/week @ 2019-10-02 2587/week @ 2019-10-09 2567/week @ 2019-10-16 1594/week @ 2019-10-23 1440/week @ 2019-10-30 1433/week @ 2019-11-06 1229/week @ 2019-11-13 1244/week @ 2019-11-20 1083/week @ 2019-11-27

8,045 downloads per month
Used in 10 crates (1 directly)

MIT license

4MB
75K SLoC

C 63K SLoC // 0.2% comments C++ 6K SLoC // 0.2% comments Rust 3K SLoC // 0.1% comments Python 1.5K SLoC // 0.2% comments Visual Studio Project 1K SLoC // 0.0% comments Shell 602 SLoC // 0.2% comments Java 215 SLoC // 0.0% comments Visual Studio Solution 196 SLoC RPM Specfile 77 SLoC // 0.1% comments PowerShell 32 SLoC // 0.3% comments Batch 18 SLoC

rdkafka-sys

Low level bindings to librdkafka.

Bindings

To regenerate the bindings:

git submodule update --init
cargo install bindgen
./update-bindings.sh

Version

The rdkafka-sys version number is in the format X.Y.Z-P, where X.Y.Z corresponds to the librdkafka version, and P indicates the version of the rust bindings.

Build

Known issues

  • When any of librdkafka's optional dependencies are enabled, like libz or OpenSSL, if you have multiple versions of that library installed upon your system, librdkafka's build system may disagree with Cargo about which version of the library to use! This can result in subtly broken builds, if librdkafka compiles against the headers for one version but Cargo links against a different version. For complete confidence when building release binaries, use an environment like a Docker container or a chroot jail where you can guarantee that only one version of each dependency is present. Unfortunately, the current design of Cargo makes this nearly impossible to fix.

  • librdkafka's default build system, which uses a bespoke tool called mklove, is somewhat unreliable, as it does not support out-of-tree builds. This means that if you have multiple projects that depend on the same version of librdkafka, they will share a build directory in ~/.cargo/registry, and builds from one project may corrupt builds from the other. Using the CMake based build system is strongly encouraged, if you can take the dependency on CMake.

Features

By default a submodule with the librdkafka sources pinned to a specific commit will be used to compile and statically link the library.

The dynamic-linking feature can be used to link rdkafka to a locally installed version of librdkafka: if the feature is enabled, the build script will use pkg-config to check the version of the library installed in the system, and it will configure the compiler to dynamically link against it.

The cmake-build feature builds librdkafka with its CMake build system, rather than its default mklove-based build system. This feature requires that CMake is installed on the build machine.

The following features directly correspond to librdkafka features (i.e., flags you would pass to configure if you were compiling manually).

  • The ssl feature enables SSL support. By default, the system's OpenSSL library is dynamically linked, but static linking of the version bundled with the openssl-sys crate can be requested with the ssl-vendored feature.
  • The gssapi feature enables SASL GSSAPI support with Cyrus libsasl2. This feature requires that libsasl2 is installed on the system, as there is not yet a libsasl2-sys crate that can build and link against a bundled copy of the library.
  • The libz feature enables support for zlib compression. This feature is enabled by default. By default, the system's libz is dynamically linked, but static linking of the version bundled with the libz-sys crate can be requested with the libz-static feature.
  • The zstd feature enables support for ZSTD compression. By default, this builds and statically links the version bundled with the zstd-sys crate, but dynamic linking of the system's version can be requested with the zstd-pkg-config feature.
  • The external-lz4 feature statically links against the copy of liblz4 bundled with the lz4-sys crate. By default, librdkafka statically links against its own bundled version of liblz4. Due to limitations with lz4-sys, it is not yet possible to dynamically link against the system's version of liblz4.

All features are disabled by default unless noted otherwise above. The build process is defined in build.rs.

Updating

To upgrade change the git submodule in librdkafka, check if new errors need to be added to helpers::primive_to_rd_kafka_resp_err_t and update the version in Cargo.toml.

Dependencies