### Install librdkafka using Vcpkg Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Installs librdkafka using the vcpkg dependency manager. This involves cloning vcpkg, bootstrapping it, integrating it, and then installing the librdkafka package. ```bash $ git clone https://github.com/Microsoft/vcpkg.git ``` ```bash $ cd vcpkg ``` ```bash $ ./bootstrap-vcpkg.sh ``` ```bash $ ./vcpkg integrate install ``` ```bash $ vcpkg install librdkafka ``` -------------------------------- ### Install librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Installs the compiled librdkafka libraries and header files to the system directories, typically requiring superuser privileges. ```Shell sudo make install ``` -------------------------------- ### Configure librdkafka with Dependency Installation Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Runs the configuration script and automatically installs required dependencies using the system's package manager. ```Shell ./configure --install-deps ``` -------------------------------- ### Building librdkafka Project (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Compiles the librdkafka project using the 'make' command based on the current configuration. ```Shell make ``` -------------------------------- ### Install librdkafka using Homebrew (MacOS) Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Installs the librdkafka library on MacOS using the Homebrew package manager. ```bash $ brew install librdkafka ``` -------------------------------- ### Building librdkafka Tests (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Navigates into the 'tests' directory and compiles the librdkafka test suite using the 'make' command with parallel jobs enabled. ```Shell cd tests make -j build ``` -------------------------------- ### Run Packaging Script (PowerShell) Source: https://github.com/confluentinc/librdkafka/blob/master/win32/README.md This script creates a zip package of the librdkafka build artifacts generated by the build.bat script. ```PowerShell package-zip.ps1 ``` -------------------------------- ### Run Build Script (Batch) Source: https://github.com/confluentinc/librdkafka/blob/master/win32/README.md This script builds the librdkafka project for various configurations (Win32, x64, Release, Debug) using the current msbuild toolset. ```Batch build.bat ``` -------------------------------- ### Install librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md Installs the compiled librdkafka library to the system using the cmake install target. ```Shell cmake --build _cmake_build --target install ``` -------------------------------- ### Copy Example Test Configuration Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Copies the example test configuration file (test.conf.example) to create a local test.conf file that can be modified for custom settings. ```Shell cp test.conf.example test.conf ``` -------------------------------- ### Creating librdkafka Release Candidate Tag (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Creates a lightweight Git tag for a release candidate version, following the vA.B.C-RCn naming convention. ```Shell git tag v0.11.1-RC1 ``` -------------------------------- ### Creating librdkafka Final Release Tag (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Creates a lightweight Git tag for the final release version, following the vA.B.C naming convention. ```Shell git tag v0.11.1 ``` -------------------------------- ### Configuring librdkafka Build (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Runs the project's configure script to prepare the build environment, typically after source files or build settings have been modified. ```Shell ./configure ``` -------------------------------- ### Setup CMake Build Environment (Basic) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md Initial command to configure the cmake build environment for librdkafka in a '_cmake_build' directory. ```Shell cmake -H. -B_cmake_build ``` -------------------------------- ### Install librdkafka development package using APT (Debian/Ubuntu) Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Installs the librdkafka development package on Debian or Ubuntu systems using the APT package manager, assuming Confluent repositories are configured. ```bash $ apt install librdkafka-dev ``` -------------------------------- ### C New Block on New Line Style Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Demonstrates the style requirement that the code block following an 'if' or 'else' statement should start on a new line, even if it's a single statement, according to the librdkafka C style guide. ```C if (1) new(); else old(); ``` -------------------------------- ### Install Dependencies (Python) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/tools/stats/README.md Installs the required Python packages listed in the `requirements.txt` file using the pip package manager. ```Shell python3 -m pip install -r requirements.txt ``` -------------------------------- ### Setup CMake Build Environment (MacOSX/Homebrew OpenSSL) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md Configures the cmake build environment, specifically setting the OpenSSL root directory for MacOSX users who installed OpenSSL via Homebrew. ```Shell cmake -H. -B_cmake_build -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ``` -------------------------------- ### Install librdkafka development package using YUM (RHEL/CentOS/Fedora) Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Installs the librdkafka development package on RedHat, CentOS, or Fedora systems using the YUM package manager, assuming Confluent repositories are configured. ```bash $ yum install librdkafka-devel ``` -------------------------------- ### Checking Out librdkafka Release Branch (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Creates and switches to a new local Git branch specifically for the release, following a version format like A.B.C.x or A.B.x. ```Shell git checkout -b 0.11.1.x ``` -------------------------------- ### Start Execution in GDB (GDB) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Starts the execution of the program loaded in GDB. ```GDB (gdb) run ``` -------------------------------- ### Pushing librdkafka Release Tags (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Pushes the created Git tags to the 'origin' remote repository, making them available remotely. ```Shell git push --tags origin v0.11.1-RC1 ``` -------------------------------- ### Start Interactive Git Rebase for Squashing Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Initiate an interactive rebase session against the master branch to squash or fixup commits, cleaning up the commit history before submitting a pull request. ```Shell git rebase -i master ``` -------------------------------- ### Dry-Running Push of Release Tags (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Performs a simulation of pushing the created Git tags to the 'origin' remote repository without actually sending data. ```Shell git push --dry-run --tags origin v0.11.1-RC1 ``` -------------------------------- ### Install Python Test Dependencies Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Installs the required Python packages for running the test suite, including trivup, using pip and the provided requirements.txt file. ```Shell python3 -m pip install -U -r requirements.txt ``` -------------------------------- ### Running Full librdkafka Regression Tests (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Executes the complete librdkafka regression test suite using the 'make full' command. This step requires a Linux environment and the 'trivup' Python package. ```Shell make full ``` -------------------------------- ### Configure Self-Contained Static Build - librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Configures the librdkafka build system using `./configure` with specific flags to download and build static versions of external dependencies, enabling the creation of a self-contained static library (`librdkafka-static.a`) that has no external dependencies other than system libraries. ```Shell ./configure --install-deps --source-deps-only --enable-static ``` -------------------------------- ### Checking Git Differences (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Displays the changes made to the tracked files in the Git repository, useful for reviewing modifications before committing. ```Shell git diff ``` -------------------------------- ### Pushing librdkafka Release Branch (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Pushes the local release branch to the 'origin' remote repository, making it available remotely. ```Shell git push origin 0.11.1.x ``` -------------------------------- ### Example librdkafka Producer Stats JSON Output Source: https://github.com/confluentinc/librdkafka/blob/master/STATISTICS.md A prettified example of the JSON output generated by the librdkafka performance tool when run as a producer. It includes general client information, detailed statistics per broker (state, traffic, latency, RTT, throttle), and topic/partition assignments. ```JSON { "name": "rdkafka#producer-1", "client_id": "rdkafka", "type": "producer", "ts": 5016483227792, "time": 1527060869, "replyq": 0, "msg_cnt": 22710, "msg_size": 704010, "msg_max": 500000, "msg_size_max": 1073741824, "simple_cnt": 0, "metadata_cache_cnt": 1, "brokers": { "localhost:9092/2": { "name": "localhost:9092/2", "nodeid": 2, "nodename": "localhost:9092", "source": "learned", "state": "UP", "stateage": 9057234, "outbuf_cnt": 0, "outbuf_msg_cnt": 0, "waitresp_cnt": 0, "waitresp_msg_cnt": 0, "tx": 320, "txbytes": 84283332, "txerrs": 0, "txretries": 0, "req_timeouts": 0, "rx": 320, "rxbytes": 15708, "rxerrs": 0, "rxcorriderrs": 0, "rxpartial": 0, "zbuf_grow": 0, "buf_grow": 0, "wakeups": 591067, "int_latency": { "min": 86, "max": 59375, "avg": 23726, "sum": 5694616664, "stddev": 13982, "p50": 28031, "p75": 36095, "p90": 39679, "p95": 43263, "p99": 48639, "p99_99": 59391, "outofrange": 0, "hdrsize": 11376, "cnt": 240012 }, "rtt": { "min": 1580, "max": 3389, "avg": 2349, "sum": 79868, "stddev": 474, "p50": 2319, "p75": 2543, "p90": 3183, "p95": 3199, "p99": 3391, "p99_99": 3391, "outofrange": 0, "hdrsize": 13424, "cnt": 34 }, "throttle": { "min": 0, "max": 0, "avg": 0, "sum": 0, "stddev": 0, "p50": 0, "p75": 0, "p90": 0, "p95": 0, "p99": 0, "p99_99": 0, "outofrange": 0, "hdrsize": 17520, "cnt": 34 }, "toppars": { "test-1": { "topic": "test", "partition": 1 } } }, "localhost:9093/3": { "name": "localhost:9093/3", "nodeid": 3, "nodename": "localhost:9093", "source": "learned", "state": "UP", "stateage": 9057209, "outbuf_cnt": 0, "outbuf_msg_cnt": 0, "waitresp_cnt": 0, "waitresp_msg_cnt": 0, "tx": 310, "txbytes": 84301122, "txerrs": 0, "txretries": 0, "req_timeouts": 0, "rx": 310, "rxbytes": 15104, "rxerrs": 0, "rxcorriderrs": 0, "rxpartial": 0, "zbuf_grow": 0, "buf_grow": 0, "wakeups": 607956, "int_latency": { "min": 82, "max": 58069, "avg": 23404, "sum": 5617432101, "stddev": 14021, "p50": 27391, "p75": 35839, "p90": 39679, "p95": 42751, "p99": 48639, "p99_99": 58111, "outofrange": 0, "hdrsize": 11376, "cnt": 240016 }, "rtt": { "min": 1704, "max": 3572, "avg": 2493, "sum": 87289, "stddev": 559, "p50": 2447, "p75": 2895, "p90": 3375, "p95": 3407, "p99": 3583, "p99_99": 3583, "outofrange": 0, "hdrsize": 13424, "cnt": 35 }, "throttle": { "min": 0, "max": 0, "avg": 0, "sum": 0, "stddev": 0, "p50": 0, "p75": 0, "p90": 0, "p95": 0, "p99": 0, "p99_99": 0, "outofrange": 0, "hdrsize": 17520, "cnt": 35 }, "toppars": { "test-0": { "topic": "test", "partition": 0 } } }, "localhost:9094/4": { "name": "localhost:9094/4", "nodeid": 4, "nodename": "localhost:9094", "source": "learned", "state": "UP", "stateage": 9057207, "outbuf_cnt": 0, "outbuf_msg_cnt": 0, "waitresp_cnt": 0, "waitresp_msg_cnt": 0, "tx": 1, "txbytes": 25, "txerrs": 0, "txretries": 0, "req_timeouts": 0, "rx": 1, "rxbytes": 272, "rxerrs": 0, "rxcorriderrs": 0, "rxpartial": 0, "zbuf_grow": 0, "buf_grow": 0, "wakeups": 4, "int_latency": { "min": 0, "max": 0, "avg": 0, "sum": 0, "stddev": 0, "p50": 0, "p75": 0, "p90": 0, "p95": 0, "p99": 0, "p99_99": 0, "outofrange": 0, "hdrsize": 11376, "cnt": 0 }, "rtt": { "min": 0, "max": 0, "avg": 0, "sum": 0, "stddev": 0, "p50": 0, "p75": 0, "p90": 0, "p95": 0, "p99": 0, "p99_99": 0, "outofrange": 0, "hdrsize": 13424, "cnt": 0 }, "throttle": { "min": 0, "max": 0, "avg": 0, "sum": 0, "stddev": 0, "p50": 0, "p75": 0, "p90": 0, "p95": 0, "p99": 0, "p99_99": 0, "outofrange": 0, "hdrsize": 17520, "cnt": 0 } ``` -------------------------------- ### Build and Run librdkafka Fuzzers with OSS-Fuzz Helper Source: https://github.com/confluentinc/librdkafka/blob/master/tests/fuzzers/README.md These commands clone the OSS-Fuzz repository, navigate into it, build the librdkafka Docker image, build the fuzzers within the image, and run a specific fuzzer. Requires Docker installed and may need root access. ```shell git clone https://github.com/google/oss-fuzz cd oss-fuzz python3 infra/helper.py build_image librdkafka python3 infra/helper.py build_fuzzers librdkafka python3 infra/helper.py run_fuzzer librdkafka FUZZ_NAME ``` -------------------------------- ### Run Murmur2 CLI (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/java/README.md Executes the compiled Murmur2 CLI tool via the run-class.sh script. Requires setting KAFKA_JARS and provides example arguments for hashing. ```shell $ KAFKA_JARS=/your/kafka/libs ./run-class.sh Murmur2Cli "a sentence" and a word ``` -------------------------------- ### Dry-Running Push of Release Branch (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Performs a simulation of pushing the local release branch to the 'origin' remote repository without actually sending data, useful for checking permissions and conflicts. ```Shell git push --dry-run origin 0.11.1.x ``` -------------------------------- ### C Bracing and Scope Style Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Illustrates the required bracing style for control flow statements (if, while, else) and shows that single-line scopes should omit braces according to the librdkafka C style guide. ```C int some_func (..) { while (1) { if (1) { do something; .. } else { do something else; .. } } /* Single line scopes should not have braces */ if (1) hi(); else if (2) /* Say hello */ hello(); else bye(); } ``` -------------------------------- ### Editing librdkafka Version Files (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Opens the primary librdkafka C/C++ header files and the vcpkg manifest file in a text editor to manually update the version definitions. ```Shell $EDITOR src/rdkafka.h src-cpp/rdkafkacpp.h vcpkg.json ``` -------------------------------- ### Committing librdkafka Version Changes (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Commits the updated version definitions in the specified header and vcpkg files to the Git repository with a descriptive commit message. ```Shell git commit -m "Version v0.11.1-RC1" src/rdkafka.h src-cpp/rdkafkacpp.h ``` -------------------------------- ### Run librdkafka Tests with GDB (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Starts the librdkafka test runner under the GDB debugger using the `run-test.sh` script. Allows interactive debugging of test execution. ```Shell ./run-test.sh gdb ``` -------------------------------- ### Generate SSL Keys using Makefile (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/fixtures/ssl/README.md Execute the Makefile in the current directory to generate the required PKCS#12 keystore, PEM certificate, and key files for librdkafka SSL testing. This command requires OpenSSL, Java keytool, and GNU Make to be installed and accessible in the system's PATH. ```Shell make ``` -------------------------------- ### Start Kafka Cluster with Trivup Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Uses the trivup Python module to bring up a local Kafka cluster of a specified version (e.g., 2.3.0) and enters an interactive shell. Optional flags like --ssl, --sasl, and --sr can be added for different configurations. ```Shell python3 -m trivup.clusters.KafkaCluster 2.3.0 ``` -------------------------------- ### C Operator Spacing Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Shows the required spacing around assignment (=), comparison (>=), and arithmetic (+=) operators in C code according to the librdkafka style guide. ```C int a = 2; if (b >= 3) c += 2; ``` -------------------------------- ### Running librdkafka Performance Tool Producer Source: https://github.com/confluentinc/librdkafka/blob/master/STATISTICS.md Example shell command used to run the librdkafka performance tool as a producer. It connects to localhost, sends 1000 messages to the 'test' topic, and pipes the generated statistics JSON output to a file named 'stats.json'. ```Shell rdkafka_performance -b localhost -P -t test -T 1000 -Y 'cat >> stats.json' ``` -------------------------------- ### Update Homebrew Recipe (Dry Run) - librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Navigates to the Homebrew packaging directory and runs the update script in dry-run mode to check if the Homebrew formula update for a specific librdkafka version looks correct before performing a live push. ```Shell cd package/homebrew ./brew-update-pr.sh v0.11.1 ``` -------------------------------- ### C Parentheses and Loop Spacing Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Demonstrates the required spacing around parentheses in function declarations, control flow statements (if), and loop constructs (for) as per the librdkafka C style guide. ```C int some_func (int a) { if (1) ....; for (i = 0 ; i < 19 ; i++) { } } ``` -------------------------------- ### Generate GitHub Release Checksums - librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Runs a Python script to download assets from a specified GitHub release tag and generate their checksums. This output is typically added to the release description on GitHub. ```Shell packaging/tools/gh-release-checksums.py ``` -------------------------------- ### Debug librdkafka Core File on OSX (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Starts GDB to debug a core file generated by the librdkafka test runner on OSX. Sets the `DYLD_LIBRARY_PATH` to include necessary librdkafka libraries. ```Shell DYLD_LIBRARY_PATH=../src:../src-cpp gdb ./test-runner /cores/core. ``` -------------------------------- ### Run Test Suite in Trivup Shell Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite from within the interactive shell provided by trivup after a cluster has been started. ```Shell make ``` -------------------------------- ### Update Homebrew Recipe (Live Push) - librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Runs the Homebrew update script with the --upload flag to automatically push a pull request to homebrew-core with the updated librdkafka version. This step is typically skipped as Homebrew often picks up new versions automatically and should only be done for final releases. ```Shell ./brew-update-pr.sh --upload v0.11.1 ``` -------------------------------- ### Generating librdkafka Protocol Types (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/RELEASE.md Uses a shell script to generate protocol request type codes based on a specified Apache Kafka source directory. The generated output needs to be manually integrated into librdkafka header files. ```Shell src/generate_proto.sh ~/src/your-kafka-dir ``` -------------------------------- ### Start Trivup Cluster for librdkafka Tests (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Launches a local Kafka cluster using the `interactive_broker_version.py` script, specifying the desired broker version. This cluster is used by the librdkafka test suite. ```Shell ./interactive_broker_version.py 2.3.0 ``` -------------------------------- ### Example OAUTHBEARER Configuration String Format (Text) Source: https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md Illustrates the format for the `sasl.oauthbearer.config` string when using the default unsecured JWT token handler. It consists of space-separated name=value pairs for standard claims (principalClaimName, principal, scopeClaimName, scope, lifeSeconds) and allows including SASL extensions via `extension_NAME=value`. ```text principalClaimName=azp principal=admin scopeClaimName=roles scope=role1,role2 lifeSeconds=600 ``` ```text principal=admin extension_traceId=123 ``` -------------------------------- ### Getting Background Queue librdkafka C Source: https://github.com/confluentinc/librdkafka/blob/master/CHANGELOG.md This function retrieves the background queue. In v1.9.0, calling this function will now create the background thread if it has not already been created. ```C rd_kafka_queue_get_background() ``` -------------------------------- ### Debug librdkafka Core File on Linux (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Starts GDB to debug a core file generated by the librdkafka test runner on Linux. Sets the `LD_LIBRARY_PATH` to include necessary librdkafka libraries. ```Shell LD_LIBRARY_PATH=../src:../src-cpp gdb ./test-runner ``` -------------------------------- ### C Unary Operator Spacing Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Illustrates that no space is required around unary increment (++) and decrement (--) operators in C code, as specified by the librdkafka style guide. ```C d++; --e; ``` -------------------------------- ### Configure librdkafka Build Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Runs the standard configuration script for building librdkafka. ```Shell ./configure ``` -------------------------------- ### Getting Consumer Close Queue librdkafka C Source: https://github.com/confluentinc/librdkafka/blob/master/CHANGELOG.md This new API allows applications and language bindings to implement asynchronous consumer closing, providing more control over the shutdown process. ```C rd_kafka_consumer_close_queue() ``` -------------------------------- ### librdkafka Log Output with linger.ms=1 (Lower Latency) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md This log output example shows the message batch sizes delivered by librdkafka when the `linger.ms` configuration is set to 1ms. Lower `linger.ms` values result in smaller, more frequent batches, which can reduce latency but may decrease overall throughput due to increased overhead. ```Log ... test [0]: MessageSet with 1514 message(s) delivered ... test [3]: MessageSet with 1690 message(s) delivered ... test [0]: MessageSet with 1720 message(s) delivered ... test [3]: MessageSet with 2 message(s) delivered ... test [3]: MessageSet with 4 message(s) delivered ... test [0]: MessageSet with 4 message(s) delivered ... test [3]: MessageSet with 11 message(s) delivered ``` -------------------------------- ### Configure librdkafka Building Dependencies from Source Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Runs the configuration script and builds required dependencies from source instead of using the system's package manager. ```Shell ./configure --install-deps --source-deps-only ``` -------------------------------- ### librdkafka Log Output with linger.ms=1000 (Higher Throughput) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md This log output example demonstrates the message batch sizes delivered by librdkafka when the `linger.ms` configuration is set to 1000ms. Higher `linger.ms` values allow messages to accumulate longer, resulting in larger, less frequent batches that amortize overhead and increase overall throughput. ```Log ... test [0]: MessageSet with 10000 message(s) delivered ... test [0]: MessageSet with 10000 message(s) delivered ... test [0]: MessageSet with 4667 message(s) delivered ... test [3]: MessageSet with 10000 message(s) delivered ... test [3]: MessageSet with 10000 message(s) delivered ... test [3]: MessageSet with 4476 message(s) delivered ``` -------------------------------- ### Creating librdkafka Producer and Setting Configuration (C) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md This snippet demonstrates how to create a librdkafka producer instance in C. It shows how to initialize a configuration object, set properties like compression codec and batch size using `rd_kafka_conf_set`, and create the producer handle with `rd_kafka_new`, including basic error checking. ```c rd_kafka_conf_t *conf; rd_kafka_conf_res_t res; rd_kafka_t *rk; char errstr[512]; conf = rd_kafka_conf_new(); res = rd_kafka_conf_set(conf, "compression.codec", "snappy", errstr, sizeof(errstr)); if (res != RD_KAFKA_CONF_OK) fail("%s\n", errstr); res = rd_kafka_conf_set(conf, "batch.num.messages", "100", errstr, sizeof(errstr)); if (res != RD_KAFKA_CONF_OK) fail("%s\n", errstr); rk = rd_kafka_new(RD_KAFKA_PRODUCER, conf, errstr, sizeof(errstr)); if (!rk) { rd_kafka_conf_destroy(rk); fail("Failed to create producer: %s\n", errstr); } /* Note: librdkafka takes ownership of the conf object on success */ ``` -------------------------------- ### Build RPM packages with make Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/rpm/README.md Runs the default make target to build RPM packages using mock. ```bash make ``` -------------------------------- ### Building and Uploading NuGet Package (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Run the release script with options to automatically upload the built package to NuGet.org using an API key, including retry logic. ```bash ./release.py --retries 100 --upload your-nuget-api.key v0.11.0-RC3 ``` -------------------------------- ### Build librdkafka Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Compiles the librdkafka library after it has been configured. ```Shell make ``` -------------------------------- ### Building NuGet Package with release.py (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Navigate to the packaging directory and execute the release script with the target tag to assemble and build the NuGet package. ```bash cd packaging/nuget ``` ```bash ./release.py v0.11.0-RC3 ``` -------------------------------- ### Build RPM packages with make and mock options Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/rpm/README.md Runs the make target, passing additional options to the mock command via the MOCK_OPTIONS environment variable. ```bash make MOCK_OPTIONS='--bootstrap-chroot' ``` -------------------------------- ### Tagging and Pushing Release Candidate (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Commands to create a Git tag for a release candidate version and push it to the origin repository, which typically triggers CI builds. ```bash git tag v0.11.0-RC3 ``` ```bash git push origin v0.11.0-RC3 ``` -------------------------------- ### Run a Single librdkafka Fuzzer Reproducer Source: https://github.com/confluentinc/librdkafka/blob/master/tests/fuzzers/README.md These commands build a specific fuzzer test case locally using make and then execute it with a downloaded reproducer file. Note that some test cases may require specific build configurations. ```shell make ./fuzz_regex ~/Downloads/clusterfuzz-testcase-... ``` -------------------------------- ### Building NuGet Package with Specific SHA (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Execute the release script, specifying both the tag and an exact Git SHA to use for artifact collection, useful if the tag was moved. ```bash ./release.py --sha v0.11.0-RC3 ``` -------------------------------- ### Creating Static Library Bundle (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Execute the release script, specifying the 'StaticPackage' class to assemble CI artifacts into a self-contained static library tarball instead of a NuGet package. ```bash ./release.py --class StaticPackage v1.1.0 ``` -------------------------------- ### Configure librdkafka with Static ZStd Linking (MacOSX) Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Configures librdkafka on MacOSX to statically link the ZStd library, using `brew` to find the library path. ```Shell STATIC_LIB_libzstd=$(brew ls -v zstd | grep libzstd.a$) ./configure --enable-static ``` -------------------------------- ### Build RPM packages using mock on Docker Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/rpm/README.md Executes the script to build RPM packages within a Docker container using mock. ```bash packaging/rpm/mock-on-docker.sh ``` -------------------------------- ### Run Local Tests Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md Navigates into the build directory and executes the broker-less librdkafka tests using ctest. ```Shell (cd _cmake_build && ctest -VV -R RdKafkaTestBrokerLess) ``` -------------------------------- ### Configure librdkafka with Static ZStd Linking (Generic) Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Configures librdkafka to statically link the ZStd library for improved consumer performance, specifying the path to the static library file. ```Shell STATIC_LIB_libzstd=/path/to/libzstd.a ./configure --enable-static ``` -------------------------------- ### Configure with LDFLAGS Containing Equals Source: https://github.com/confluentinc/librdkafka/blob/master/CHANGELOG.md Demonstrates how to use the ./configure script with LDFLAGS arguments that contain equals signs, which is now supported. ```Shell ./configure --LDFLAGS='a=b, c=d' ``` -------------------------------- ### Executing Package Verification Script (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cp/README.md This command executes the `verify-packages.sh` script to verify librdkafka packages. It requires the base URL for the packages, the target platform (e.g., linux/amd64), and the expected librdkafka version. Docker is required to run the script. ```bash $ ./verify-packages.sh https://packages.confluent.io linux/amd64 2.8.0 ``` -------------------------------- ### Run Condensed Test Suite (Quick) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes a smaller, quicker subset of the test suite, typically used for continuous integration (CI) builds. ```Shell make quick ``` -------------------------------- ### Build Murmur2 CLI (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/java/README.md Builds the Murmur2 CLI tool using the 'make' command. Requires setting the KAFKA_JARS environment variable to the path containing Kafka libraries. ```shell $ KAFKA_JARS=/your/kafka/libs make ``` -------------------------------- ### Configure Client Software Name (librdkafka) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md Sets the name of the high-level client binding using librdkafka. This helps distinguish different client implementations built on top of librdkafka. ```Configuration client.software.name ``` -------------------------------- ### Test RPM packages on Docker Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/rpm/README.md Executes the script to run tests on the built RPM packages within a Docker container. ```bash packaging/rpm/tests/test-on-docker.sh ``` -------------------------------- ### Configure and Build Development Build (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md This command executes the dev-conf.sh script to configure and build librdkafka and its test suite specifically for development purposes. This enables extra runtime checks, disables optimization, and can enable tools like ASAN for debugging. ```Shell $ ./dev-conf.sh ``` -------------------------------- ### Check C/C++/Python Code Style with Make Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Use this command from the top-level directory to check the code style of changed C/C++ and Python files using clang-format, flake8, and autopep8. ```Shell make style-check-changed ``` -------------------------------- ### Configure Client Software Version (librdkafka) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md Sets the version of the high-level client binding, ideally including the librdkafka version. This aids in tracking client versions and their compatibility with broker versions. ```Configuration client.software.version ``` -------------------------------- ### Fix C/C++/Python Code Style with Make Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Run this command from the top-level directory to automatically fix code style issues in changed C/C++ and Python files using clang-format and autopep8. ```Shell make style-fix-changed ``` -------------------------------- ### Enable ASAN - librdkafka - Shell Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Builds librdkafka and its test suite with AddressSanitizer (ASAN) enabled. ASAN instruments the code to detect memory errors at runtime. Requires a clean build environment. ```Shell ./dev-conf.sh asan ``` -------------------------------- ### Run Resource Usage Tests - librdkafka - Makefile Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite with resource usage monitoring enabled using the `make rusage` target. This runs tests sequentially and checks against defined thresholds for CPU time, memory, and context switches. ```Makefile make rusage ``` -------------------------------- ### Single-Step Instruction in GDB (GDB) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the next single instruction in the program in GDB. ```GDB (gdb) step ``` -------------------------------- ### Build librdkafka (Dynamic) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md Compiles the librdkafka library using the previously configured cmake build directory. ```Shell cmake --build _cmake_build ``` -------------------------------- ### Checking Old Builds in S3 (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Use the cleanup-s3.py script with an AWS profile to list objects in the S3 bucket older than a specified age without deleting them. ```bash AWS_PROFILE=.. ./cleanup-s3.py --age 360 ``` -------------------------------- ### Run Full librdkafka Test Suite (Parallel) (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the entire librdkafka test suite using the standard `make` command. By default, this runs tests in parallel. ```Shell make ``` -------------------------------- ### Run Tests with Valgrind - librdkafka - Shell Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite under Valgrind. Valgrind is a virtual machine that checks for memory access violations, use-after-free, and leaks. Requires a build without ASAN or TSAN and runs only on Linux. ```Shell ./run-test.sh valgrind ``` -------------------------------- ### Run Single librdkafka Test (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Runs a specific librdkafka test identified by its number using the `TESTS` environment variable and the `make` command. ```Shell TESTS=0034 make ``` -------------------------------- ### Run RPM Tests using Docker (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/rpm/tests/README.md Execute the test script located in the packaging directory to run the RPM tests within a Docker container. This script is designed to test the built RPMs on supported CentOS/RHEL environments. ```Shell packaging/rpm/tests/test-on-docker.sh ``` -------------------------------- ### Run librdkafka Tests with Valgrind (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite using the `run-test.sh` script with the `valgrind` mode enabled. This performs memory checking (leaks, corruption, etc.). ```Shell ./run-test.sh valgrind ``` -------------------------------- ### Run All Tests (Parallel) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the full librdkafka test suite using the default make target, which runs tests in parallel for faster execution. ```Shell make ``` -------------------------------- ### Rebase PR Branch on Master Before Pushing Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Instructs contributors to rebase their pull request branch on top of the latest master branch using interactive rebase to ensure a clean history before pushing updates. ```Shell git rebase -i master ``` -------------------------------- ### Run brew-update-pr.sh in Upload Mode (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/homebrew/README.md Executes the brew-update-pr.sh script in live upload mode to push a PR to the homebrew-core repository. Use the --upload flag and specify the librdkafka tag. ```Shell ./brew-update-pr.sh --upload v0.11.0 ``` -------------------------------- ### Configure Argument Precedence Source: https://github.com/confluentinc/librdkafka/blob/master/CHANGELOG.md Notes that arguments provided directly to the ./configure command line now take precedence over cached variables from previous invocations. ```Shell ./configure ``` -------------------------------- ### Show Code at Location in GDB (GDB) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Displays the source code lines around the current execution point in GDB. ```GDB (gdb) list ``` -------------------------------- ### Integrate librdkafka as Static Submodule (CMake) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md CMake script snippet demonstrating how to include librdkafka as a submodule in another project and link against its static library. ```CMake set(RDKAFKA_BUILD_STATIC ON CACHE BOOL "") add_subdirectory(librdkafka) target_link_libraries(your_library_or_executable rdkafka) ``` -------------------------------- ### Configure Kerberos Ticket Refresh Command (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md Defines the shell command executed by librdkafka to refresh or acquire the client's Kerberos ticket. This command runs upon client creation and periodically based on `sasl.kerberos.min.time.before.relogin`. Placeholders like `%{sasl.kerberos.keytab}` and `%{sasl.kerberos.principal}` are replaced with corresponding configuration values. ```shell kinit -R -t "%{sasl.kerberos.keytab}" -k %{sasl.kerberos.principal} || kinit -t "%{sasl.kerberos.keytab}" -k %{sasl.kerberos.principal} ``` -------------------------------- ### Configure librdkafka for Broker >= 0.10.0.0 (Legacy < v1.0.0) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md Configuration settings for librdkafka versions prior to v1.0.0 when connecting to Kafka brokers version 0.10.0.0 or later. It enables API version requests and disables the fallback timer. ```Configuration api.version.request=true api.version.fallback.ms=0 ``` -------------------------------- ### Run Specific Test with Valgrind/Helgrind/GDB Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes a specific test using the run-test.sh script with debugging or analysis tools like Valgrind, Helgrind, or GDB. ```Shell TESTS=0009 ./run-test.sh valgrind|helgrind|gdb ``` -------------------------------- ### Link librdkafka in C/C++ Applications Source: https://github.com/confluentinc/librdkafka/blob/master/README.md Specifies the linker flags required to link librdkafka into C or C++ applications during compilation. ```C -lrdkafka ``` ```C++ -lrdkafka++ ``` -------------------------------- ### Edit Test Configuration File Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Opens the test.conf file in the default editor specified by the $EDITOR environment variable for manual configuration. ```Shell $EDITOR test.conf ``` -------------------------------- ### Run Tests Sequentially Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite one test at a time, which can be helpful for troubleshooting specific test failures. ```Shell make run_seq ``` -------------------------------- ### Run Full librdkafka Test Suite (Sequential) (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the entire librdkafka test suite sequentially, one test at a time. Useful for debugging issues that might be related to parallel execution. ```Shell make run_seq ``` -------------------------------- ### Run Tests with Helgrind - librdkafka - Shell Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite using Helgrind, Valgrind's thread checker. Useful for diagnosing complex threading issues when TSAN output is insufficient. Requires a build without ASAN or TSAN and runs only on Linux. ```Shell ./run-test.sh helgrind ``` -------------------------------- ### Run librdkafka Tests with Helgrind (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes the librdkafka test suite using the `run-test.sh` script with the `helgrind` mode enabled. This performs thread checking (race conditions, deadlocks, etc.). ```Shell ./run-test.sh helgrind ``` -------------------------------- ### Build librdkafka (Static) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/cmake/README.md Compiles the librdkafka library as a static library by setting the RDKAFKA_BUILD_STATIC flag during the build process. ```Shell cmake --build _cmake_build -DRDKAFKA_BUILD_STATIC=1 ``` -------------------------------- ### Show Backtrace After Loading Core File in GDB (GDB) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Displays the backtrace of the thread that crashed after loading a core file into GDB. Helps identify the location of the crash. ```GDB (gdb) bt ``` -------------------------------- ### Show Backtrace After Loading Core File in GDB (GDB) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Displays the backtrace of the thread that crashed after loading a core file into GDB. Helps identify the location of the crash. ```GDB (gdb) bt ``` -------------------------------- ### Configure SQLite Test Results Database Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Adds a configuration line to the test.conf file to enable inserting test results into an SQLite database file named 'rdktests' using the sqlite3 command. ```Configuration test.sql.command=sqlite3 rdktests ``` -------------------------------- ### Use Incremental Assign/Unassign (C/C++) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md With the KIP 848 protocol, these are the only functions allowed within rebalance callbacks (`rebalance_cb`) for incrementally adding or removing partitions from the consumer's assignment. This replaces the strategy-dependent assignment logic of the classic protocol. ```C/C++ rd_kafka_incremental_assign ``` ```C/C++ rd_kafka_incremental_unassign ``` -------------------------------- ### Repeat All librdkafka Tests Until Failure (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Runs the entire librdkafka test suite repeatedly until one test fails. Uses the `until-fail.sh` script in 'bare' mode (without Valgrind). Useful for finding intermittent failures. ```Shell ./until-fail.sh bare ``` -------------------------------- ### Deleting Old Builds from S3 (bash) Source: https://github.com/confluentinc/librdkafka/blob/master/packaging/nuget/README.md Execute the cleanup-s3.py script with an AWS profile and the '--delete' flag to remove objects in the S3 bucket older than a specified age. ```bash AWS_PROFILE=.. ./cleanup-s3.py --age 360 --delete ``` -------------------------------- ### Graph CSV Data (Python) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/tools/stats/README.md Uses the `graph.py` script to generate graphs from a specified CSV file, skipping columns matching certain patterns and grouping the data by partition. ```Shell ./graph.py --skip '*bytes,*msg_cnt,stateage,*msgs,leader' --group-by 1partition test1_toppars.csv ``` -------------------------------- ### Run Specific Test by ID Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Runs a single test identified by its numeric ID (e.g., 0004) by setting the TESTS environment variable before invoking make. ```Shell TESTS=0004 make ``` -------------------------------- ### Force Push Git Branch After Rebase Source: https://github.com/confluentinc/librdkafka/blob/master/CONTRIBUTING.md Use this command to force push your feature branch to the origin remote after performing an interactive rebase that rewrites history. This is common practice for updating pull requests. ```Shell git push --force origin your_feature_branch ``` -------------------------------- ### Repeat Specific librdkafka Test Until Failure (Shell) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Executes a single librdkafka test repeatedly until it fails. Uses the `until-fail.sh` script in 'bare' mode (without Valgrind) and applies specified debug options. ```Shell TESTS=0061 TEST_DEBUG=cgrp,fetch ./until-fail.sh bare ``` -------------------------------- ### Handle UNRELEASED_INSTANCE_ID Error Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md This fatal error occurs in KIP 848 static group membership when a new member attempts to join with a `group.instance.id` that is already in use by an active member. It indicates a conflict that prevents the new member from joining. ```Identifier UNRELEASED_INSTANCE_ID ``` -------------------------------- ### Configure Static Group Instance ID (Configuration) Source: https://github.com/confluentinc/librdkafka/blob/master/INTRODUCTION.md This property is used to configure a static group member. With KIP 848, if two members attempt to use the same `group.instance.id`, the one that joins later will be fenced with the `UNRELEASED_INSTANCE_ID` error. ```Configuration group.instance.id ``` -------------------------------- ### See Backtraces of All Threads in GDB (GDB) Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Displays the backtrace for every thread in the debugged program in GDB. ```GDB (gdb) thread apply all bt ``` -------------------------------- ### Set CPU Calibration - librdkafka - Environment Source: https://github.com/confluentinc/librdkafka/blob/master/tests/README.md Sets the CPU calibration factor for resource usage tests via an environment variable. This value is multiplied by the default CPU thresholds to adjust for differences in system performance compared to the baseline. ```Environment TEST_CPU_CALIBRATION=1.5 ```