@platformatic/rdkafka 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +5 -0
- package/.jshintignore +1 -0
- package/.jshintrc +23 -0
- package/CONTRIBUTING.md +237 -0
- package/LICENSE.txt +21 -0
- package/Makefile +94 -0
- package/README.md +630 -0
- package/bench/consumer-raw-rdkafka.js +76 -0
- package/bench/consumer-subscribe.js +77 -0
- package/bench/kafka-consumer-stream.js +100 -0
- package/bench/producer-raw-rdkafka.js +125 -0
- package/bench/producer-rdkafka.js +117 -0
- package/bench/seed.sh +38 -0
- package/binding.gyp +155 -0
- package/ci/checks/librdkafka-correct-version.js +67 -0
- package/ci/checks/librdkafka-exists.js +13 -0
- package/ci/librdkafka-defs-generator.js +193 -0
- package/ci/prepublish.js +3 -0
- package/config.d.ts +1132 -0
- package/configure +15 -0
- package/cpplint.py +6325 -0
- package/deploy.enc +0 -0
- package/deps/librdkafka/.clang-format +136 -0
- package/deps/librdkafka/.clang-format-cpp +103 -0
- package/deps/librdkafka/.dir-locals.el +10 -0
- package/deps/librdkafka/.formatignore +33 -0
- package/deps/librdkafka/.gdbmacros +19 -0
- package/deps/librdkafka/.semaphore/project.yml +43 -0
- package/deps/librdkafka/.semaphore/project_public.yml +20 -0
- package/deps/librdkafka/.semaphore/semaphore.yml +355 -0
- package/deps/librdkafka/CHANGELOG.md +1738 -0
- package/deps/librdkafka/CMakeLists.txt +291 -0
- package/deps/librdkafka/CODE_OF_CONDUCT.md +46 -0
- package/deps/librdkafka/CONFIGURATION.md +189 -0
- package/deps/librdkafka/CONTRIBUTING.md +431 -0
- package/deps/librdkafka/Doxyfile +2375 -0
- package/deps/librdkafka/INTRODUCTION.md +2173 -0
- package/deps/librdkafka/LICENSE +26 -0
- package/deps/librdkafka/LICENSE.cjson +22 -0
- package/deps/librdkafka/LICENSE.crc32c +28 -0
- package/deps/librdkafka/LICENSE.fnv1a +18 -0
- package/deps/librdkafka/LICENSE.hdrhistogram +27 -0
- package/deps/librdkafka/LICENSE.lz4 +26 -0
- package/deps/librdkafka/LICENSE.murmur2 +25 -0
- package/deps/librdkafka/LICENSE.nanopb +22 -0
- package/deps/librdkafka/LICENSE.opentelemetry +203 -0
- package/deps/librdkafka/LICENSE.pycrc +23 -0
- package/deps/librdkafka/LICENSE.queue +31 -0
- package/deps/librdkafka/LICENSE.regexp +5 -0
- package/deps/librdkafka/LICENSE.snappy +36 -0
- package/deps/librdkafka/LICENSE.tinycthread +26 -0
- package/deps/librdkafka/LICENSE.wingetopt +49 -0
- package/deps/librdkafka/LICENSES.txt +625 -0
- package/deps/librdkafka/Makefile +124 -0
- package/deps/librdkafka/README.md +199 -0
- package/deps/librdkafka/README.win32 +26 -0
- package/deps/librdkafka/STATISTICS.md +624 -0
- package/deps/librdkafka/configure +214 -0
- package/deps/librdkafka/configure.self +331 -0
- package/deps/librdkafka/debian/changelog +111 -0
- package/deps/librdkafka/debian/compat +1 -0
- package/deps/librdkafka/debian/control +71 -0
- package/deps/librdkafka/debian/copyright +99 -0
- package/deps/librdkafka/debian/gbp.conf +9 -0
- package/deps/librdkafka/debian/librdkafka++1.install +1 -0
- package/deps/librdkafka/debian/librdkafka-dev.examples +2 -0
- package/deps/librdkafka/debian/librdkafka-dev.install +9 -0
- package/deps/librdkafka/debian/librdkafka1.docs +5 -0
- package/deps/librdkafka/debian/librdkafka1.install +1 -0
- package/deps/librdkafka/debian/librdkafka1.symbols +135 -0
- package/deps/librdkafka/debian/rules +19 -0
- package/deps/librdkafka/debian/source/format +1 -0
- package/deps/librdkafka/debian/watch +2 -0
- package/deps/librdkafka/dev-conf.sh +123 -0
- package/deps/librdkafka/examples/CMakeLists.txt +79 -0
- package/deps/librdkafka/examples/Makefile +167 -0
- package/deps/librdkafka/examples/README.md +42 -0
- package/deps/librdkafka/examples/alter_consumer_group_offsets.c +338 -0
- package/deps/librdkafka/examples/consumer.c +261 -0
- package/deps/librdkafka/examples/delete_records.c +233 -0
- package/deps/librdkafka/examples/describe_cluster.c +322 -0
- package/deps/librdkafka/examples/describe_consumer_groups.c +436 -0
- package/deps/librdkafka/examples/describe_topics.c +427 -0
- package/deps/librdkafka/examples/elect_leaders.c +317 -0
- package/deps/librdkafka/examples/globals.json +11 -0
- package/deps/librdkafka/examples/idempotent_producer.c +344 -0
- package/deps/librdkafka/examples/incremental_alter_configs.c +348 -0
- package/deps/librdkafka/examples/kafkatest_verifiable_client.cpp +961 -0
- package/deps/librdkafka/examples/list_consumer_group_offsets.c +359 -0
- package/deps/librdkafka/examples/list_consumer_groups.c +365 -0
- package/deps/librdkafka/examples/list_offsets.c +327 -0
- package/deps/librdkafka/examples/misc.c +287 -0
- package/deps/librdkafka/examples/openssl_engine_example.cpp +249 -0
- package/deps/librdkafka/examples/producer.c +251 -0
- package/deps/librdkafka/examples/producer.cpp +228 -0
- package/deps/librdkafka/examples/rdkafka_complex_consumer_example.c +617 -0
- package/deps/librdkafka/examples/rdkafka_complex_consumer_example.cpp +467 -0
- package/deps/librdkafka/examples/rdkafka_consume_batch.cpp +264 -0
- package/deps/librdkafka/examples/rdkafka_example.c +853 -0
- package/deps/librdkafka/examples/rdkafka_example.cpp +679 -0
- package/deps/librdkafka/examples/rdkafka_performance.c +1781 -0
- package/deps/librdkafka/examples/transactions-older-broker.c +668 -0
- package/deps/librdkafka/examples/transactions.c +665 -0
- package/deps/librdkafka/examples/user_scram.c +492 -0
- package/deps/librdkafka/examples/win_ssl_cert_store.cpp +395 -0
- package/deps/librdkafka/lds-gen.py +73 -0
- package/deps/librdkafka/mainpage.doxy +40 -0
- package/deps/librdkafka/mklove/Makefile.base +329 -0
- package/deps/librdkafka/mklove/modules/configure.atomics +144 -0
- package/deps/librdkafka/mklove/modules/configure.base +2484 -0
- package/deps/librdkafka/mklove/modules/configure.builtin +70 -0
- package/deps/librdkafka/mklove/modules/configure.cc +186 -0
- package/deps/librdkafka/mklove/modules/configure.cxx +8 -0
- package/deps/librdkafka/mklove/modules/configure.fileversion +65 -0
- package/deps/librdkafka/mklove/modules/configure.gitversion +29 -0
- package/deps/librdkafka/mklove/modules/configure.good_cflags +18 -0
- package/deps/librdkafka/mklove/modules/configure.host +132 -0
- package/deps/librdkafka/mklove/modules/configure.lib +49 -0
- package/deps/librdkafka/mklove/modules/configure.libcurl +99 -0
- package/deps/librdkafka/mklove/modules/configure.libsasl2 +36 -0
- package/deps/librdkafka/mklove/modules/configure.libssl +147 -0
- package/deps/librdkafka/mklove/modules/configure.libzstd +58 -0
- package/deps/librdkafka/mklove/modules/configure.parseversion +95 -0
- package/deps/librdkafka/mklove/modules/configure.pic +16 -0
- package/deps/librdkafka/mklove/modules/configure.socket +20 -0
- package/deps/librdkafka/mklove/modules/configure.zlib +61 -0
- package/deps/librdkafka/mklove/modules/patches/README.md +8 -0
- package/deps/librdkafka/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch +11 -0
- package/deps/librdkafka/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch +56 -0
- package/deps/librdkafka/packaging/RELEASE.md +311 -0
- package/deps/librdkafka/packaging/alpine/build-alpine.sh +38 -0
- package/deps/librdkafka/packaging/archlinux/PKGBUILD +30 -0
- package/deps/librdkafka/packaging/cmake/Config.cmake.in +37 -0
- package/deps/librdkafka/packaging/cmake/Modules/FindLZ4.cmake +38 -0
- package/deps/librdkafka/packaging/cmake/Modules/FindZSTD.cmake +27 -0
- package/deps/librdkafka/packaging/cmake/Modules/LICENSE.FindZstd +178 -0
- package/deps/librdkafka/packaging/cmake/README.md +38 -0
- package/deps/librdkafka/packaging/cmake/config.h.in +52 -0
- package/deps/librdkafka/packaging/cmake/parseversion.cmake +60 -0
- package/deps/librdkafka/packaging/cmake/rdkafka.pc.in +12 -0
- package/deps/librdkafka/packaging/cmake/try_compile/atomic_32_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/atomic_64_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/c11threads_test.c +14 -0
- package/deps/librdkafka/packaging/cmake/try_compile/crc32c_hw_test.c +27 -0
- package/deps/librdkafka/packaging/cmake/try_compile/dlopen_test.c +11 -0
- package/deps/librdkafka/packaging/cmake/try_compile/libsasl2_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_darwin_test.c +6 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_freebsd_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_gnu_test.c +5 -0
- package/deps/librdkafka/packaging/cmake/try_compile/rand_r_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/rdkafka_setup.cmake +122 -0
- package/deps/librdkafka/packaging/cmake/try_compile/regex_test.c +10 -0
- package/deps/librdkafka/packaging/cmake/try_compile/strndup_test.c +5 -0
- package/deps/librdkafka/packaging/cmake/try_compile/sync_32_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/sync_64_test.c +8 -0
- package/deps/librdkafka/packaging/cp/README.md +13 -0
- package/deps/librdkafka/packaging/cp/check_features.c +64 -0
- package/deps/librdkafka/packaging/cp/verify-deb.sh +33 -0
- package/deps/librdkafka/packaging/cp/verify-packages.sh +48 -0
- package/deps/librdkafka/packaging/cp/verify-rpm.sh +39 -0
- package/deps/librdkafka/packaging/debian/changelog +66 -0
- package/deps/librdkafka/packaging/debian/compat +1 -0
- package/deps/librdkafka/packaging/debian/control +49 -0
- package/deps/librdkafka/packaging/debian/copyright +84 -0
- package/deps/librdkafka/packaging/debian/gbp.conf +9 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.dirs +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.examples +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.install +6 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.substvars +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka.dsc +16 -0
- package/deps/librdkafka/packaging/debian/librdkafka1-dbg.substvars +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.dirs +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.install +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.postinst.debhelper +5 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.postrm.debhelper +5 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.symbols +64 -0
- package/deps/librdkafka/packaging/debian/rules +19 -0
- package/deps/librdkafka/packaging/debian/source/format +1 -0
- package/deps/librdkafka/packaging/debian/watch +2 -0
- package/deps/librdkafka/packaging/get_version.py +21 -0
- package/deps/librdkafka/packaging/homebrew/README.md +15 -0
- package/deps/librdkafka/packaging/homebrew/brew-update-pr.sh +31 -0
- package/deps/librdkafka/packaging/mingw-w64/configure-build-msys2-mingw-static.sh +52 -0
- package/deps/librdkafka/packaging/mingw-w64/configure-build-msys2-mingw.sh +21 -0
- package/deps/librdkafka/packaging/mingw-w64/run-tests.sh +6 -0
- package/deps/librdkafka/packaging/mingw-w64/semaphoreci-build.sh +38 -0
- package/deps/librdkafka/packaging/mingw-w64/travis-before-install.sh +20 -0
- package/deps/librdkafka/packaging/nuget/README.md +84 -0
- package/deps/librdkafka/packaging/nuget/artifact.py +177 -0
- package/deps/librdkafka/packaging/nuget/cleanup-s3.py +143 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-win32__bldtype-Release/msvcr120.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-win32__bldtype-Release/msvcr140.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-x64__bldtype-Release/msvcr120.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-x64__bldtype-Release/msvcr140.zip +0 -0
- package/deps/librdkafka/packaging/nuget/nuget.sh +21 -0
- package/deps/librdkafka/packaging/nuget/nugetpackage.py +278 -0
- package/deps/librdkafka/packaging/nuget/packaging.py +448 -0
- package/deps/librdkafka/packaging/nuget/push-to-nuget.sh +21 -0
- package/deps/librdkafka/packaging/nuget/release.py +167 -0
- package/deps/librdkafka/packaging/nuget/requirements.txt +3 -0
- package/deps/librdkafka/packaging/nuget/staticpackage.py +178 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.nuspec +21 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.props +18 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.targets +19 -0
- package/deps/librdkafka/packaging/nuget/zfile/__init__.py +0 -0
- package/deps/librdkafka/packaging/nuget/zfile/zfile.py +98 -0
- package/deps/librdkafka/packaging/rpm/Makefile +92 -0
- package/deps/librdkafka/packaging/rpm/README.md +23 -0
- package/deps/librdkafka/packaging/rpm/el7-x86_64.cfg +40 -0
- package/deps/librdkafka/packaging/rpm/librdkafka.spec +118 -0
- package/deps/librdkafka/packaging/rpm/mock-on-docker.sh +96 -0
- package/deps/librdkafka/packaging/rpm/tests/Makefile +25 -0
- package/deps/librdkafka/packaging/rpm/tests/README.md +8 -0
- package/deps/librdkafka/packaging/rpm/tests/run-test.sh +42 -0
- package/deps/librdkafka/packaging/rpm/tests/test-on-docker.sh +56 -0
- package/deps/librdkafka/packaging/rpm/tests/test.c +77 -0
- package/deps/librdkafka/packaging/rpm/tests/test.cpp +34 -0
- package/deps/librdkafka/packaging/tools/build-configurations-checks.sh +10 -0
- package/deps/librdkafka/packaging/tools/build-deb-package.sh +64 -0
- package/deps/librdkafka/packaging/tools/build-debian.sh +65 -0
- package/deps/librdkafka/packaging/tools/build-manylinux.sh +68 -0
- package/deps/librdkafka/packaging/tools/build-release-artifacts.sh +139 -0
- package/deps/librdkafka/packaging/tools/distro-build.sh +38 -0
- package/deps/librdkafka/packaging/tools/gh-release-checksums.py +39 -0
- package/deps/librdkafka/packaging/tools/rdutcoverage.sh +25 -0
- package/deps/librdkafka/packaging/tools/requirements.txt +2 -0
- package/deps/librdkafka/packaging/tools/style-format.sh +148 -0
- package/deps/librdkafka/service.yml +18 -0
- package/deps/librdkafka/src/CMakeLists.txt +374 -0
- package/deps/librdkafka/src/Makefile +103 -0
- package/deps/librdkafka/src/README.lz4.md +30 -0
- package/deps/librdkafka/src/cJSON.c +2834 -0
- package/deps/librdkafka/src/cJSON.h +398 -0
- package/deps/librdkafka/src/crc32c.c +430 -0
- package/deps/librdkafka/src/crc32c.h +38 -0
- package/deps/librdkafka/src/generate_proto.sh +66 -0
- package/deps/librdkafka/src/librdkafka_cgrp_synch.png +0 -0
- package/deps/librdkafka/src/lz4.c +2727 -0
- package/deps/librdkafka/src/lz4.h +842 -0
- package/deps/librdkafka/src/lz4frame.c +2078 -0
- package/deps/librdkafka/src/lz4frame.h +692 -0
- package/deps/librdkafka/src/lz4frame_static.h +47 -0
- package/deps/librdkafka/src/lz4hc.c +1631 -0
- package/deps/librdkafka/src/lz4hc.h +413 -0
- package/deps/librdkafka/src/nanopb/pb.h +917 -0
- package/deps/librdkafka/src/nanopb/pb_common.c +388 -0
- package/deps/librdkafka/src/nanopb/pb_common.h +49 -0
- package/deps/librdkafka/src/nanopb/pb_decode.c +1727 -0
- package/deps/librdkafka/src/nanopb/pb_decode.h +193 -0
- package/deps/librdkafka/src/nanopb/pb_encode.c +1000 -0
- package/deps/librdkafka/src/nanopb/pb_encode.h +185 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.c +32 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.h +170 -0
- package/deps/librdkafka/src/opentelemetry/metrics.options +2 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.c +67 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.h +966 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.c +12 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.h +58 -0
- package/deps/librdkafka/src/queue.h +850 -0
- package/deps/librdkafka/src/rd.h +441 -0
- package/deps/librdkafka/src/rdaddr.c +255 -0
- package/deps/librdkafka/src/rdaddr.h +203 -0
- package/deps/librdkafka/src/rdatomic.h +226 -0
- package/deps/librdkafka/src/rdavg.h +259 -0
- package/deps/librdkafka/src/rdavl.c +210 -0
- package/deps/librdkafka/src/rdavl.h +250 -0
- package/deps/librdkafka/src/rdbase64.c +169 -0
- package/deps/librdkafka/src/rdbase64.h +41 -0
- package/deps/librdkafka/src/rdbuf.c +1884 -0
- package/deps/librdkafka/src/rdbuf.h +375 -0
- package/deps/librdkafka/src/rdcrc32.c +114 -0
- package/deps/librdkafka/src/rdcrc32.h +170 -0
- package/deps/librdkafka/src/rddl.c +179 -0
- package/deps/librdkafka/src/rddl.h +43 -0
- package/deps/librdkafka/src/rdendian.h +174 -0
- package/deps/librdkafka/src/rdfloat.h +67 -0
- package/deps/librdkafka/src/rdfnv1a.c +113 -0
- package/deps/librdkafka/src/rdfnv1a.h +35 -0
- package/deps/librdkafka/src/rdgz.c +120 -0
- package/deps/librdkafka/src/rdgz.h +46 -0
- package/deps/librdkafka/src/rdhdrhistogram.c +721 -0
- package/deps/librdkafka/src/rdhdrhistogram.h +87 -0
- package/deps/librdkafka/src/rdhttp.c +512 -0
- package/deps/librdkafka/src/rdhttp.h +83 -0
- package/deps/librdkafka/src/rdinterval.h +177 -0
- package/deps/librdkafka/src/rdkafka.c +5351 -0
- package/deps/librdkafka/src/rdkafka.h +10603 -0
- package/deps/librdkafka/src/rdkafka_admin.c +9417 -0
- package/deps/librdkafka/src/rdkafka_admin.h +619 -0
- package/deps/librdkafka/src/rdkafka_assignment.c +1010 -0
- package/deps/librdkafka/src/rdkafka_assignment.h +73 -0
- package/deps/librdkafka/src/rdkafka_assignor.c +1786 -0
- package/deps/librdkafka/src/rdkafka_assignor.h +402 -0
- package/deps/librdkafka/src/rdkafka_aux.c +409 -0
- package/deps/librdkafka/src/rdkafka_aux.h +174 -0
- package/deps/librdkafka/src/rdkafka_background.c +221 -0
- package/deps/librdkafka/src/rdkafka_broker.c +6186 -0
- package/deps/librdkafka/src/rdkafka_broker.h +686 -0
- package/deps/librdkafka/src/rdkafka_buf.c +540 -0
- package/deps/librdkafka/src/rdkafka_buf.h +1524 -0
- package/deps/librdkafka/src/rdkafka_cert.c +552 -0
- package/deps/librdkafka/src/rdkafka_cert.h +61 -0
- package/deps/librdkafka/src/rdkafka_cgrp.c +7262 -0
- package/deps/librdkafka/src/rdkafka_cgrp.h +443 -0
- package/deps/librdkafka/src/rdkafka_conf.c +4456 -0
- package/deps/librdkafka/src/rdkafka_conf.h +668 -0
- package/deps/librdkafka/src/rdkafka_confval.h +97 -0
- package/deps/librdkafka/src/rdkafka_coord.c +623 -0
- package/deps/librdkafka/src/rdkafka_coord.h +132 -0
- package/deps/librdkafka/src/rdkafka_error.c +228 -0
- package/deps/librdkafka/src/rdkafka_error.h +80 -0
- package/deps/librdkafka/src/rdkafka_event.c +502 -0
- package/deps/librdkafka/src/rdkafka_event.h +126 -0
- package/deps/librdkafka/src/rdkafka_feature.c +461 -0
- package/deps/librdkafka/src/rdkafka_feature.h +102 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +1402 -0
- package/deps/librdkafka/src/rdkafka_fetcher.h +44 -0
- package/deps/librdkafka/src/rdkafka_header.c +220 -0
- package/deps/librdkafka/src/rdkafka_header.h +76 -0
- package/deps/librdkafka/src/rdkafka_idempotence.c +807 -0
- package/deps/librdkafka/src/rdkafka_idempotence.h +144 -0
- package/deps/librdkafka/src/rdkafka_int.h +1222 -0
- package/deps/librdkafka/src/rdkafka_interceptor.c +819 -0
- package/deps/librdkafka/src/rdkafka_interceptor.h +104 -0
- package/deps/librdkafka/src/rdkafka_lz4.c +450 -0
- package/deps/librdkafka/src/rdkafka_lz4.h +49 -0
- package/deps/librdkafka/src/rdkafka_metadata.c +2124 -0
- package/deps/librdkafka/src/rdkafka_metadata.h +341 -0
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +977 -0
- package/deps/librdkafka/src/rdkafka_mock.c +2885 -0
- package/deps/librdkafka/src/rdkafka_mock.h +491 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +710 -0
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +2817 -0
- package/deps/librdkafka/src/rdkafka_mock_int.h +591 -0
- package/deps/librdkafka/src/rdkafka_msg.c +2573 -0
- package/deps/librdkafka/src/rdkafka_msg.h +614 -0
- package/deps/librdkafka/src/rdkafka_msgbatch.h +62 -0
- package/deps/librdkafka/src/rdkafka_msgset.h +98 -0
- package/deps/librdkafka/src/rdkafka_msgset_reader.c +1806 -0
- package/deps/librdkafka/src/rdkafka_msgset_writer.c +1470 -0
- package/deps/librdkafka/src/rdkafka_offset.c +1537 -0
- package/deps/librdkafka/src/rdkafka_offset.h +150 -0
- package/deps/librdkafka/src/rdkafka_op.c +997 -0
- package/deps/librdkafka/src/rdkafka_op.h +834 -0
- package/deps/librdkafka/src/rdkafka_partition.c +4801 -0
- package/deps/librdkafka/src/rdkafka_partition.h +1173 -0
- package/deps/librdkafka/src/rdkafka_pattern.c +228 -0
- package/deps/librdkafka/src/rdkafka_pattern.h +70 -0
- package/deps/librdkafka/src/rdkafka_plugin.c +213 -0
- package/deps/librdkafka/src/rdkafka_plugin.h +41 -0
- package/deps/librdkafka/src/rdkafka_proto.h +733 -0
- package/deps/librdkafka/src/rdkafka_protocol.h +127 -0
- package/deps/librdkafka/src/rdkafka_queue.c +1153 -0
- package/deps/librdkafka/src/rdkafka_queue.h +1201 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1748 -0
- package/deps/librdkafka/src/rdkafka_request.c +6817 -0
- package/deps/librdkafka/src/rdkafka_request.h +709 -0
- package/deps/librdkafka/src/rdkafka_roundrobin_assignor.c +123 -0
- package/deps/librdkafka/src/rdkafka_sasl.c +528 -0
- package/deps/librdkafka/src/rdkafka_sasl.h +63 -0
- package/deps/librdkafka/src/rdkafka_sasl_cyrus.c +722 -0
- package/deps/librdkafka/src/rdkafka_sasl_int.h +89 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +1829 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +589 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +37 -0
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +142 -0
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +857 -0
- package/deps/librdkafka/src/rdkafka_sasl_win32.c +550 -0
- package/deps/librdkafka/src/rdkafka_ssl.c +1904 -0
- package/deps/librdkafka/src/rdkafka_ssl.h +64 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4781 -0
- package/deps/librdkafka/src/rdkafka_subscription.c +278 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +703 -0
- package/deps/librdkafka/src/rdkafka_telemetry.h +52 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.c +1053 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.h +59 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.c +993 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.h +301 -0
- package/deps/librdkafka/src/rdkafka_timer.c +402 -0
- package/deps/librdkafka/src/rdkafka_timer.h +117 -0
- package/deps/librdkafka/src/rdkafka_topic.c +2078 -0
- package/deps/librdkafka/src/rdkafka_topic.h +328 -0
- package/deps/librdkafka/src/rdkafka_transport.c +1297 -0
- package/deps/librdkafka/src/rdkafka_transport.h +94 -0
- package/deps/librdkafka/src/rdkafka_transport_int.h +100 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +3251 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.h +171 -0
- package/deps/librdkafka/src/rdkafka_zstd.c +226 -0
- package/deps/librdkafka/src/rdkafka_zstd.h +57 -0
- package/deps/librdkafka/src/rdlist.c +576 -0
- package/deps/librdkafka/src/rdlist.h +434 -0
- package/deps/librdkafka/src/rdlog.c +89 -0
- package/deps/librdkafka/src/rdlog.h +41 -0
- package/deps/librdkafka/src/rdmap.c +503 -0
- package/deps/librdkafka/src/rdmap.h +492 -0
- package/deps/librdkafka/src/rdmurmur2.c +167 -0
- package/deps/librdkafka/src/rdmurmur2.h +35 -0
- package/deps/librdkafka/src/rdports.c +61 -0
- package/deps/librdkafka/src/rdports.h +38 -0
- package/deps/librdkafka/src/rdposix.h +250 -0
- package/deps/librdkafka/src/rdrand.c +70 -0
- package/deps/librdkafka/src/rdrand.h +43 -0
- package/deps/librdkafka/src/rdregex.c +156 -0
- package/deps/librdkafka/src/rdregex.h +43 -0
- package/deps/librdkafka/src/rdsignal.h +57 -0
- package/deps/librdkafka/src/rdstring.c +645 -0
- package/deps/librdkafka/src/rdstring.h +98 -0
- package/deps/librdkafka/src/rdsysqueue.h +404 -0
- package/deps/librdkafka/src/rdtime.h +325 -0
- package/deps/librdkafka/src/rdtypes.h +86 -0
- package/deps/librdkafka/src/rdunittest.c +532 -0
- package/deps/librdkafka/src/rdunittest.h +230 -0
- package/deps/librdkafka/src/rdvarint.c +134 -0
- package/deps/librdkafka/src/rdvarint.h +165 -0
- package/deps/librdkafka/src/rdwin32.h +382 -0
- package/deps/librdkafka/src/rdxxhash.c +1030 -0
- package/deps/librdkafka/src/rdxxhash.h +328 -0
- package/deps/librdkafka/src/regexp.c +1347 -0
- package/deps/librdkafka/src/regexp.h +41 -0
- package/deps/librdkafka/src/snappy.c +1866 -0
- package/deps/librdkafka/src/snappy.h +62 -0
- package/deps/librdkafka/src/snappy_compat.h +138 -0
- package/deps/librdkafka/src/statistics_schema.json +444 -0
- package/deps/librdkafka/src/tinycthread.c +932 -0
- package/deps/librdkafka/src/tinycthread.h +503 -0
- package/deps/librdkafka/src/tinycthread_extra.c +175 -0
- package/deps/librdkafka/src/tinycthread_extra.h +208 -0
- package/deps/librdkafka/src/win32_config.h +58 -0
- package/deps/librdkafka/src-cpp/CMakeLists.txt +90 -0
- package/deps/librdkafka/src-cpp/ConfImpl.cpp +84 -0
- package/deps/librdkafka/src-cpp/ConsumerImpl.cpp +244 -0
- package/deps/librdkafka/src-cpp/HandleImpl.cpp +436 -0
- package/deps/librdkafka/src-cpp/HeadersImpl.cpp +48 -0
- package/deps/librdkafka/src-cpp/KafkaConsumerImpl.cpp +296 -0
- package/deps/librdkafka/src-cpp/Makefile +55 -0
- package/deps/librdkafka/src-cpp/MessageImpl.cpp +38 -0
- package/deps/librdkafka/src-cpp/MetadataImpl.cpp +170 -0
- package/deps/librdkafka/src-cpp/ProducerImpl.cpp +197 -0
- package/deps/librdkafka/src-cpp/QueueImpl.cpp +70 -0
- package/deps/librdkafka/src-cpp/README.md +16 -0
- package/deps/librdkafka/src-cpp/RdKafka.cpp +59 -0
- package/deps/librdkafka/src-cpp/TopicImpl.cpp +124 -0
- package/deps/librdkafka/src-cpp/TopicPartitionImpl.cpp +57 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp.h +3771 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp_int.h +1641 -0
- package/deps/librdkafka/tests/0000-unittests.c +72 -0
- package/deps/librdkafka/tests/0001-multiobj.c +98 -0
- package/deps/librdkafka/tests/0002-unkpart.c +244 -0
- package/deps/librdkafka/tests/0003-msgmaxsize.c +173 -0
- package/deps/librdkafka/tests/0004-conf.c +867 -0
- package/deps/librdkafka/tests/0005-order.c +133 -0
- package/deps/librdkafka/tests/0006-symbols.c +163 -0
- package/deps/librdkafka/tests/0007-autotopic.c +136 -0
- package/deps/librdkafka/tests/0008-reqacks.c +179 -0
- package/deps/librdkafka/tests/0009-mock_cluster.c +96 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +752 -0
- package/deps/librdkafka/tests/0012-produce_consume.c +537 -0
- package/deps/librdkafka/tests/0013-null-msgs.c +473 -0
- package/deps/librdkafka/tests/0014-reconsume-191.c +512 -0
- package/deps/librdkafka/tests/0015-offset_seeks.c +172 -0
- package/deps/librdkafka/tests/0016-client_swname.c +166 -0
- package/deps/librdkafka/tests/0017-compression.c +142 -0
- package/deps/librdkafka/tests/0018-cgrp_term.c +333 -0
- package/deps/librdkafka/tests/0019-list_groups.c +289 -0
- package/deps/librdkafka/tests/0020-destroy_hang.c +162 -0
- package/deps/librdkafka/tests/0021-rkt_destroy.c +71 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +276 -0
- package/deps/librdkafka/tests/0025-timers.c +147 -0
- package/deps/librdkafka/tests/0026-consume_pause.c +549 -0
- package/deps/librdkafka/tests/0028-long_topicnames.c +79 -0
- package/deps/librdkafka/tests/0029-assign_offset.c +204 -0
- package/deps/librdkafka/tests/0030-offset_commit.c +589 -0
- package/deps/librdkafka/tests/0031-get_offsets.c +235 -0
- package/deps/librdkafka/tests/0033-regex_subscribe.c +520 -0
- package/deps/librdkafka/tests/0034-offset_reset.c +377 -0
- package/deps/librdkafka/tests/0035-api_version.c +73 -0
- package/deps/librdkafka/tests/0036-partial_fetch.c +86 -0
- package/deps/librdkafka/tests/0037-destroy_hang_local.c +85 -0
- package/deps/librdkafka/tests/0038-performance.c +120 -0
- package/deps/librdkafka/tests/0039-event.c +284 -0
- package/deps/librdkafka/tests/0040-io_event.c +251 -0
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +96 -0
- package/deps/librdkafka/tests/0042-many_topics.c +252 -0
- package/deps/librdkafka/tests/0043-no_connection.c +77 -0
- package/deps/librdkafka/tests/0044-partition_cnt.c +93 -0
- package/deps/librdkafka/tests/0045-subscribe_update.c +746 -0
- package/deps/librdkafka/tests/0046-rkt_cache.c +65 -0
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +97 -0
- package/deps/librdkafka/tests/0048-partitioner.c +283 -0
- package/deps/librdkafka/tests/0049-consume_conn_close.c +162 -0
- package/deps/librdkafka/tests/0050-subscribe_adds.c +144 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +125 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +220 -0
- package/deps/librdkafka/tests/0053-stats_cb.cpp +535 -0
- package/deps/librdkafka/tests/0054-offset_time.cpp +236 -0
- package/deps/librdkafka/tests/0055-producer_latency.c +366 -0
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +311 -0
- package/deps/librdkafka/tests/0057-invalid_topic.cpp +112 -0
- package/deps/librdkafka/tests/0058-log.cpp +123 -0
- package/deps/librdkafka/tests/0059-bsearch.cpp +237 -0
- package/deps/librdkafka/tests/0060-op_prio.cpp +163 -0
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +275 -0
- package/deps/librdkafka/tests/0062-stats_event.c +126 -0
- package/deps/librdkafka/tests/0063-clusterid.cpp +180 -0
- package/deps/librdkafka/tests/0064-interceptors.c +481 -0
- package/deps/librdkafka/tests/0065-yield.cpp +140 -0
- package/deps/librdkafka/tests/0066-plugins.cpp +129 -0
- package/deps/librdkafka/tests/0067-empty_topic.cpp +148 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +138 -0
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +123 -0
- package/deps/librdkafka/tests/0070-null_empty.cpp +197 -0
- package/deps/librdkafka/tests/0072-headers_ut.c +448 -0
- package/deps/librdkafka/tests/0073-headers.c +381 -0
- package/deps/librdkafka/tests/0074-producev.c +87 -0
- package/deps/librdkafka/tests/0075-retry.c +253 -0
- package/deps/librdkafka/tests/0076-produce_retry.c +450 -0
- package/deps/librdkafka/tests/0077-compaction.c +357 -0
- package/deps/librdkafka/tests/0078-c_from_cpp.cpp +96 -0
- package/deps/librdkafka/tests/0079-fork.c +93 -0
- package/deps/librdkafka/tests/0080-admin_ut.c +3065 -0
- package/deps/librdkafka/tests/0081-admin.c +5333 -0
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +133 -0
- package/deps/librdkafka/tests/0083-cb_event.c +228 -0
- package/deps/librdkafka/tests/0084-destroy_flags.c +212 -0
- package/deps/librdkafka/tests/0085-headers.cpp +388 -0
- package/deps/librdkafka/tests/0086-purge.c +335 -0
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +162 -0
- package/deps/librdkafka/tests/0089-max_poll_interval.c +506 -0
- package/deps/librdkafka/tests/0090-idempotence.c +172 -0
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +297 -0
- package/deps/librdkafka/tests/0092-mixed_msgver.c +97 -0
- package/deps/librdkafka/tests/0093-holb.c +197 -0
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +230 -0
- package/deps/librdkafka/tests/0095-all_brokers_down.cpp +122 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +466 -0
- package/deps/librdkafka/tests/0098-consumer-txn.cpp +1218 -0
- package/deps/librdkafka/tests/0099-commit_metadata.c +194 -0
- package/deps/librdkafka/tests/0100-thread_interceptors.cpp +195 -0
- package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +446 -0
- package/deps/librdkafka/tests/0102-static_group_rebalance.c +535 -0
- package/deps/librdkafka/tests/0103-transactions.c +1383 -0
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +624 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +3923 -0
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +297 -0
- package/deps/librdkafka/tests/0107-topic_recreate.c +259 -0
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +218 -0
- package/deps/librdkafka/tests/0110-batch_size.cpp +183 -0
- package/deps/librdkafka/tests/0111-delay_create_topics.cpp +127 -0
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +98 -0
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +3329 -0
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +176 -0
- package/deps/librdkafka/tests/0115-producer_auth.cpp +179 -0
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +214 -0
- package/deps/librdkafka/tests/0117-mock_errors.c +321 -0
- package/deps/librdkafka/tests/0118-commit_rebalance.c +121 -0
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +148 -0
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +180 -0
- package/deps/librdkafka/tests/0121-clusterid.c +115 -0
- package/deps/librdkafka/tests/0122-buffer_cleaning_after_rebalance.c +227 -0
- package/deps/librdkafka/tests/0123-connections_max_idle.c +98 -0
- package/deps/librdkafka/tests/0124-openssl_invalid_engine.c +69 -0
- package/deps/librdkafka/tests/0125-immediate_flush.c +144 -0
- package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +213 -0
- package/deps/librdkafka/tests/0127-fetch_queue_backoff.cpp +165 -0
- package/deps/librdkafka/tests/0128-sasl_callback_queue.cpp +125 -0
- package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +78 -0
- package/deps/librdkafka/tests/0130-store_offsets.c +178 -0
- package/deps/librdkafka/tests/0131-connect_timeout.c +81 -0
- package/deps/librdkafka/tests/0132-strategy_ordering.c +171 -0
- package/deps/librdkafka/tests/0133-ssl_keys.c +128 -0
- package/deps/librdkafka/tests/0134-ssl_provider.c +92 -0
- package/deps/librdkafka/tests/0135-sasl_credentials.cpp +143 -0
- package/deps/librdkafka/tests/0136-resolve_cb.c +181 -0
- package/deps/librdkafka/tests/0137-barrier_batch_consume.c +609 -0
- package/deps/librdkafka/tests/0138-admin_mock.c +281 -0
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +442 -0
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +108 -0
- package/deps/librdkafka/tests/0142-reauthentication.c +495 -0
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +553 -0
- package/deps/librdkafka/tests/0144-idempotence_mock.c +373 -0
- package/deps/librdkafka/tests/0145-pause_resume_mock.c +119 -0
- package/deps/librdkafka/tests/0146-metadata_mock.c +444 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +648 -0
- package/deps/librdkafka/tests/1000-unktopic.c +164 -0
- package/deps/librdkafka/tests/8000-idle.cpp +60 -0
- package/deps/librdkafka/tests/8001-fetch_from_follower_mock_manual.c +113 -0
- package/deps/librdkafka/tests/CMakeLists.txt +164 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +266 -0
- package/deps/librdkafka/tests/Makefile +182 -0
- package/deps/librdkafka/tests/README.md +509 -0
- package/deps/librdkafka/tests/autotest.sh +33 -0
- package/deps/librdkafka/tests/backtrace.gdb +30 -0
- package/deps/librdkafka/tests/broker_version_tests.py +315 -0
- package/deps/librdkafka/tests/buildbox.sh +17 -0
- package/deps/librdkafka/tests/cleanup-checker-tests.sh +20 -0
- package/deps/librdkafka/tests/cluster_testing.py +191 -0
- package/deps/librdkafka/tests/delete-test-topics.sh +56 -0
- package/deps/librdkafka/tests/fixtures/ssl/Makefile +8 -0
- package/deps/librdkafka/tests/fixtures/ssl/README.md +13 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +109 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +34 -0
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +93 -0
- package/deps/librdkafka/tests/fuzzers/Makefile +12 -0
- package/deps/librdkafka/tests/fuzzers/README.md +31 -0
- package/deps/librdkafka/tests/fuzzers/fuzz_regex.c +74 -0
- package/deps/librdkafka/tests/fuzzers/helpers.h +90 -0
- package/deps/librdkafka/tests/gen-ssl-certs.sh +165 -0
- package/deps/librdkafka/tests/interactive_broker_version.py +170 -0
- package/deps/librdkafka/tests/interceptor_test/CMakeLists.txt +16 -0
- package/deps/librdkafka/tests/interceptor_test/Makefile +22 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.c +314 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.h +54 -0
- package/deps/librdkafka/tests/java/IncrementalRebalanceCli.java +97 -0
- package/deps/librdkafka/tests/java/Makefile +12 -0
- package/deps/librdkafka/tests/java/Murmur2Cli.java +46 -0
- package/deps/librdkafka/tests/java/README.md +14 -0
- package/deps/librdkafka/tests/java/TransactionProducerCli.java +162 -0
- package/deps/librdkafka/tests/java/run-class.sh +11 -0
- package/deps/librdkafka/tests/librdkafka.suppressions +483 -0
- package/deps/librdkafka/tests/lz4_manual_test.sh +59 -0
- package/deps/librdkafka/tests/multi-broker-version-test.sh +50 -0
- package/deps/librdkafka/tests/parse-refcnt.sh +43 -0
- package/deps/librdkafka/tests/performance_plot.py +115 -0
- package/deps/librdkafka/tests/plugin_test/Makefile +19 -0
- package/deps/librdkafka/tests/plugin_test/plugin_test.c +58 -0
- package/deps/librdkafka/tests/requirements.txt +2 -0
- package/deps/librdkafka/tests/run-consumer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-producer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-test.sh +140 -0
- package/deps/librdkafka/tests/rusage.c +249 -0
- package/deps/librdkafka/tests/sasl_test.py +289 -0
- package/deps/librdkafka/tests/scenarios/README.md +6 -0
- package/deps/librdkafka/tests/scenarios/ak23.json +6 -0
- package/deps/librdkafka/tests/scenarios/default.json +5 -0
- package/deps/librdkafka/tests/scenarios/noautocreate.json +5 -0
- package/deps/librdkafka/tests/sockem.c +801 -0
- package/deps/librdkafka/tests/sockem.h +85 -0
- package/deps/librdkafka/tests/sockem_ctrl.c +145 -0
- package/deps/librdkafka/tests/sockem_ctrl.h +61 -0
- package/deps/librdkafka/tests/test.c +7318 -0
- package/deps/librdkafka/tests/test.conf.example +27 -0
- package/deps/librdkafka/tests/test.h +979 -0
- package/deps/librdkafka/tests/testcpp.cpp +126 -0
- package/deps/librdkafka/tests/testcpp.h +360 -0
- package/deps/librdkafka/tests/testshared.h +402 -0
- package/deps/librdkafka/tests/tools/README.md +4 -0
- package/deps/librdkafka/tests/tools/stats/README.md +21 -0
- package/deps/librdkafka/tests/tools/stats/filter.jq +42 -0
- package/deps/librdkafka/tests/tools/stats/graph.py +150 -0
- package/deps/librdkafka/tests/tools/stats/requirements.txt +3 -0
- package/deps/librdkafka/tests/tools/stats/to_csv.py +124 -0
- package/deps/librdkafka/tests/until-fail.sh +87 -0
- package/deps/librdkafka/tests/xxxx-assign_partition.c +122 -0
- package/deps/librdkafka/tests/xxxx-metadata.cpp +159 -0
- package/deps/librdkafka/vcpkg.json +23 -0
- package/deps/librdkafka/win32/README.md +5 -0
- package/deps/librdkafka/win32/build-package.bat +3 -0
- package/deps/librdkafka/win32/build.bat +19 -0
- package/deps/librdkafka/win32/common.vcxproj +84 -0
- package/deps/librdkafka/win32/install-openssl.ps1 +33 -0
- package/deps/librdkafka/win32/interceptor_test/interceptor_test.vcxproj +87 -0
- package/deps/librdkafka/win32/librdkafka.autopkg.template +54 -0
- package/deps/librdkafka/win32/librdkafka.master.testing.targets +13 -0
- package/deps/librdkafka/win32/librdkafka.sln +226 -0
- package/deps/librdkafka/win32/librdkafka.vcxproj +276 -0
- package/deps/librdkafka/win32/librdkafkacpp/librdkafkacpp.vcxproj +104 -0
- package/deps/librdkafka/win32/msbuild.ps1 +15 -0
- package/deps/librdkafka/win32/openssl_engine_example/openssl_engine_example.vcxproj +132 -0
- package/deps/librdkafka/win32/package-zip.ps1 +46 -0
- package/deps/librdkafka/win32/packages/repositories.config +4 -0
- package/deps/librdkafka/win32/push-package.bat +4 -0
- package/deps/librdkafka/win32/rdkafka_complex_consumer_example_cpp/rdkafka_complex_consumer_example_cpp.vcxproj +67 -0
- package/deps/librdkafka/win32/rdkafka_example/rdkafka_example.vcxproj +97 -0
- package/deps/librdkafka/win32/rdkafka_performance/rdkafka_performance.vcxproj +97 -0
- package/deps/librdkafka/win32/setup-msys2.ps1 +31 -0
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +12 -0
- package/deps/librdkafka/win32/tests/test.conf.example +25 -0
- package/deps/librdkafka/win32/tests/tests.vcxproj +247 -0
- package/deps/librdkafka/win32/win_ssl_cert_store/win_ssl_cert_store.vcxproj +132 -0
- package/deps/librdkafka/win32/wingetopt.c +564 -0
- package/deps/librdkafka/win32/wingetopt.h +100 -0
- package/deps/librdkafka/win32/wintime.h +33 -0
- package/deps/librdkafka.gyp +62 -0
- package/deps/windows-install.py +73 -0
- package/docker-compose.yml +23 -0
- package/e2e/admin.spec.js +187 -0
- package/e2e/both.spec.js +726 -0
- package/e2e/consumer.spec.js +386 -0
- package/e2e/groups.spec.js +132 -0
- package/e2e/listener.js +51 -0
- package/e2e/producer-transaction.spec.js +333 -0
- package/e2e/producer.spec.js +283 -0
- package/errors.d.ts +347 -0
- package/examples/consumer-flow.md +76 -0
- package/examples/consumer.md +45 -0
- package/examples/docker-alpine.md +30 -0
- package/examples/high-level-producer.md +32 -0
- package/examples/metadata.md +27 -0
- package/examples/oauthbearer-default-flow.md +80 -0
- package/examples/producer-cluster.md +103 -0
- package/examples/producer.md +73 -0
- package/index.d.ts +357 -0
- package/lib/admin.js +233 -0
- package/lib/client.js +578 -0
- package/lib/error.js +472 -0
- package/lib/index.js +34 -0
- package/lib/kafka-consumer-stream.js +397 -0
- package/lib/kafka-consumer.js +698 -0
- package/lib/producer/high-level-producer.js +323 -0
- package/lib/producer-stream.js +307 -0
- package/lib/producer.js +375 -0
- package/lib/tools/ref-counter.js +52 -0
- package/lib/topic-partition.js +88 -0
- package/lib/topic.js +42 -0
- package/lib/util.js +29 -0
- package/librdkafka.js +12 -0
- package/make_docs.sh +59 -0
- package/package.json +53 -0
- package/renovate.json +30 -0
- package/run_docker.sh +42 -0
- package/src/admin.cc +624 -0
- package/src/admin.h +78 -0
- package/src/binding.cc +73 -0
- package/src/binding.h +25 -0
- package/src/callbacks.cc +614 -0
- package/src/callbacks.h +265 -0
- package/src/common.cc +582 -0
- package/src/common.h +134 -0
- package/src/config.cc +167 -0
- package/src/config.h +45 -0
- package/src/connection.cc +482 -0
- package/src/connection.h +108 -0
- package/src/errors.cc +96 -0
- package/src/errors.h +53 -0
- package/src/kafka-consumer.cc +1457 -0
- package/src/kafka-consumer.h +136 -0
- package/src/per-isolate-data.cc +57 -0
- package/src/per-isolate-data.h +39 -0
- package/src/producer.cc +873 -0
- package/src/producer.h +125 -0
- package/src/topic.cc +180 -0
- package/src/topic.h +56 -0
- package/src/workers.cc +1245 -0
- package/src/workers.h +511 -0
- package/test/binding.spec.js +66 -0
- package/test/consumer.spec.js +91 -0
- package/test/error.spec.js +8 -0
- package/test/index.spec.js +8 -0
- package/test/kafka-consumer-stream.spec.js +298 -0
- package/test/kafka-consumer-worker.js +51 -0
- package/test/kafka-consumer.spec.js +86 -0
- package/test/mocha.opts +1 -0
- package/test/mock.js +55 -0
- package/test/producer/high-level-producer.spec.js +496 -0
- package/test/producer-stream.spec.js +723 -0
- package/test/producer-worker.js +53 -0
- package/test/producer.spec.js +120 -0
- package/test/tools/ref-counter.spec.js +53 -0
- package/test/topic-partition.spec.js +104 -0
- package/test/util.spec.js +46 -0
- package/util/configure.js +30 -0
- package/util/get-env.js +6 -0
- package/util/test-compile.js +11 -0
- package/util/test-producer-delivery.js +100 -0
- package/win_install.ps1 +2 -0
|
@@ -0,0 +1,4456 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* librdkafka - Apache Kafka C library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2012-2022, Magnus Edenhill
|
|
5
|
+
* 2023 Confluent Inc.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions are met:
|
|
10
|
+
*
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright notice,
|
|
12
|
+
* this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
14
|
+
* this list of conditions and the following disclaimer in the documentation
|
|
15
|
+
* and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
18
|
+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
19
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
20
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
|
21
|
+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
#include "rdkafka_int.h"
|
|
31
|
+
#include "rd.h"
|
|
32
|
+
#include "rdfloat.h"
|
|
33
|
+
|
|
34
|
+
#include <stdlib.h>
|
|
35
|
+
#include <ctype.h>
|
|
36
|
+
#include <stddef.h>
|
|
37
|
+
|
|
38
|
+
#include "rdkafka_int.h"
|
|
39
|
+
#include "rdkafka_feature.h"
|
|
40
|
+
#include "rdkafka_interceptor.h"
|
|
41
|
+
#include "rdkafka_idempotence.h"
|
|
42
|
+
#include "rdkafka_assignor.h"
|
|
43
|
+
#include "rdkafka_sasl_oauthbearer.h"
|
|
44
|
+
#if WITH_PLUGINS
|
|
45
|
+
#include "rdkafka_plugin.h"
|
|
46
|
+
#endif
|
|
47
|
+
#include "rdunittest.h"
|
|
48
|
+
|
|
49
|
+
#ifndef _WIN32
|
|
50
|
+
#include <netinet/tcp.h>
|
|
51
|
+
#else
|
|
52
|
+
|
|
53
|
+
#ifndef WIN32_MEAN_AND_LEAN
|
|
54
|
+
#define WIN32_MEAN_AND_LEAN
|
|
55
|
+
#endif
|
|
56
|
+
#include <windows.h>
|
|
57
|
+
#endif
|
|
58
|
+
|
|
59
|
+
struct rd_kafka_property {
|
|
60
|
+
rd_kafka_conf_scope_t scope;
|
|
61
|
+
const char *name;
|
|
62
|
+
enum { _RK_C_STR,
|
|
63
|
+
_RK_C_INT,
|
|
64
|
+
_RK_C_DBL, /* Double */
|
|
65
|
+
_RK_C_S2I, /* String to Integer mapping.
|
|
66
|
+
* Supports limited canonical str->int mappings
|
|
67
|
+
* using s2i[] */
|
|
68
|
+
_RK_C_S2F, /* CSV String to Integer flag mapping (OR:ed) */
|
|
69
|
+
_RK_C_BOOL,
|
|
70
|
+
_RK_C_PTR, /* Only settable through special set functions */
|
|
71
|
+
_RK_C_PATLIST, /* Pattern list */
|
|
72
|
+
_RK_C_KSTR, /* Kafka string */
|
|
73
|
+
_RK_C_ALIAS, /* Alias: points to other property through .sdef */
|
|
74
|
+
_RK_C_INTERNAL, /* Internal, don't expose to application */
|
|
75
|
+
_RK_C_INVALID, /* Invalid property, used to catch known
|
|
76
|
+
* but unsupported Java properties. */
|
|
77
|
+
} type;
|
|
78
|
+
int offset;
|
|
79
|
+
const char *desc;
|
|
80
|
+
int vmin;
|
|
81
|
+
int vmax;
|
|
82
|
+
int vdef; /* Default value (int) */
|
|
83
|
+
const char *sdef; /* Default value (string) */
|
|
84
|
+
void *pdef; /* Default value (pointer) */
|
|
85
|
+
double ddef; /* Default value (double) */
|
|
86
|
+
double dmin;
|
|
87
|
+
double dmax;
|
|
88
|
+
struct {
|
|
89
|
+
int val;
|
|
90
|
+
const char *str;
|
|
91
|
+
const char *unsupported; /**< Reason for value not being
|
|
92
|
+
* supported in this build. */
|
|
93
|
+
} s2i[21]; /* _RK_C_S2I and _RK_C_S2F */
|
|
94
|
+
|
|
95
|
+
const char *unsupported; /**< Reason for propery not being supported
|
|
96
|
+
* in this build.
|
|
97
|
+
* Will be included in the conf_set()
|
|
98
|
+
* error string. */
|
|
99
|
+
|
|
100
|
+
/* Value validator (STR) */
|
|
101
|
+
int (*validate)(const struct rd_kafka_property *prop,
|
|
102
|
+
const char *val,
|
|
103
|
+
int ival);
|
|
104
|
+
|
|
105
|
+
/* Configuration object constructors and destructor for use when
|
|
106
|
+
* the property value itself is not used, or needs extra care. */
|
|
107
|
+
void (*ctor)(int scope, void *pconf);
|
|
108
|
+
void (*dtor)(int scope, void *pconf);
|
|
109
|
+
void (*copy)(int scope,
|
|
110
|
+
void *pdst,
|
|
111
|
+
const void *psrc,
|
|
112
|
+
void *dstptr,
|
|
113
|
+
const void *srcptr,
|
|
114
|
+
size_t filter_cnt,
|
|
115
|
+
const char **filter);
|
|
116
|
+
|
|
117
|
+
rd_kafka_conf_res_t (*set)(int scope,
|
|
118
|
+
void *pconf,
|
|
119
|
+
const char *name,
|
|
120
|
+
const char *value,
|
|
121
|
+
void *dstptr,
|
|
122
|
+
rd_kafka_conf_set_mode_t set_mode,
|
|
123
|
+
char *errstr,
|
|
124
|
+
size_t errstr_size);
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
#define _RK(field) offsetof(rd_kafka_conf_t, field)
|
|
129
|
+
#define _RKT(field) offsetof(rd_kafka_topic_conf_t, field)
|
|
130
|
+
|
|
131
|
+
#if WITH_SSL
|
|
132
|
+
#define _UNSUPPORTED_SSL .unsupported = NULL
|
|
133
|
+
#else
|
|
134
|
+
#define _UNSUPPORTED_SSL .unsupported = "OpenSSL not available at build time"
|
|
135
|
+
#endif
|
|
136
|
+
|
|
137
|
+
#if OPENSSL_VERSION_NUMBER >= 0x1000200fL && defined(WITH_SSL) && \
|
|
138
|
+
!defined(LIBRESSL_VERSION_NUMBER)
|
|
139
|
+
#define _UNSUPPORTED_OPENSSL_1_0_2 .unsupported = NULL
|
|
140
|
+
#else
|
|
141
|
+
#define _UNSUPPORTED_OPENSSL_1_0_2 \
|
|
142
|
+
.unsupported = "OpenSSL >= 1.0.2 not available at build time"
|
|
143
|
+
#endif
|
|
144
|
+
|
|
145
|
+
#if OPENSSL_VERSION_NUMBER >= 0x10100000 && defined(WITH_SSL) && \
|
|
146
|
+
!defined(LIBRESSL_VERSION_NUMBER)
|
|
147
|
+
#define _UNSUPPORTED_OPENSSL_1_1_0 .unsupported = NULL
|
|
148
|
+
#else
|
|
149
|
+
#define _UNSUPPORTED_OPENSSL_1_1_0 \
|
|
150
|
+
.unsupported = "OpenSSL >= 1.1.0 not available at build time"
|
|
151
|
+
#endif
|
|
152
|
+
|
|
153
|
+
#if WITH_SSL_ENGINE
|
|
154
|
+
#define _UNSUPPORTED_SSL_ENGINE .unsupported = NULL
|
|
155
|
+
#else
|
|
156
|
+
#define _UNSUPPORTED_SSL_ENGINE \
|
|
157
|
+
.unsupported = "OpenSSL >= 1.1.x not available at build time"
|
|
158
|
+
#endif
|
|
159
|
+
|
|
160
|
+
#if OPENSSL_VERSION_NUMBER >= 0x30000000 && defined(WITH_SSL)
|
|
161
|
+
#define _UNSUPPORTED_SSL_3 .unsupported = NULL
|
|
162
|
+
#else
|
|
163
|
+
#define _UNSUPPORTED_SSL_3 \
|
|
164
|
+
.unsupported = "OpenSSL >= 3.0.0 not available at build time"
|
|
165
|
+
#endif
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
#if WITH_ZLIB
|
|
169
|
+
#define _UNSUPPORTED_ZLIB .unsupported = NULL
|
|
170
|
+
#else
|
|
171
|
+
#define _UNSUPPORTED_ZLIB .unsupported = "zlib not available at build time"
|
|
172
|
+
#endif
|
|
173
|
+
|
|
174
|
+
#if WITH_SNAPPY
|
|
175
|
+
#define _UNSUPPORTED_SNAPPY .unsupported = NULL
|
|
176
|
+
#else
|
|
177
|
+
#define _UNSUPPORTED_SNAPPY .unsupported = "snappy not enabled at build time"
|
|
178
|
+
#endif
|
|
179
|
+
|
|
180
|
+
#if WITH_ZSTD
|
|
181
|
+
#define _UNSUPPORTED_ZSTD .unsupported = NULL
|
|
182
|
+
#else
|
|
183
|
+
#define _UNSUPPORTED_ZSTD .unsupported = "libzstd not available at build time"
|
|
184
|
+
#endif
|
|
185
|
+
|
|
186
|
+
#if WITH_CURL
|
|
187
|
+
#define _UNSUPPORTED_HTTP .unsupported = NULL
|
|
188
|
+
#else
|
|
189
|
+
#define _UNSUPPORTED_HTTP .unsupported = "libcurl not available at build time"
|
|
190
|
+
#endif
|
|
191
|
+
|
|
192
|
+
#if WITH_OAUTHBEARER_OIDC
|
|
193
|
+
#define _UNSUPPORTED_OIDC .unsupported = NULL
|
|
194
|
+
#else
|
|
195
|
+
#define _UNSUPPORTED_OIDC \
|
|
196
|
+
.unsupported = \
|
|
197
|
+
"OAuth/OIDC depends on libcurl and OpenSSL which were not " \
|
|
198
|
+
"available at build time"
|
|
199
|
+
#endif
|
|
200
|
+
|
|
201
|
+
#ifdef _WIN32
|
|
202
|
+
#define _UNSUPPORTED_WIN32_GSSAPI \
|
|
203
|
+
.unsupported = \
|
|
204
|
+
"Kerberos keytabs are not supported on Windows, " \
|
|
205
|
+
"instead the logged on " \
|
|
206
|
+
"user's credentials are used through native SSPI"
|
|
207
|
+
#else
|
|
208
|
+
#define _UNSUPPORTED_WIN32_GSSAPI .unsupported = NULL
|
|
209
|
+
#endif
|
|
210
|
+
|
|
211
|
+
#if defined(_WIN32) || defined(WITH_SASL_CYRUS)
|
|
212
|
+
#define _UNSUPPORTED_GSSAPI .unsupported = NULL
|
|
213
|
+
#else
|
|
214
|
+
#define _UNSUPPORTED_GSSAPI \
|
|
215
|
+
.unsupported = "cyrus-sasl/libsasl2 not available at build time"
|
|
216
|
+
#endif
|
|
217
|
+
|
|
218
|
+
#define _UNSUPPORTED_OAUTHBEARER _UNSUPPORTED_SSL
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
static rd_kafka_conf_res_t
|
|
222
|
+
rd_kafka_anyconf_get0(const void *conf,
|
|
223
|
+
const struct rd_kafka_property *prop,
|
|
224
|
+
char *dest,
|
|
225
|
+
size_t *dest_size);
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* @returns a unique index for property \p prop, using the byte position
|
|
231
|
+
* of the field.
|
|
232
|
+
*/
|
|
233
|
+
static RD_INLINE int rd_kafka_prop2idx(const struct rd_kafka_property *prop) {
|
|
234
|
+
return prop->offset;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* @brief Set the property as modified.
|
|
241
|
+
*
|
|
242
|
+
* We do this by mapping the property's conf struct field byte offset
|
|
243
|
+
* to a bit in a bit vector.
|
|
244
|
+
* If the bit is set the property has been modified, otherwise it is
|
|
245
|
+
* at its default unmodified value.
|
|
246
|
+
*
|
|
247
|
+
* \p is_modified 1: set as modified, 0: clear modified
|
|
248
|
+
*/
|
|
249
|
+
static void rd_kafka_anyconf_set_modified(void *conf,
|
|
250
|
+
const struct rd_kafka_property *prop,
|
|
251
|
+
int is_modified) {
|
|
252
|
+
int idx = rd_kafka_prop2idx(prop);
|
|
253
|
+
int bkt = idx / 64;
|
|
254
|
+
uint64_t bit = (uint64_t)1 << (idx % 64);
|
|
255
|
+
struct rd_kafka_anyconf_hdr *confhdr = conf;
|
|
256
|
+
|
|
257
|
+
rd_assert(idx < RD_KAFKA_CONF_PROPS_IDX_MAX &&
|
|
258
|
+
*"Increase RD_KAFKA_CONF_PROPS_IDX_MAX");
|
|
259
|
+
|
|
260
|
+
if (is_modified)
|
|
261
|
+
confhdr->modified[bkt] |= bit;
|
|
262
|
+
else
|
|
263
|
+
confhdr->modified[bkt] &= ~bit;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @brief Clear is_modified for all properties.
|
|
268
|
+
* @warning Does NOT clear/reset the value.
|
|
269
|
+
*/
|
|
270
|
+
static void rd_kafka_anyconf_clear_all_is_modified(void *conf) {
|
|
271
|
+
struct rd_kafka_anyconf_hdr *confhdr = conf;
|
|
272
|
+
|
|
273
|
+
memset(confhdr, 0, sizeof(*confhdr));
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* @returns true of the property has been set/modified, else false.
|
|
279
|
+
*/
|
|
280
|
+
static rd_bool_t
|
|
281
|
+
rd_kafka_anyconf_is_modified(const void *conf,
|
|
282
|
+
const struct rd_kafka_property *prop) {
|
|
283
|
+
int idx = rd_kafka_prop2idx(prop);
|
|
284
|
+
int bkt = idx / 64;
|
|
285
|
+
uint64_t bit = (uint64_t)1 << (idx % 64);
|
|
286
|
+
const struct rd_kafka_anyconf_hdr *confhdr = conf;
|
|
287
|
+
|
|
288
|
+
return !!(confhdr->modified[bkt] & bit);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* @returns true if any property in \p conf has been set/modified.
|
|
293
|
+
*/
|
|
294
|
+
static rd_bool_t rd_kafka_anyconf_is_any_modified(const void *conf) {
|
|
295
|
+
const struct rd_kafka_anyconf_hdr *confhdr = conf;
|
|
296
|
+
int i;
|
|
297
|
+
|
|
298
|
+
for (i = 0; i < (int)RD_ARRAYSIZE(confhdr->modified); i++)
|
|
299
|
+
if (confhdr->modified[i])
|
|
300
|
+
return rd_true;
|
|
301
|
+
|
|
302
|
+
return rd_false;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
* @brief Validate \p broker.version.fallback property.
|
|
309
|
+
*/
|
|
310
|
+
static int
|
|
311
|
+
rd_kafka_conf_validate_broker_version(const struct rd_kafka_property *prop,
|
|
312
|
+
const char *val,
|
|
313
|
+
int ival) {
|
|
314
|
+
struct rd_kafka_ApiVersion *apis;
|
|
315
|
+
size_t api_cnt;
|
|
316
|
+
return rd_kafka_get_legacy_ApiVersions(val, &apis, &api_cnt, NULL);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @brief Validate that string is a single item, without delimters (, space).
|
|
321
|
+
*/
|
|
322
|
+
static RD_UNUSED int
|
|
323
|
+
rd_kafka_conf_validate_single(const struct rd_kafka_property *prop,
|
|
324
|
+
const char *val,
|
|
325
|
+
int ival) {
|
|
326
|
+
return !strchr(val, ',') && !strchr(val, ' ');
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* @brief Validate builtin partitioner string
|
|
331
|
+
*/
|
|
332
|
+
static RD_UNUSED int
|
|
333
|
+
rd_kafka_conf_validate_partitioner(const struct rd_kafka_property *prop,
|
|
334
|
+
const char *val,
|
|
335
|
+
int ival) {
|
|
336
|
+
return !strcmp(val, "random") || !strcmp(val, "consistent") ||
|
|
337
|
+
!strcmp(val, "consistent_random") || !strcmp(val, "murmur2") ||
|
|
338
|
+
!strcmp(val, "murmur2_random") || !strcmp(val, "fnv1a") ||
|
|
339
|
+
!strcmp(val, "fnv1a_random");
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* librdkafka configuration property definitions.
|
|
345
|
+
*/
|
|
346
|
+
static const struct rd_kafka_property rd_kafka_properties[] = {
|
|
347
|
+
/* Global properties */
|
|
348
|
+
{_RK_GLOBAL, "builtin.features", _RK_C_S2F, _RK(builtin_features),
|
|
349
|
+
"Indicates the builtin features for this build of librdkafka. "
|
|
350
|
+
"An application can either query this value or attempt to set it "
|
|
351
|
+
"with its list of required features to check for library support.",
|
|
352
|
+
0, 0x7fffffff, 0xffff,
|
|
353
|
+
.s2i = {{0x1, "gzip", _UNSUPPORTED_ZLIB},
|
|
354
|
+
{0x2, "snappy", _UNSUPPORTED_SNAPPY},
|
|
355
|
+
{0x4, "ssl", _UNSUPPORTED_SSL},
|
|
356
|
+
{0x8, "sasl"},
|
|
357
|
+
{0x10, "regex"},
|
|
358
|
+
{0x20, "lz4"},
|
|
359
|
+
{0x40, "sasl_gssapi", _UNSUPPORTED_GSSAPI},
|
|
360
|
+
{0x80, "sasl_plain"},
|
|
361
|
+
{0x100, "sasl_scram", _UNSUPPORTED_SSL},
|
|
362
|
+
{0x200, "plugins"
|
|
363
|
+
#if !WITH_PLUGINS
|
|
364
|
+
,
|
|
365
|
+
.unsupported = "libdl/dlopen(3) not available at "
|
|
366
|
+
"build time"
|
|
367
|
+
#endif
|
|
368
|
+
},
|
|
369
|
+
{0x400, "zstd", _UNSUPPORTED_ZSTD},
|
|
370
|
+
{0x800, "sasl_oauthbearer", _UNSUPPORTED_SSL},
|
|
371
|
+
{0x1000, "http", _UNSUPPORTED_HTTP},
|
|
372
|
+
{0x2000, "oidc", _UNSUPPORTED_OIDC},
|
|
373
|
+
{0, NULL}}},
|
|
374
|
+
{_RK_GLOBAL, "client.id", _RK_C_STR, _RK(client_id_str),
|
|
375
|
+
"Client identifier.", .sdef = "rdkafka"},
|
|
376
|
+
{_RK_GLOBAL | _RK_HIDDEN, "client.software.name", _RK_C_STR, _RK(sw_name),
|
|
377
|
+
"Client software name as reported to broker version >= v2.4.0. "
|
|
378
|
+
"Broker-side character restrictions apply, as of broker version "
|
|
379
|
+
"v2.4.0 the allowed characters are `a-zA-Z0-9.-`. The local client "
|
|
380
|
+
"will replace any other character with `-` and strip leading and "
|
|
381
|
+
"trailing non-alphanumeric characters before tranmission to "
|
|
382
|
+
"the broker. "
|
|
383
|
+
"This property should only be set by high-level language "
|
|
384
|
+
"librdkafka client bindings.",
|
|
385
|
+
.sdef = "librdkafka"},
|
|
386
|
+
{
|
|
387
|
+
_RK_GLOBAL | _RK_HIDDEN,
|
|
388
|
+
"client.software.version",
|
|
389
|
+
_RK_C_STR,
|
|
390
|
+
_RK(sw_version),
|
|
391
|
+
"Client software version as reported to broker version >= v2.4.0. "
|
|
392
|
+
"Broker-side character restrictions apply, as of broker version "
|
|
393
|
+
"v2.4.0 the allowed characters are `a-zA-Z0-9.-`. The local client "
|
|
394
|
+
"will replace any other character with `-` and strip leading and "
|
|
395
|
+
"trailing non-alphanumeric characters before tranmission to "
|
|
396
|
+
"the broker. "
|
|
397
|
+
"This property should only be set by high-level language "
|
|
398
|
+
"librdkafka client bindings."
|
|
399
|
+
"If changing this property it is highly recommended to append the "
|
|
400
|
+
"librdkafka version.",
|
|
401
|
+
},
|
|
402
|
+
{_RK_GLOBAL | _RK_HIGH, "metadata.broker.list", _RK_C_STR, _RK(brokerlist),
|
|
403
|
+
"Initial list of brokers as a CSV list of broker host or host:port. "
|
|
404
|
+
"The application may also use `rd_kafka_brokers_add()` to add "
|
|
405
|
+
"brokers during runtime."},
|
|
406
|
+
{_RK_GLOBAL | _RK_HIGH, "bootstrap.servers", _RK_C_ALIAS, 0,
|
|
407
|
+
"See metadata.broker.list", .sdef = "metadata.broker.list"},
|
|
408
|
+
{_RK_GLOBAL | _RK_MED, "message.max.bytes", _RK_C_INT, _RK(max_msg_size),
|
|
409
|
+
"Maximum Kafka protocol request message size. "
|
|
410
|
+
"Due to differing framing overhead between protocol versions the "
|
|
411
|
+
"producer is unable to reliably enforce a strict max message limit "
|
|
412
|
+
"at produce time and may exceed the maximum size by one message in "
|
|
413
|
+
"protocol ProduceRequests, the broker will enforce the the topic's "
|
|
414
|
+
"`max.message.bytes` limit (see Apache Kafka documentation).",
|
|
415
|
+
1000, 1000000000, 1000000},
|
|
416
|
+
{_RK_GLOBAL, "message.copy.max.bytes", _RK_C_INT, _RK(msg_copy_max_size),
|
|
417
|
+
"Maximum size for message to be copied to buffer. "
|
|
418
|
+
"Messages larger than this will be passed by reference (zero-copy) "
|
|
419
|
+
"at the expense of larger iovecs.",
|
|
420
|
+
0, 1000000000, 0xffff},
|
|
421
|
+
{_RK_GLOBAL | _RK_MED, "receive.message.max.bytes", _RK_C_INT,
|
|
422
|
+
_RK(recv_max_msg_size),
|
|
423
|
+
"Maximum Kafka protocol response message size. "
|
|
424
|
+
"This serves as a safety precaution to avoid memory exhaustion in "
|
|
425
|
+
"case of protocol hickups. "
|
|
426
|
+
"This value must be at least `fetch.max.bytes` + 512 to allow "
|
|
427
|
+
"for protocol overhead; the value is adjusted automatically "
|
|
428
|
+
"unless the configuration property is explicitly set.",
|
|
429
|
+
1000, INT_MAX, 100000000},
|
|
430
|
+
{_RK_GLOBAL, "max.in.flight.requests.per.connection", _RK_C_INT,
|
|
431
|
+
_RK(max_inflight),
|
|
432
|
+
"Maximum number of in-flight requests per broker connection. "
|
|
433
|
+
"This is a generic property applied to all broker communication, "
|
|
434
|
+
"however it is primarily relevant to produce requests. "
|
|
435
|
+
"In particular, note that other mechanisms limit the number "
|
|
436
|
+
"of outstanding consumer fetch request per broker to one.",
|
|
437
|
+
1, 1000000, 1000000},
|
|
438
|
+
{_RK_GLOBAL, "max.in.flight", _RK_C_ALIAS,
|
|
439
|
+
.sdef = "max.in.flight.requests.per.connection"},
|
|
440
|
+
{_RK_GLOBAL | _RK_DEPRECATED | _RK_HIDDEN, "metadata.request.timeout.ms",
|
|
441
|
+
_RK_C_INT, _RK(metadata_request_timeout_ms), "Not used.", 10, 900 * 1000,
|
|
442
|
+
10},
|
|
443
|
+
{_RK_GLOBAL, "topic.metadata.refresh.interval.ms", _RK_C_INT,
|
|
444
|
+
_RK(metadata_refresh_interval_ms),
|
|
445
|
+
"Period of time in milliseconds at which topic and broker "
|
|
446
|
+
"metadata is refreshed in order to proactively discover any new "
|
|
447
|
+
"brokers, topics, partitions or partition leader changes. "
|
|
448
|
+
"Use -1 to disable the intervalled refresh (not recommended). "
|
|
449
|
+
"If there are no locally referenced topics "
|
|
450
|
+
"(no topic objects created, no messages produced, "
|
|
451
|
+
"no subscription or no assignment) then only the broker list will "
|
|
452
|
+
"be refreshed every interval but no more often than every 10s.",
|
|
453
|
+
-1, 3600 * 1000, 5 * 60 * 1000},
|
|
454
|
+
{_RK_GLOBAL, "metadata.max.age.ms", _RK_C_INT, _RK(metadata_max_age_ms),
|
|
455
|
+
"Metadata cache max age. "
|
|
456
|
+
"Defaults to topic.metadata.refresh.interval.ms * 3",
|
|
457
|
+
1, 24 * 3600 * 1000, 5 * 60 * 1000 * 3},
|
|
458
|
+
{_RK_GLOBAL, "topic.metadata.refresh.fast.interval.ms", _RK_C_INT,
|
|
459
|
+
_RK(metadata_refresh_fast_interval_ms),
|
|
460
|
+
"When a topic loses its leader a new metadata request will be "
|
|
461
|
+
"enqueued immediately and then with this initial interval, exponentially "
|
|
462
|
+
"increasing upto `retry.backoff.max.ms`, "
|
|
463
|
+
"until the topic metadata has been refreshed. "
|
|
464
|
+
"If not set explicitly, it will be defaulted to `retry.backoff.ms`. "
|
|
465
|
+
"This is used to recover quickly from transitioning leader brokers.",
|
|
466
|
+
1, 60 * 1000, 100},
|
|
467
|
+
{_RK_GLOBAL | _RK_DEPRECATED, "topic.metadata.refresh.fast.cnt", _RK_C_INT,
|
|
468
|
+
_RK(metadata_refresh_fast_cnt), "No longer used.", 0, 1000, 10},
|
|
469
|
+
{_RK_GLOBAL, "topic.metadata.refresh.sparse", _RK_C_BOOL,
|
|
470
|
+
_RK(metadata_refresh_sparse),
|
|
471
|
+
"Sparse metadata requests (consumes less network bandwidth)", 0, 1, 1},
|
|
472
|
+
{_RK_GLOBAL, "topic.metadata.propagation.max.ms", _RK_C_INT,
|
|
473
|
+
_RK(metadata_propagation_max_ms),
|
|
474
|
+
"Apache Kafka topic creation is asynchronous and it takes some "
|
|
475
|
+
"time for a new topic to propagate throughout the cluster to all "
|
|
476
|
+
"brokers. "
|
|
477
|
+
"If a client requests topic metadata after manual topic creation but "
|
|
478
|
+
"before the topic has been fully propagated to the broker the "
|
|
479
|
+
"client is requesting metadata from, the topic will seem to be "
|
|
480
|
+
"non-existent and the client will mark the topic as such, "
|
|
481
|
+
"failing queued produced messages with `ERR__UNKNOWN_TOPIC`. "
|
|
482
|
+
"This setting delays marking a topic as non-existent until the "
|
|
483
|
+
"configured propagation max time has passed. "
|
|
484
|
+
"The maximum propagation time is calculated from the time the "
|
|
485
|
+
"topic is first referenced in the client, e.g., on produce().",
|
|
486
|
+
0, 60 * 60 * 1000, 30 * 1000},
|
|
487
|
+
{_RK_GLOBAL, "topic.blacklist", _RK_C_PATLIST, _RK(topic_blacklist),
|
|
488
|
+
"Topic blacklist, a comma-separated list of regular expressions "
|
|
489
|
+
"for matching topic names that should be ignored in "
|
|
490
|
+
"broker metadata information as if the topics did not exist."},
|
|
491
|
+
{_RK_GLOBAL | _RK_MED, "debug", _RK_C_S2F, _RK(debug),
|
|
492
|
+
"A comma-separated list of debug contexts to enable. "
|
|
493
|
+
"Detailed Producer debugging: broker,topic,msg. "
|
|
494
|
+
"Consumer: consumer,cgrp,topic,fetch",
|
|
495
|
+
.s2i = {{RD_KAFKA_DBG_GENERIC, "generic"},
|
|
496
|
+
{RD_KAFKA_DBG_BROKER, "broker"},
|
|
497
|
+
{RD_KAFKA_DBG_TOPIC, "topic"},
|
|
498
|
+
{RD_KAFKA_DBG_METADATA, "metadata"},
|
|
499
|
+
{RD_KAFKA_DBG_FEATURE, "feature"},
|
|
500
|
+
{RD_KAFKA_DBG_QUEUE, "queue"},
|
|
501
|
+
{RD_KAFKA_DBG_MSG, "msg"},
|
|
502
|
+
{RD_KAFKA_DBG_PROTOCOL, "protocol"},
|
|
503
|
+
{RD_KAFKA_DBG_CGRP, "cgrp"},
|
|
504
|
+
{RD_KAFKA_DBG_SECURITY, "security"},
|
|
505
|
+
{RD_KAFKA_DBG_FETCH, "fetch"},
|
|
506
|
+
{RD_KAFKA_DBG_INTERCEPTOR, "interceptor"},
|
|
507
|
+
{RD_KAFKA_DBG_PLUGIN, "plugin"},
|
|
508
|
+
{RD_KAFKA_DBG_CONSUMER, "consumer"},
|
|
509
|
+
{RD_KAFKA_DBG_ADMIN, "admin"},
|
|
510
|
+
{RD_KAFKA_DBG_EOS, "eos"},
|
|
511
|
+
{RD_KAFKA_DBG_MOCK, "mock"},
|
|
512
|
+
{RD_KAFKA_DBG_ASSIGNOR, "assignor"},
|
|
513
|
+
{RD_KAFKA_DBG_CONF, "conf"},
|
|
514
|
+
{RD_KAFKA_DBG_TELEMETRY, "telemetry"},
|
|
515
|
+
{RD_KAFKA_DBG_ALL, "all"}}},
|
|
516
|
+
{_RK_GLOBAL, "socket.timeout.ms", _RK_C_INT, _RK(socket_timeout_ms),
|
|
517
|
+
"Default timeout for network requests. "
|
|
518
|
+
"Producer: ProduceRequests will use the lesser value of "
|
|
519
|
+
"`socket.timeout.ms` and remaining `message.timeout.ms` for the "
|
|
520
|
+
"first message in the batch. "
|
|
521
|
+
"Consumer: FetchRequests will use "
|
|
522
|
+
"`fetch.wait.max.ms` + `socket.timeout.ms`. "
|
|
523
|
+
"Admin: Admin requests will use `socket.timeout.ms` or explicitly "
|
|
524
|
+
"set `rd_kafka_AdminOptions_set_operation_timeout()` value.",
|
|
525
|
+
10, 300 * 1000, 60 * 1000},
|
|
526
|
+
{_RK_GLOBAL | _RK_DEPRECATED, "socket.blocking.max.ms", _RK_C_INT,
|
|
527
|
+
_RK(socket_blocking_max_ms), "No longer used.", 1, 60 * 1000, 1000},
|
|
528
|
+
{_RK_GLOBAL, "socket.send.buffer.bytes", _RK_C_INT, _RK(socket_sndbuf_size),
|
|
529
|
+
"Broker socket send buffer size. System default is used if 0.", 0,
|
|
530
|
+
100000000, 0},
|
|
531
|
+
{_RK_GLOBAL, "socket.receive.buffer.bytes", _RK_C_INT,
|
|
532
|
+
_RK(socket_rcvbuf_size),
|
|
533
|
+
"Broker socket receive buffer size. System default is used if 0.", 0,
|
|
534
|
+
100000000, 0},
|
|
535
|
+
{_RK_GLOBAL, "socket.keepalive.enable", _RK_C_BOOL, _RK(socket_keepalive),
|
|
536
|
+
"Enable TCP keep-alives (SO_KEEPALIVE) on broker sockets", 0, 1, 0
|
|
537
|
+
#ifndef SO_KEEPALIVE
|
|
538
|
+
,
|
|
539
|
+
.unsupported = "SO_KEEPALIVE not available at build time"
|
|
540
|
+
#endif
|
|
541
|
+
},
|
|
542
|
+
{_RK_GLOBAL, "socket.nagle.disable", _RK_C_BOOL, _RK(socket_nagle_disable),
|
|
543
|
+
"Disable the Nagle algorithm (TCP_NODELAY) on broker sockets.", 0, 1, 0
|
|
544
|
+
#ifndef TCP_NODELAY
|
|
545
|
+
,
|
|
546
|
+
.unsupported = "TCP_NODELAY not available at build time"
|
|
547
|
+
#endif
|
|
548
|
+
},
|
|
549
|
+
{_RK_GLOBAL, "socket.max.fails", _RK_C_INT, _RK(socket_max_fails),
|
|
550
|
+
"Disconnect from broker when this number of send failures "
|
|
551
|
+
"(e.g., timed out requests) is reached. Disable with 0. "
|
|
552
|
+
"WARNING: It is highly recommended to leave this setting at "
|
|
553
|
+
"its default value of 1 to avoid the client and broker to "
|
|
554
|
+
"become desynchronized in case of request timeouts. "
|
|
555
|
+
"NOTE: The connection is automatically re-established.",
|
|
556
|
+
0, 1000000, 1},
|
|
557
|
+
{_RK_GLOBAL, "broker.address.ttl", _RK_C_INT, _RK(broker_addr_ttl),
|
|
558
|
+
"How long to cache the broker address resolving "
|
|
559
|
+
"results (milliseconds).",
|
|
560
|
+
0, 86400 * 1000, 1 * 1000},
|
|
561
|
+
{_RK_GLOBAL, "broker.address.family", _RK_C_S2I, _RK(broker_addr_family),
|
|
562
|
+
"Allowed broker IP address families: any, v4, v6", .vdef = AF_UNSPEC,
|
|
563
|
+
.s2i =
|
|
564
|
+
{
|
|
565
|
+
{AF_UNSPEC, "any"},
|
|
566
|
+
{AF_INET, "v4"},
|
|
567
|
+
{AF_INET6, "v6"},
|
|
568
|
+
}},
|
|
569
|
+
{_RK_GLOBAL | _RK_MED, "socket.connection.setup.timeout.ms", _RK_C_INT,
|
|
570
|
+
_RK(socket_connection_setup_timeout_ms),
|
|
571
|
+
"Maximum time allowed for broker connection setup "
|
|
572
|
+
"(TCP connection setup as well SSL and SASL handshake). "
|
|
573
|
+
"If the connection to the broker is not fully functional after this "
|
|
574
|
+
"the connection will be closed and retried.",
|
|
575
|
+
1000, INT_MAX, 30 * 1000 /* 30s */},
|
|
576
|
+
{_RK_GLOBAL | _RK_MED, "connections.max.idle.ms", _RK_C_INT,
|
|
577
|
+
_RK(connections_max_idle_ms),
|
|
578
|
+
"Close broker connections after the specified time of "
|
|
579
|
+
"inactivity. "
|
|
580
|
+
"Disable with 0. "
|
|
581
|
+
"If this property is left at its default value some heuristics are "
|
|
582
|
+
"performed to determine a suitable default value, this is currently "
|
|
583
|
+
"limited to identifying brokers on Azure "
|
|
584
|
+
"(see librdkafka issue #3109 for more info).",
|
|
585
|
+
0, INT_MAX, 0},
|
|
586
|
+
{_RK_GLOBAL | _RK_MED | _RK_HIDDEN, "enable.sparse.connections", _RK_C_BOOL,
|
|
587
|
+
_RK(sparse_connections),
|
|
588
|
+
"When enabled the client will only connect to brokers "
|
|
589
|
+
"it needs to communicate with. When disabled the client "
|
|
590
|
+
"will maintain connections to all brokers in the cluster.",
|
|
591
|
+
0, 1, 1},
|
|
592
|
+
{_RK_GLOBAL | _RK_DEPRECATED, "reconnect.backoff.jitter.ms", _RK_C_INT,
|
|
593
|
+
_RK(reconnect_jitter_ms),
|
|
594
|
+
"No longer used. See `reconnect.backoff.ms` and "
|
|
595
|
+
"`reconnect.backoff.max.ms`.",
|
|
596
|
+
0, 60 * 60 * 1000, 0},
|
|
597
|
+
{_RK_GLOBAL | _RK_MED, "reconnect.backoff.ms", _RK_C_INT,
|
|
598
|
+
_RK(reconnect_backoff_ms),
|
|
599
|
+
"The initial time to wait before reconnecting to a broker "
|
|
600
|
+
"after the connection has been closed. "
|
|
601
|
+
"The time is increased exponentially until "
|
|
602
|
+
"`reconnect.backoff.max.ms` is reached. "
|
|
603
|
+
"-25% to +50% jitter is applied to each reconnect backoff. "
|
|
604
|
+
"A value of 0 disables the backoff and reconnects immediately.",
|
|
605
|
+
0, 60 * 60 * 1000, 100},
|
|
606
|
+
{_RK_GLOBAL | _RK_MED, "reconnect.backoff.max.ms", _RK_C_INT,
|
|
607
|
+
_RK(reconnect_backoff_max_ms),
|
|
608
|
+
"The maximum time to wait before reconnecting to a broker "
|
|
609
|
+
"after the connection has been closed.",
|
|
610
|
+
0, 60 * 60 * 1000, 10 * 1000},
|
|
611
|
+
{_RK_GLOBAL | _RK_HIGH, "statistics.interval.ms", _RK_C_INT,
|
|
612
|
+
_RK(stats_interval_ms),
|
|
613
|
+
"librdkafka statistics emit interval. The application also needs to "
|
|
614
|
+
"register a stats callback using `rd_kafka_conf_set_stats_cb()`. "
|
|
615
|
+
"The granularity is 1000ms. A value of 0 disables statistics.",
|
|
616
|
+
0, 86400 * 1000, 0},
|
|
617
|
+
{_RK_GLOBAL, "enabled_events", _RK_C_INT, _RK(enabled_events),
|
|
618
|
+
"See `rd_kafka_conf_set_events()`", 0, 0x7fffffff, 0},
|
|
619
|
+
{_RK_GLOBAL, "error_cb", _RK_C_PTR, _RK(error_cb),
|
|
620
|
+
"Error callback (set with rd_kafka_conf_set_error_cb())"},
|
|
621
|
+
{_RK_GLOBAL, "throttle_cb", _RK_C_PTR, _RK(throttle_cb),
|
|
622
|
+
"Throttle callback (set with rd_kafka_conf_set_throttle_cb())"},
|
|
623
|
+
{_RK_GLOBAL, "stats_cb", _RK_C_PTR, _RK(stats_cb),
|
|
624
|
+
"Statistics callback (set with rd_kafka_conf_set_stats_cb())"},
|
|
625
|
+
{_RK_GLOBAL, "log_cb", _RK_C_PTR, _RK(log_cb),
|
|
626
|
+
"Log callback (set with rd_kafka_conf_set_log_cb())",
|
|
627
|
+
.pdef = rd_kafka_log_print},
|
|
628
|
+
{_RK_GLOBAL, "log_level", _RK_C_INT, _RK(log_level),
|
|
629
|
+
"Logging level (syslog(3) levels)", 0, 7, 6},
|
|
630
|
+
{_RK_GLOBAL, "log.queue", _RK_C_BOOL, _RK(log_queue),
|
|
631
|
+
"Disable spontaneous log_cb from internal librdkafka "
|
|
632
|
+
"threads, instead enqueue log messages on queue set with "
|
|
633
|
+
"`rd_kafka_set_log_queue()` and serve log callbacks or "
|
|
634
|
+
"events through the standard poll APIs. "
|
|
635
|
+
"**NOTE**: Log messages will linger in a temporary queue "
|
|
636
|
+
"until the log queue has been set.",
|
|
637
|
+
0, 1, 0},
|
|
638
|
+
{_RK_GLOBAL, "log.thread.name", _RK_C_BOOL, _RK(log_thread_name),
|
|
639
|
+
"Print internal thread name in log messages "
|
|
640
|
+
"(useful for debugging librdkafka internals)",
|
|
641
|
+
0, 1, 1},
|
|
642
|
+
{_RK_GLOBAL, "enable.random.seed", _RK_C_BOOL, _RK(enable_random_seed),
|
|
643
|
+
"If enabled librdkafka will initialize the PRNG "
|
|
644
|
+
"with srand(current_time.milliseconds) on the first invocation of "
|
|
645
|
+
"rd_kafka_new() (required only if rand_r() is not available on your "
|
|
646
|
+
"platform). "
|
|
647
|
+
"If disabled the application must call srand() prior to calling "
|
|
648
|
+
"rd_kafka_new().",
|
|
649
|
+
0, 1, 1},
|
|
650
|
+
{_RK_GLOBAL, "log.connection.close", _RK_C_BOOL, _RK(log_connection_close),
|
|
651
|
+
"Log broker disconnects. "
|
|
652
|
+
"It might be useful to turn this off when interacting with "
|
|
653
|
+
"0.9 brokers with an aggressive `connections.max.idle.ms` value.",
|
|
654
|
+
0, 1, 1},
|
|
655
|
+
{_RK_GLOBAL, "background_event_cb", _RK_C_PTR, _RK(background_event_cb),
|
|
656
|
+
"Background queue event callback "
|
|
657
|
+
"(set with rd_kafka_conf_set_background_event_cb())"},
|
|
658
|
+
{_RK_GLOBAL, "socket_cb", _RK_C_PTR, _RK(socket_cb),
|
|
659
|
+
"Socket creation callback to provide race-free CLOEXEC",
|
|
660
|
+
.pdef =
|
|
661
|
+
#ifdef __linux__
|
|
662
|
+
rd_kafka_socket_cb_linux
|
|
663
|
+
#else
|
|
664
|
+
rd_kafka_socket_cb_generic
|
|
665
|
+
#endif
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
_RK_GLOBAL,
|
|
669
|
+
"connect_cb",
|
|
670
|
+
_RK_C_PTR,
|
|
671
|
+
_RK(connect_cb),
|
|
672
|
+
"Socket connect callback",
|
|
673
|
+
},
|
|
674
|
+
{
|
|
675
|
+
_RK_GLOBAL,
|
|
676
|
+
"closesocket_cb",
|
|
677
|
+
_RK_C_PTR,
|
|
678
|
+
_RK(closesocket_cb),
|
|
679
|
+
"Socket close callback",
|
|
680
|
+
},
|
|
681
|
+
{_RK_GLOBAL, "open_cb", _RK_C_PTR, _RK(open_cb),
|
|
682
|
+
"File open callback to provide race-free CLOEXEC",
|
|
683
|
+
.pdef =
|
|
684
|
+
#ifdef __linux__
|
|
685
|
+
rd_kafka_open_cb_linux
|
|
686
|
+
#else
|
|
687
|
+
rd_kafka_open_cb_generic
|
|
688
|
+
#endif
|
|
689
|
+
},
|
|
690
|
+
{_RK_GLOBAL, "resolve_cb", _RK_C_PTR, _RK(resolve_cb),
|
|
691
|
+
"Address resolution callback (set with rd_kafka_conf_set_resolve_cb())."},
|
|
692
|
+
{_RK_GLOBAL, "opaque", _RK_C_PTR, _RK(opaque),
|
|
693
|
+
"Application opaque (set with rd_kafka_conf_set_opaque())"},
|
|
694
|
+
{_RK_GLOBAL, "default_topic_conf", _RK_C_PTR, _RK(topic_conf),
|
|
695
|
+
"Default topic configuration for automatically subscribed topics"},
|
|
696
|
+
{_RK_GLOBAL, "internal.termination.signal", _RK_C_INT, _RK(term_sig),
|
|
697
|
+
"Signal that librdkafka will use to quickly terminate on "
|
|
698
|
+
"rd_kafka_destroy(). If this signal is not set then there will be a "
|
|
699
|
+
"delay before rd_kafka_wait_destroyed() returns true "
|
|
700
|
+
"as internal threads are timing out their system calls. "
|
|
701
|
+
"If this signal is set however the delay will be minimal. "
|
|
702
|
+
"The application should mask this signal as an internal "
|
|
703
|
+
"signal handler is installed.",
|
|
704
|
+
0, 128, 0},
|
|
705
|
+
{_RK_GLOBAL | _RK_HIGH, "api.version.request", _RK_C_BOOL,
|
|
706
|
+
_RK(api_version_request),
|
|
707
|
+
"Request broker's supported API versions to adjust functionality to "
|
|
708
|
+
"available protocol features. If set to false, or the "
|
|
709
|
+
"ApiVersionRequest fails, the fallback version "
|
|
710
|
+
"`broker.version.fallback` will be used. "
|
|
711
|
+
"**NOTE**: Depends on broker version >=0.10.0. If the request is not "
|
|
712
|
+
"supported by (an older) broker the `broker.version.fallback` fallback is "
|
|
713
|
+
"used.",
|
|
714
|
+
0, 1, 1},
|
|
715
|
+
{_RK_GLOBAL, "api.version.request.timeout.ms", _RK_C_INT,
|
|
716
|
+
_RK(api_version_request_timeout_ms),
|
|
717
|
+
"Timeout for broker API version requests.", 1, 5 * 60 * 1000, 10 * 1000},
|
|
718
|
+
{_RK_GLOBAL | _RK_MED, "api.version.fallback.ms", _RK_C_INT,
|
|
719
|
+
_RK(api_version_fallback_ms),
|
|
720
|
+
"Dictates how long the `broker.version.fallback` fallback is used "
|
|
721
|
+
"in the case the ApiVersionRequest fails. "
|
|
722
|
+
"**NOTE**: The ApiVersionRequest is only issued when a new connection "
|
|
723
|
+
"to the broker is made (such as after an upgrade).",
|
|
724
|
+
0, 86400 * 7 * 1000, 0},
|
|
725
|
+
|
|
726
|
+
{_RK_GLOBAL | _RK_MED, "broker.version.fallback", _RK_C_STR,
|
|
727
|
+
_RK(broker_version_fallback),
|
|
728
|
+
"Older broker versions (before 0.10.0) provide no way for a client to "
|
|
729
|
+
"query "
|
|
730
|
+
"for supported protocol features "
|
|
731
|
+
"(ApiVersionRequest, see `api.version.request`) making it impossible "
|
|
732
|
+
"for the client to know what features it may use. "
|
|
733
|
+
"As a workaround a user may set this property to the expected broker "
|
|
734
|
+
"version and the client will automatically adjust its feature set "
|
|
735
|
+
"accordingly if the ApiVersionRequest fails (or is disabled). "
|
|
736
|
+
"The fallback broker version will be used for `api.version.fallback.ms`. "
|
|
737
|
+
"Valid values are: 0.9.0, 0.8.2, 0.8.1, 0.8.0. "
|
|
738
|
+
"Any other value >= 0.10, such as 0.10.2.1, "
|
|
739
|
+
"enables ApiVersionRequests.",
|
|
740
|
+
.sdef = "0.10.0", .validate = rd_kafka_conf_validate_broker_version},
|
|
741
|
+
{_RK_GLOBAL, "allow.auto.create.topics", _RK_C_BOOL,
|
|
742
|
+
_RK(allow_auto_create_topics),
|
|
743
|
+
"Allow automatic topic creation on the broker when subscribing to "
|
|
744
|
+
"or assigning non-existent topics. "
|
|
745
|
+
"The broker must also be configured with "
|
|
746
|
+
"`auto.create.topics.enable=true` for this configuration to "
|
|
747
|
+
"take effect. "
|
|
748
|
+
"Note: the default value (true) for the producer is "
|
|
749
|
+
"different from the default value (false) for the consumer. "
|
|
750
|
+
"Further, the consumer default value is different from the Java "
|
|
751
|
+
"consumer (true), and this property is not supported by the Java "
|
|
752
|
+
"producer. Requires broker version >= 0.11.0.0, for older broker "
|
|
753
|
+
"versions only the broker configuration applies.",
|
|
754
|
+
0, 1, 0},
|
|
755
|
+
|
|
756
|
+
/* Security related global properties */
|
|
757
|
+
{_RK_GLOBAL | _RK_HIGH, "security.protocol", _RK_C_S2I,
|
|
758
|
+
_RK(security_protocol), "Protocol used to communicate with brokers.",
|
|
759
|
+
.vdef = RD_KAFKA_PROTO_PLAINTEXT,
|
|
760
|
+
.s2i = {{RD_KAFKA_PROTO_PLAINTEXT, "plaintext"},
|
|
761
|
+
{RD_KAFKA_PROTO_SSL, "ssl", _UNSUPPORTED_SSL},
|
|
762
|
+
{RD_KAFKA_PROTO_SASL_PLAINTEXT, "sasl_plaintext"},
|
|
763
|
+
{RD_KAFKA_PROTO_SASL_SSL, "sasl_ssl", _UNSUPPORTED_SSL},
|
|
764
|
+
{0, NULL}}},
|
|
765
|
+
|
|
766
|
+
{_RK_GLOBAL, "ssl.cipher.suites", _RK_C_STR, _RK(ssl.cipher_suites),
|
|
767
|
+
"A cipher suite is a named combination of authentication, "
|
|
768
|
+
"encryption, MAC and key exchange algorithm used to negotiate the "
|
|
769
|
+
"security settings for a network connection using TLS or SSL network "
|
|
770
|
+
"protocol. See manual page for `ciphers(1)` and "
|
|
771
|
+
"`SSL_CTX_set_cipher_list(3).",
|
|
772
|
+
_UNSUPPORTED_SSL},
|
|
773
|
+
{_RK_GLOBAL, "ssl.curves.list", _RK_C_STR, _RK(ssl.curves_list),
|
|
774
|
+
"The supported-curves extension in the TLS ClientHello message specifies "
|
|
775
|
+
"the curves (standard/named, or 'explicit' GF(2^k) or GF(p)) the client "
|
|
776
|
+
"is willing to have the server use. See manual page for "
|
|
777
|
+
"`SSL_CTX_set1_curves_list(3)`. OpenSSL >= 1.0.2 required.",
|
|
778
|
+
_UNSUPPORTED_OPENSSL_1_0_2},
|
|
779
|
+
{_RK_GLOBAL, "ssl.sigalgs.list", _RK_C_STR, _RK(ssl.sigalgs_list),
|
|
780
|
+
"The client uses the TLS ClientHello signature_algorithms extension "
|
|
781
|
+
"to indicate to the server which signature/hash algorithm pairs "
|
|
782
|
+
"may be used in digital signatures. See manual page for "
|
|
783
|
+
"`SSL_CTX_set1_sigalgs_list(3)`. OpenSSL >= 1.0.2 required.",
|
|
784
|
+
_UNSUPPORTED_OPENSSL_1_0_2},
|
|
785
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "ssl.key.location", _RK_C_STR,
|
|
786
|
+
_RK(ssl.key_location),
|
|
787
|
+
"Path to client's private key (PEM) used for authentication.",
|
|
788
|
+
_UNSUPPORTED_SSL},
|
|
789
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "ssl.key.password", _RK_C_STR,
|
|
790
|
+
_RK(ssl.key_password),
|
|
791
|
+
"Private key passphrase (for use with `ssl.key.location` "
|
|
792
|
+
"and `set_ssl_cert()`)",
|
|
793
|
+
_UNSUPPORTED_SSL},
|
|
794
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "ssl.key.pem", _RK_C_STR, _RK(ssl.key_pem),
|
|
795
|
+
"Client's private key string (PEM format) used for authentication.",
|
|
796
|
+
_UNSUPPORTED_SSL},
|
|
797
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "ssl_key", _RK_C_INTERNAL, _RK(ssl.key),
|
|
798
|
+
"Client's private key as set by rd_kafka_conf_set_ssl_cert()",
|
|
799
|
+
.dtor = rd_kafka_conf_cert_dtor, .copy = rd_kafka_conf_cert_copy,
|
|
800
|
+
_UNSUPPORTED_SSL},
|
|
801
|
+
{_RK_GLOBAL, "ssl.certificate.location", _RK_C_STR, _RK(ssl.cert_location),
|
|
802
|
+
"Path to client's public key (PEM) used for authentication.",
|
|
803
|
+
_UNSUPPORTED_SSL},
|
|
804
|
+
{_RK_GLOBAL, "ssl.certificate.pem", _RK_C_STR, _RK(ssl.cert_pem),
|
|
805
|
+
"Client's public key string (PEM format) used for authentication.",
|
|
806
|
+
_UNSUPPORTED_SSL},
|
|
807
|
+
{_RK_GLOBAL, "ssl_certificate", _RK_C_INTERNAL, _RK(ssl.key),
|
|
808
|
+
"Client's public key as set by rd_kafka_conf_set_ssl_cert()",
|
|
809
|
+
.dtor = rd_kafka_conf_cert_dtor, .copy = rd_kafka_conf_cert_copy,
|
|
810
|
+
_UNSUPPORTED_SSL},
|
|
811
|
+
|
|
812
|
+
{_RK_GLOBAL, "ssl.ca.location", _RK_C_STR, _RK(ssl.ca_location),
|
|
813
|
+
"File or directory path to CA certificate(s) for verifying "
|
|
814
|
+
"the broker's key. "
|
|
815
|
+
"Defaults: "
|
|
816
|
+
"On Windows the system's CA certificates are automatically looked "
|
|
817
|
+
"up in the Windows Root certificate store. "
|
|
818
|
+
"On Mac OSX this configuration defaults to `probe`. "
|
|
819
|
+
"It is recommended to install openssl using Homebrew, "
|
|
820
|
+
"to provide CA certificates. "
|
|
821
|
+
"On Linux install the distribution's ca-certificates package. "
|
|
822
|
+
"If OpenSSL is statically linked or `ssl.ca.location` is set to "
|
|
823
|
+
"`probe` a list of standard paths will be probed and the first one "
|
|
824
|
+
"found will be used as the default CA certificate location path. "
|
|
825
|
+
"If OpenSSL is dynamically linked the OpenSSL library's default "
|
|
826
|
+
"path will be used (see `OPENSSLDIR` in `openssl version -a`).",
|
|
827
|
+
_UNSUPPORTED_SSL},
|
|
828
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "ssl.ca.pem", _RK_C_STR, _RK(ssl.ca_pem),
|
|
829
|
+
"CA certificate string (PEM format) for verifying the broker's key.",
|
|
830
|
+
_UNSUPPORTED_SSL},
|
|
831
|
+
{_RK_GLOBAL, "ssl_ca", _RK_C_INTERNAL, _RK(ssl.ca),
|
|
832
|
+
"CA certificate as set by rd_kafka_conf_set_ssl_cert()",
|
|
833
|
+
.dtor = rd_kafka_conf_cert_dtor, .copy = rd_kafka_conf_cert_copy,
|
|
834
|
+
_UNSUPPORTED_SSL},
|
|
835
|
+
{_RK_GLOBAL, "ssl.ca.certificate.stores", _RK_C_STR,
|
|
836
|
+
_RK(ssl.ca_cert_stores),
|
|
837
|
+
"Comma-separated list of Windows Certificate stores to load "
|
|
838
|
+
"CA certificates from. Certificates will be loaded in the same "
|
|
839
|
+
"order as stores are specified. If no certificates can be loaded "
|
|
840
|
+
"from any of the specified stores an error is logged and the "
|
|
841
|
+
"OpenSSL library's default CA location is used instead. "
|
|
842
|
+
"Store names are typically one or more of: MY, Root, Trust, CA.",
|
|
843
|
+
.sdef = "Root",
|
|
844
|
+
#if !defined(_WIN32)
|
|
845
|
+
.unsupported = "configuration only valid on Windows"
|
|
846
|
+
#endif
|
|
847
|
+
},
|
|
848
|
+
|
|
849
|
+
{_RK_GLOBAL, "ssl.crl.location", _RK_C_STR, _RK(ssl.crl_location),
|
|
850
|
+
"Path to CRL for verifying broker's certificate validity.",
|
|
851
|
+
_UNSUPPORTED_SSL},
|
|
852
|
+
{_RK_GLOBAL, "ssl.keystore.location", _RK_C_STR, _RK(ssl.keystore_location),
|
|
853
|
+
"Path to client's keystore (PKCS#12) used for authentication.",
|
|
854
|
+
_UNSUPPORTED_SSL},
|
|
855
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "ssl.keystore.password", _RK_C_STR,
|
|
856
|
+
_RK(ssl.keystore_password), "Client's keystore (PKCS#12) password.",
|
|
857
|
+
_UNSUPPORTED_SSL},
|
|
858
|
+
{_RK_GLOBAL, "ssl.providers", _RK_C_STR, _RK(ssl.providers),
|
|
859
|
+
"Comma-separated list of OpenSSL 3.0.x implementation providers. "
|
|
860
|
+
"E.g., \"default,legacy\".",
|
|
861
|
+
_UNSUPPORTED_SSL_3},
|
|
862
|
+
{_RK_GLOBAL | _RK_DEPRECATED, "ssl.engine.location", _RK_C_STR,
|
|
863
|
+
_RK(ssl.engine_location),
|
|
864
|
+
"Path to OpenSSL engine library. OpenSSL >= 1.1.x required. "
|
|
865
|
+
"DEPRECATED: OpenSSL engine support is deprecated and should be "
|
|
866
|
+
"replaced by OpenSSL 3 providers.",
|
|
867
|
+
_UNSUPPORTED_SSL_ENGINE},
|
|
868
|
+
{_RK_GLOBAL, "ssl.engine.id", _RK_C_STR, _RK(ssl.engine_id),
|
|
869
|
+
"OpenSSL engine id is the name used for loading engine.",
|
|
870
|
+
.sdef = "dynamic", _UNSUPPORTED_SSL_ENGINE},
|
|
871
|
+
{_RK_GLOBAL, "ssl_engine_callback_data", _RK_C_PTR,
|
|
872
|
+
_RK(ssl.engine_callback_data),
|
|
873
|
+
"OpenSSL engine callback data (set "
|
|
874
|
+
"with rd_kafka_conf_set_engine_callback_data()).",
|
|
875
|
+
_UNSUPPORTED_SSL_ENGINE},
|
|
876
|
+
{_RK_GLOBAL, "enable.ssl.certificate.verification", _RK_C_BOOL,
|
|
877
|
+
_RK(ssl.enable_verify),
|
|
878
|
+
"Enable OpenSSL's builtin broker (server) certificate verification. "
|
|
879
|
+
"This verification can be extended by the application by "
|
|
880
|
+
"implementing a certificate_verify_cb.",
|
|
881
|
+
0, 1, 1, _UNSUPPORTED_SSL},
|
|
882
|
+
{_RK_GLOBAL, "ssl.endpoint.identification.algorithm", _RK_C_S2I,
|
|
883
|
+
_RK(ssl.endpoint_identification),
|
|
884
|
+
"Endpoint identification algorithm to validate broker "
|
|
885
|
+
"hostname using broker certificate. "
|
|
886
|
+
"https - Server (broker) hostname verification as "
|
|
887
|
+
"specified in RFC2818. "
|
|
888
|
+
"none - No endpoint verification. "
|
|
889
|
+
"OpenSSL >= 1.0.2 required.",
|
|
890
|
+
.vdef = RD_KAFKA_SSL_ENDPOINT_ID_HTTPS,
|
|
891
|
+
.s2i = {{RD_KAFKA_SSL_ENDPOINT_ID_NONE, "none"},
|
|
892
|
+
{RD_KAFKA_SSL_ENDPOINT_ID_HTTPS, "https"}},
|
|
893
|
+
_UNSUPPORTED_OPENSSL_1_0_2},
|
|
894
|
+
{_RK_GLOBAL, "ssl.certificate.verify_cb", _RK_C_PTR,
|
|
895
|
+
_RK(ssl.cert_verify_cb),
|
|
896
|
+
"Callback to verify the broker certificate chain.", _UNSUPPORTED_SSL},
|
|
897
|
+
|
|
898
|
+
/* Point user in the right direction if they try to apply
|
|
899
|
+
* Java client SSL / JAAS properties. */
|
|
900
|
+
{_RK_GLOBAL, "ssl.truststore.location", _RK_C_INVALID, _RK(dummy),
|
|
901
|
+
"Java TrustStores are not supported, use `ssl.ca.location` "
|
|
902
|
+
"and a certificate file instead. "
|
|
903
|
+
"See "
|
|
904
|
+
"https://github.com/confluentinc/librdkafka/"
|
|
905
|
+
"wiki/Using-SSL-with-librdkafka "
|
|
906
|
+
"for more information."},
|
|
907
|
+
{_RK_GLOBAL, "sasl.jaas.config", _RK_C_INVALID, _RK(dummy),
|
|
908
|
+
"Java JAAS configuration is not supported, see "
|
|
909
|
+
"https://github.com/confluentinc/librdkafka/"
|
|
910
|
+
"wiki/Using-SASL-with-librdkafka "
|
|
911
|
+
"for more information."},
|
|
912
|
+
|
|
913
|
+
{_RK_GLOBAL | _RK_HIGH, "sasl.mechanisms", _RK_C_STR, _RK(sasl.mechanisms),
|
|
914
|
+
"SASL mechanism to use for authentication. "
|
|
915
|
+
"Supported: GSSAPI, PLAIN, SCRAM-SHA-256, SCRAM-SHA-512, OAUTHBEARER. "
|
|
916
|
+
"**NOTE**: Despite the name only one mechanism must be configured.",
|
|
917
|
+
.sdef = "GSSAPI", .validate = rd_kafka_conf_validate_single},
|
|
918
|
+
{_RK_GLOBAL | _RK_HIGH, "sasl.mechanism", _RK_C_ALIAS,
|
|
919
|
+
.sdef = "sasl.mechanisms"},
|
|
920
|
+
{_RK_GLOBAL, "sasl.kerberos.service.name", _RK_C_STR,
|
|
921
|
+
_RK(sasl.service_name),
|
|
922
|
+
"Kerberos principal name that Kafka runs as, "
|
|
923
|
+
"not including /hostname@REALM",
|
|
924
|
+
.sdef = "kafka"},
|
|
925
|
+
{_RK_GLOBAL, "sasl.kerberos.principal", _RK_C_STR, _RK(sasl.principal),
|
|
926
|
+
"This client's Kerberos principal name. "
|
|
927
|
+
"(Not supported on Windows, will use the logon user's principal).",
|
|
928
|
+
.sdef = "kafkaclient"},
|
|
929
|
+
{_RK_GLOBAL, "sasl.kerberos.kinit.cmd", _RK_C_STR, _RK(sasl.kinit_cmd),
|
|
930
|
+
"Shell command to refresh or acquire the client's Kerberos ticket. "
|
|
931
|
+
"This command is executed on client creation and every "
|
|
932
|
+
"sasl.kerberos.min.time.before.relogin (0=disable). "
|
|
933
|
+
"%{config.prop.name} is replaced by corresponding config "
|
|
934
|
+
"object value.",
|
|
935
|
+
.sdef =
|
|
936
|
+
/* First attempt to refresh, else acquire. */
|
|
937
|
+
"kinit -R -t \"%{sasl.kerberos.keytab}\" "
|
|
938
|
+
"-k %{sasl.kerberos.principal} || "
|
|
939
|
+
"kinit -t \"%{sasl.kerberos.keytab}\" -k %{sasl.kerberos.principal}",
|
|
940
|
+
_UNSUPPORTED_WIN32_GSSAPI},
|
|
941
|
+
{_RK_GLOBAL, "sasl.kerberos.keytab", _RK_C_STR, _RK(sasl.keytab),
|
|
942
|
+
"Path to Kerberos keytab file. "
|
|
943
|
+
"This configuration property is only used as a variable in "
|
|
944
|
+
"`sasl.kerberos.kinit.cmd` as "
|
|
945
|
+
"` ... -t \"%{sasl.kerberos.keytab}\"`.",
|
|
946
|
+
_UNSUPPORTED_WIN32_GSSAPI},
|
|
947
|
+
{_RK_GLOBAL, "sasl.kerberos.min.time.before.relogin", _RK_C_INT,
|
|
948
|
+
_RK(sasl.relogin_min_time),
|
|
949
|
+
"Minimum time in milliseconds between key refresh attempts. "
|
|
950
|
+
"Disable automatic key refresh by setting this property to 0.",
|
|
951
|
+
0, 86400 * 1000, 60 * 1000, _UNSUPPORTED_WIN32_GSSAPI},
|
|
952
|
+
{_RK_GLOBAL | _RK_HIGH | _RK_SENSITIVE, "sasl.username", _RK_C_STR,
|
|
953
|
+
_RK(sasl.username),
|
|
954
|
+
"SASL username for use with the PLAIN and SASL-SCRAM-.. mechanisms"},
|
|
955
|
+
{_RK_GLOBAL | _RK_HIGH | _RK_SENSITIVE, "sasl.password", _RK_C_STR,
|
|
956
|
+
_RK(sasl.password),
|
|
957
|
+
"SASL password for use with the PLAIN and SASL-SCRAM-.. mechanism"},
|
|
958
|
+
{_RK_GLOBAL | _RK_SENSITIVE, "sasl.oauthbearer.config", _RK_C_STR,
|
|
959
|
+
_RK(sasl.oauthbearer_config),
|
|
960
|
+
"SASL/OAUTHBEARER configuration. The format is "
|
|
961
|
+
"implementation-dependent and must be parsed accordingly. The "
|
|
962
|
+
"default unsecured token implementation (see "
|
|
963
|
+
"https://tools.ietf.org/html/rfc7515#appendix-A.5) recognizes "
|
|
964
|
+
"space-separated name=value pairs with valid names including "
|
|
965
|
+
"principalClaimName, principal, scopeClaimName, scope, and "
|
|
966
|
+
"lifeSeconds. The default value for principalClaimName is \"sub\", "
|
|
967
|
+
"the default value for scopeClaimName is \"scope\", and the default "
|
|
968
|
+
"value for lifeSeconds is 3600. The scope value is CSV format with "
|
|
969
|
+
"the default value being no/empty scope. For example: "
|
|
970
|
+
"`principalClaimName=azp principal=admin scopeClaimName=roles "
|
|
971
|
+
"scope=role1,role2 lifeSeconds=600`. In addition, SASL extensions "
|
|
972
|
+
"can be communicated to the broker via "
|
|
973
|
+
"`extension_NAME=value`. For example: "
|
|
974
|
+
"`principal=admin extension_traceId=123`",
|
|
975
|
+
_UNSUPPORTED_OAUTHBEARER},
|
|
976
|
+
{_RK_GLOBAL, "enable.sasl.oauthbearer.unsecure.jwt", _RK_C_BOOL,
|
|
977
|
+
_RK(sasl.enable_oauthbearer_unsecure_jwt),
|
|
978
|
+
"Enable the builtin unsecure JWT OAUTHBEARER token handler "
|
|
979
|
+
"if no oauthbearer_refresh_cb has been set. "
|
|
980
|
+
"This builtin handler should only be used for development "
|
|
981
|
+
"or testing, and not in production.",
|
|
982
|
+
0, 1, 0, _UNSUPPORTED_OAUTHBEARER},
|
|
983
|
+
{_RK_GLOBAL, "oauthbearer_token_refresh_cb", _RK_C_PTR,
|
|
984
|
+
_RK(sasl.oauthbearer.token_refresh_cb),
|
|
985
|
+
"SASL/OAUTHBEARER token refresh callback (set with "
|
|
986
|
+
"rd_kafka_conf_set_oauthbearer_token_refresh_cb(), triggered by "
|
|
987
|
+
"rd_kafka_poll(), et.al. "
|
|
988
|
+
"This callback will be triggered when it is time to refresh "
|
|
989
|
+
"the client's OAUTHBEARER token. "
|
|
990
|
+
"Also see `rd_kafka_conf_enable_sasl_queue()`.",
|
|
991
|
+
_UNSUPPORTED_OAUTHBEARER},
|
|
992
|
+
{
|
|
993
|
+
_RK_GLOBAL | _RK_HIDDEN,
|
|
994
|
+
"enable_sasl_queue",
|
|
995
|
+
_RK_C_BOOL,
|
|
996
|
+
_RK(sasl.enable_callback_queue),
|
|
997
|
+
"Enable the SASL callback queue "
|
|
998
|
+
"(set with rd_kafka_conf_enable_sasl_queue()).",
|
|
999
|
+
0,
|
|
1000
|
+
1,
|
|
1001
|
+
0,
|
|
1002
|
+
},
|
|
1003
|
+
{_RK_GLOBAL, "sasl.oauthbearer.method", _RK_C_S2I,
|
|
1004
|
+
_RK(sasl.oauthbearer.method),
|
|
1005
|
+
"Set to \"default\" or \"oidc\" to control which login method "
|
|
1006
|
+
"to be used. If set to \"oidc\", the following properties must also be "
|
|
1007
|
+
"be specified: "
|
|
1008
|
+
"`sasl.oauthbearer.client.id`, `sasl.oauthbearer.client.secret`, "
|
|
1009
|
+
"and `sasl.oauthbearer.token.endpoint.url`.",
|
|
1010
|
+
.vdef = RD_KAFKA_SASL_OAUTHBEARER_METHOD_DEFAULT,
|
|
1011
|
+
.s2i = {{RD_KAFKA_SASL_OAUTHBEARER_METHOD_DEFAULT, "default"},
|
|
1012
|
+
{RD_KAFKA_SASL_OAUTHBEARER_METHOD_OIDC, "oidc"}},
|
|
1013
|
+
_UNSUPPORTED_OIDC},
|
|
1014
|
+
{_RK_GLOBAL, "sasl.oauthbearer.client.id", _RK_C_STR,
|
|
1015
|
+
_RK(sasl.oauthbearer.client_id),
|
|
1016
|
+
"Public identifier for the application. "
|
|
1017
|
+
"Must be unique across all clients that the "
|
|
1018
|
+
"authorization server handles. "
|
|
1019
|
+
"Only used when `sasl.oauthbearer.method` is set to \"oidc\".",
|
|
1020
|
+
_UNSUPPORTED_OIDC},
|
|
1021
|
+
{_RK_GLOBAL, "sasl.oauthbearer.client.secret", _RK_C_STR,
|
|
1022
|
+
_RK(sasl.oauthbearer.client_secret),
|
|
1023
|
+
"Client secret only known to the application and the "
|
|
1024
|
+
"authorization server. This should be a sufficiently random string "
|
|
1025
|
+
"that is not guessable. "
|
|
1026
|
+
"Only used when `sasl.oauthbearer.method` is set to \"oidc\".",
|
|
1027
|
+
_UNSUPPORTED_OIDC},
|
|
1028
|
+
{_RK_GLOBAL, "sasl.oauthbearer.scope", _RK_C_STR,
|
|
1029
|
+
_RK(sasl.oauthbearer.scope),
|
|
1030
|
+
"Client use this to specify the scope of the access request to the "
|
|
1031
|
+
"broker. "
|
|
1032
|
+
"Only used when `sasl.oauthbearer.method` is set to \"oidc\".",
|
|
1033
|
+
_UNSUPPORTED_OIDC},
|
|
1034
|
+
{_RK_GLOBAL, "sasl.oauthbearer.extensions", _RK_C_STR,
|
|
1035
|
+
_RK(sasl.oauthbearer.extensions_str),
|
|
1036
|
+
"Allow additional information to be provided to the broker. "
|
|
1037
|
+
"Comma-separated list of key=value pairs. "
|
|
1038
|
+
"E.g., \"supportFeatureX=true,organizationId=sales-emea\"."
|
|
1039
|
+
"Only used when `sasl.oauthbearer.method` is set to \"oidc\".",
|
|
1040
|
+
_UNSUPPORTED_OIDC},
|
|
1041
|
+
{_RK_GLOBAL, "sasl.oauthbearer.token.endpoint.url", _RK_C_STR,
|
|
1042
|
+
_RK(sasl.oauthbearer.token_endpoint_url),
|
|
1043
|
+
"OAuth/OIDC issuer token endpoint HTTP(S) URI used to retrieve token. "
|
|
1044
|
+
"Only used when `sasl.oauthbearer.method` is set to \"oidc\".",
|
|
1045
|
+
_UNSUPPORTED_OIDC},
|
|
1046
|
+
|
|
1047
|
+
/* Plugins */
|
|
1048
|
+
{_RK_GLOBAL, "plugin.library.paths", _RK_C_STR, _RK(plugin_paths),
|
|
1049
|
+
"List of plugin libraries to load (; separated). "
|
|
1050
|
+
"The library search path is platform dependent (see dlopen(3) for "
|
|
1051
|
+
"Unix and LoadLibrary() for Windows). If no filename extension is "
|
|
1052
|
+
"specified the platform-specific extension (such as .dll or .so) "
|
|
1053
|
+
"will be appended automatically.",
|
|
1054
|
+
#if WITH_PLUGINS
|
|
1055
|
+
.set = rd_kafka_plugins_conf_set
|
|
1056
|
+
#else
|
|
1057
|
+
.unsupported = "libdl/dlopen(3) not available at build time"
|
|
1058
|
+
#endif
|
|
1059
|
+
},
|
|
1060
|
+
|
|
1061
|
+
/* Interceptors are added through specific API and not exposed
|
|
1062
|
+
* as configuration properties.
|
|
1063
|
+
* The interceptor property must be defined after plugin.library.paths
|
|
1064
|
+
* so that the plugin libraries are properly loaded before
|
|
1065
|
+
* interceptors are configured when duplicating configuration objects.*/
|
|
1066
|
+
{_RK_GLOBAL, "interceptors", _RK_C_INTERNAL, _RK(interceptors),
|
|
1067
|
+
"Interceptors added through rd_kafka_conf_interceptor_add_..() "
|
|
1068
|
+
"and any configuration handled by interceptors.",
|
|
1069
|
+
.ctor = rd_kafka_conf_interceptor_ctor,
|
|
1070
|
+
.dtor = rd_kafka_conf_interceptor_dtor,
|
|
1071
|
+
.copy = rd_kafka_conf_interceptor_copy},
|
|
1072
|
+
|
|
1073
|
+
/* Test mocks. */
|
|
1074
|
+
{_RK_GLOBAL | _RK_HIDDEN, "test.mock.num.brokers", _RK_C_INT,
|
|
1075
|
+
_RK(mock.broker_cnt),
|
|
1076
|
+
"Number of mock brokers to create. "
|
|
1077
|
+
"This will automatically overwrite `bootstrap.servers` with the "
|
|
1078
|
+
"mock broker list.",
|
|
1079
|
+
0, 10000, 0},
|
|
1080
|
+
{_RK_GLOBAL | _RK_HIDDEN, "test.mock.broker.rtt", _RK_C_INT,
|
|
1081
|
+
_RK(mock.broker_rtt), "Simulated mock broker latency in milliseconds.", 0,
|
|
1082
|
+
60 * 60 * 1000 /*1h*/, 0},
|
|
1083
|
+
|
|
1084
|
+
/* Unit test interfaces.
|
|
1085
|
+
* These are not part of the public API and may change at any time.
|
|
1086
|
+
* Only to be used by the librdkafka tests. */
|
|
1087
|
+
{_RK_GLOBAL | _RK_HIDDEN, "ut_handle_ProduceResponse", _RK_C_PTR,
|
|
1088
|
+
_RK(ut.handle_ProduceResponse),
|
|
1089
|
+
"ProduceResponse handler: "
|
|
1090
|
+
"rd_kafka_resp_err_t (*cb) (rd_kafka_t *rk, "
|
|
1091
|
+
"int32_t brokerid, uint64_t msgid, rd_kafka_resp_err_t err)"},
|
|
1092
|
+
|
|
1093
|
+
/* Global consumer group properties */
|
|
1094
|
+
{_RK_GLOBAL | _RK_CGRP | _RK_HIGH, "group.id", _RK_C_STR, _RK(group_id_str),
|
|
1095
|
+
"Client group id string. All clients sharing the same group.id "
|
|
1096
|
+
"belong to the same group."},
|
|
1097
|
+
{_RK_GLOBAL | _RK_CGRP | _RK_MED, "group.instance.id", _RK_C_STR,
|
|
1098
|
+
_RK(group_instance_id),
|
|
1099
|
+
"Enable static group membership. "
|
|
1100
|
+
"Static group members are able to leave and rejoin a group "
|
|
1101
|
+
"within the configured `session.timeout.ms` without prompting a "
|
|
1102
|
+
"group rebalance. This should be used in combination with a larger "
|
|
1103
|
+
"`session.timeout.ms` to avoid group rebalances caused by transient "
|
|
1104
|
+
"unavailability (e.g. process restarts). "
|
|
1105
|
+
"Requires broker version >= 2.3.0."},
|
|
1106
|
+
{_RK_GLOBAL | _RK_CGRP | _RK_MED, "partition.assignment.strategy",
|
|
1107
|
+
_RK_C_STR, _RK(partition_assignment_strategy),
|
|
1108
|
+
"The name of one or more partition assignment strategies. The "
|
|
1109
|
+
"elected group leader will use a strategy supported by all "
|
|
1110
|
+
"members of the group to assign partitions to group members. If "
|
|
1111
|
+
"there is more than one eligible strategy, preference is "
|
|
1112
|
+
"determined by the order of this list (strategies earlier in the "
|
|
1113
|
+
"list have higher priority). "
|
|
1114
|
+
"Cooperative and non-cooperative (eager) strategies must not be "
|
|
1115
|
+
"mixed. "
|
|
1116
|
+
"Available strategies: range, roundrobin, cooperative-sticky.",
|
|
1117
|
+
.sdef = "range,roundrobin"},
|
|
1118
|
+
{_RK_GLOBAL | _RK_CGRP | _RK_HIGH, "session.timeout.ms", _RK_C_INT,
|
|
1119
|
+
_RK(group_session_timeout_ms),
|
|
1120
|
+
"Client group session and failure detection timeout. "
|
|
1121
|
+
"The consumer sends periodic heartbeats (heartbeat.interval.ms) "
|
|
1122
|
+
"to indicate its liveness to the broker. If no hearts are "
|
|
1123
|
+
"received by the broker for a group member within the "
|
|
1124
|
+
"session timeout, the broker will remove the consumer from "
|
|
1125
|
+
"the group and trigger a rebalance. "
|
|
1126
|
+
"The allowed range is configured with the **broker** configuration "
|
|
1127
|
+
"properties `group.min.session.timeout.ms` and "
|
|
1128
|
+
"`group.max.session.timeout.ms`. "
|
|
1129
|
+
"Also see `max.poll.interval.ms`.",
|
|
1130
|
+
1, 3600 * 1000, 45 * 1000},
|
|
1131
|
+
{_RK_GLOBAL | _RK_CGRP, "heartbeat.interval.ms", _RK_C_INT,
|
|
1132
|
+
_RK(group_heartbeat_intvl_ms),
|
|
1133
|
+
"Group session keepalive heartbeat interval.", 1, 3600 * 1000, 3 * 1000},
|
|
1134
|
+
{_RK_GLOBAL | _RK_CGRP, "group.protocol.type", _RK_C_KSTR,
|
|
1135
|
+
_RK(group_protocol_type),
|
|
1136
|
+
"Group protocol type for the `classic` group protocol. NOTE: Currently, "
|
|
1137
|
+
"the only supported group "
|
|
1138
|
+
"protocol type is `consumer`.",
|
|
1139
|
+
.sdef = "consumer"},
|
|
1140
|
+
{_RK_GLOBAL | _RK_CGRP | _RK_HIGH, "group.protocol", _RK_C_S2I,
|
|
1141
|
+
_RK(group_protocol),
|
|
1142
|
+
"Group protocol to use. Use `classic` for the original protocol and "
|
|
1143
|
+
"`consumer` for the new "
|
|
1144
|
+
"protocol introduced in KIP-848. Available protocols: classic or "
|
|
1145
|
+
"consumer. Default is `classic`, "
|
|
1146
|
+
"but will change to `consumer` in next releases.",
|
|
1147
|
+
.vdef = RD_KAFKA_GROUP_PROTOCOL_CLASSIC,
|
|
1148
|
+
.s2i = {{RD_KAFKA_GROUP_PROTOCOL_CLASSIC, "classic"},
|
|
1149
|
+
{RD_KAFKA_GROUP_PROTOCOL_CONSUMER, "consumer"}}},
|
|
1150
|
+
{_RK_GLOBAL | _RK_CGRP | _RK_MED, "group.remote.assignor", _RK_C_STR,
|
|
1151
|
+
_RK(group_remote_assignor),
|
|
1152
|
+
"Server side assignor to use. Keep it null to make server select a "
|
|
1153
|
+
"suitable assignor for the group. "
|
|
1154
|
+
"Available assignors: uniform or range. Default is null",
|
|
1155
|
+
.sdef = NULL},
|
|
1156
|
+
{_RK_GLOBAL | _RK_CGRP, "coordinator.query.interval.ms", _RK_C_INT,
|
|
1157
|
+
_RK(coord_query_intvl_ms),
|
|
1158
|
+
"How often to query for the current client group coordinator. "
|
|
1159
|
+
"If the currently assigned coordinator is down the configured "
|
|
1160
|
+
"query interval will be divided by ten to more quickly recover "
|
|
1161
|
+
"in case of coordinator reassignment.",
|
|
1162
|
+
1, 3600 * 1000, 10 * 60 * 1000},
|
|
1163
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_HIGH, "max.poll.interval.ms", _RK_C_INT,
|
|
1164
|
+
_RK(max_poll_interval_ms),
|
|
1165
|
+
"Maximum allowed time between calls to consume messages "
|
|
1166
|
+
"(e.g., rd_kafka_consumer_poll()) for high-level consumers. "
|
|
1167
|
+
"If this interval is exceeded the consumer is considered failed "
|
|
1168
|
+
"and the group will rebalance in order to reassign the "
|
|
1169
|
+
"partitions to another consumer group member. "
|
|
1170
|
+
"Warning: Offset commits may be not possible at this point. "
|
|
1171
|
+
"Note: It is recommended to set `enable.auto.offset.store=false` "
|
|
1172
|
+
"for long-time processing applications and then explicitly store "
|
|
1173
|
+
"offsets (using offsets_store()) *after* message processing, to "
|
|
1174
|
+
"make sure offsets are not auto-committed prior to processing "
|
|
1175
|
+
"has finished. "
|
|
1176
|
+
"The interval is checked two times per second. "
|
|
1177
|
+
"See KIP-62 for more information.",
|
|
1178
|
+
1, 86400 * 1000, 300000},
|
|
1179
|
+
|
|
1180
|
+
/* Global consumer properties */
|
|
1181
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_HIGH, "enable.auto.commit", _RK_C_BOOL,
|
|
1182
|
+
_RK(enable_auto_commit),
|
|
1183
|
+
"Automatically and periodically commit offsets in the background. "
|
|
1184
|
+
"Note: setting this to false does not prevent the consumer from "
|
|
1185
|
+
"fetching previously committed start offsets. To circumvent this "
|
|
1186
|
+
"behaviour set specific start offsets per partition in the call "
|
|
1187
|
+
"to assign().",
|
|
1188
|
+
0, 1, 1},
|
|
1189
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "auto.commit.interval.ms", _RK_C_INT,
|
|
1190
|
+
_RK(auto_commit_interval_ms),
|
|
1191
|
+
"The frequency in milliseconds that the consumer offsets "
|
|
1192
|
+
"are committed (written) to offset storage. (0 = disable). "
|
|
1193
|
+
"This setting is used by the high-level consumer.",
|
|
1194
|
+
0, 86400 * 1000, 5 * 1000},
|
|
1195
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_HIGH, "enable.auto.offset.store",
|
|
1196
|
+
_RK_C_BOOL, _RK(enable_auto_offset_store),
|
|
1197
|
+
"Automatically store offset of last message provided to "
|
|
1198
|
+
"application. "
|
|
1199
|
+
"The offset store is an in-memory store of the next offset to "
|
|
1200
|
+
"(auto-)commit for each partition.",
|
|
1201
|
+
0, 1, 1},
|
|
1202
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "queued.min.messages", _RK_C_INT,
|
|
1203
|
+
_RK(queued_min_msgs),
|
|
1204
|
+
"Minimum number of messages per topic+partition "
|
|
1205
|
+
"librdkafka tries to maintain in the local consumer queue.",
|
|
1206
|
+
1, 10000000, 100000},
|
|
1207
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "queued.max.messages.kbytes",
|
|
1208
|
+
_RK_C_INT, _RK(queued_max_msg_kbytes),
|
|
1209
|
+
"Maximum number of kilobytes of queued pre-fetched messages "
|
|
1210
|
+
"in the local consumer queue. "
|
|
1211
|
+
"If using the high-level consumer this setting applies to the "
|
|
1212
|
+
"single consumer queue, regardless of the number of partitions. "
|
|
1213
|
+
"When using the legacy simple consumer or when separate "
|
|
1214
|
+
"partition queues are used this setting applies per partition. "
|
|
1215
|
+
"This value may be overshot by fetch.message.max.bytes. "
|
|
1216
|
+
"This property has higher priority than queued.min.messages.",
|
|
1217
|
+
1, INT_MAX / 1024, 0x10000 /*64MB*/},
|
|
1218
|
+
{_RK_GLOBAL | _RK_CONSUMER, "fetch.wait.max.ms", _RK_C_INT,
|
|
1219
|
+
_RK(fetch_wait_max_ms),
|
|
1220
|
+
"Maximum time the broker may wait to fill the Fetch response "
|
|
1221
|
+
"with fetch.min.bytes of messages.",
|
|
1222
|
+
0, 300 * 1000, 500},
|
|
1223
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "fetch.queue.backoff.ms", _RK_C_INT,
|
|
1224
|
+
_RK(fetch_queue_backoff_ms),
|
|
1225
|
+
"How long to postpone the next fetch request for a "
|
|
1226
|
+
"topic+partition in case the current fetch queue thresholds "
|
|
1227
|
+
"(queued.min.messages or queued.max.messages.kbytes) have "
|
|
1228
|
+
"been exceded. "
|
|
1229
|
+
"This property may need to be decreased if the queue thresholds are "
|
|
1230
|
+
"set low and the application is experiencing long (~1s) delays "
|
|
1231
|
+
"between messages. Low values may increase CPU utilization.",
|
|
1232
|
+
0, 300 * 1000, 1000},
|
|
1233
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "fetch.message.max.bytes", _RK_C_INT,
|
|
1234
|
+
_RK(fetch_msg_max_bytes),
|
|
1235
|
+
"Initial maximum number of bytes per topic+partition to request when "
|
|
1236
|
+
"fetching messages from the broker. "
|
|
1237
|
+
"If the client encounters a message larger than this value "
|
|
1238
|
+
"it will gradually try to increase it until the "
|
|
1239
|
+
"entire message can be fetched.",
|
|
1240
|
+
1, 1000000000, 1024 * 1024},
|
|
1241
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "max.partition.fetch.bytes",
|
|
1242
|
+
_RK_C_ALIAS, .sdef = "fetch.message.max.bytes"},
|
|
1243
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "fetch.max.bytes", _RK_C_INT,
|
|
1244
|
+
_RK(fetch_max_bytes),
|
|
1245
|
+
"Maximum amount of data the broker shall return for a Fetch request. "
|
|
1246
|
+
"Messages are fetched in batches by the consumer and if the first "
|
|
1247
|
+
"message batch in the first non-empty partition of the Fetch request "
|
|
1248
|
+
"is larger than this value, then the message batch will still be "
|
|
1249
|
+
"returned to ensure the consumer can make progress. "
|
|
1250
|
+
"The maximum message batch size accepted by the broker is defined "
|
|
1251
|
+
"via `message.max.bytes` (broker config) or "
|
|
1252
|
+
"`max.message.bytes` (broker topic config). "
|
|
1253
|
+
"`fetch.max.bytes` is automatically adjusted upwards to be "
|
|
1254
|
+
"at least `message.max.bytes` (consumer config).",
|
|
1255
|
+
0, INT_MAX - 512, 50 * 1024 * 1024 /* 50MB */},
|
|
1256
|
+
{_RK_GLOBAL | _RK_CONSUMER, "fetch.min.bytes", _RK_C_INT,
|
|
1257
|
+
_RK(fetch_min_bytes),
|
|
1258
|
+
"Minimum number of bytes the broker responds with. "
|
|
1259
|
+
"If fetch.wait.max.ms expires the accumulated data will "
|
|
1260
|
+
"be sent to the client regardless of this setting.",
|
|
1261
|
+
1, 100000000, 1},
|
|
1262
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "fetch.error.backoff.ms", _RK_C_INT,
|
|
1263
|
+
_RK(fetch_error_backoff_ms),
|
|
1264
|
+
"How long to postpone the next fetch request for a "
|
|
1265
|
+
"topic+partition in case of a fetch error.",
|
|
1266
|
+
0, 300 * 1000, 500},
|
|
1267
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_DEPRECATED, "offset.store.method",
|
|
1268
|
+
_RK_C_S2I, _RK(offset_store_method),
|
|
1269
|
+
"Offset commit store method: "
|
|
1270
|
+
"'file' - DEPRECATED: local file store (offset.store.path, et.al), "
|
|
1271
|
+
"'broker' - broker commit store "
|
|
1272
|
+
"(requires Apache Kafka 0.8.2 or later on the broker).",
|
|
1273
|
+
.vdef = RD_KAFKA_OFFSET_METHOD_BROKER,
|
|
1274
|
+
.s2i = {{RD_KAFKA_OFFSET_METHOD_NONE, "none"},
|
|
1275
|
+
{RD_KAFKA_OFFSET_METHOD_FILE, "file"},
|
|
1276
|
+
{RD_KAFKA_OFFSET_METHOD_BROKER, "broker"}}},
|
|
1277
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_HIGH, "isolation.level", _RK_C_S2I,
|
|
1278
|
+
_RK(isolation_level),
|
|
1279
|
+
"Controls how to read messages written transactionally: "
|
|
1280
|
+
"`read_committed` - only return transactional messages which have "
|
|
1281
|
+
"been committed. `read_uncommitted` - return all messages, even "
|
|
1282
|
+
"transactional messages which have been aborted.",
|
|
1283
|
+
.vdef = RD_KAFKA_READ_COMMITTED,
|
|
1284
|
+
.s2i = {{RD_KAFKA_READ_UNCOMMITTED, "read_uncommitted"},
|
|
1285
|
+
{RD_KAFKA_READ_COMMITTED, "read_committed"}}},
|
|
1286
|
+
{_RK_GLOBAL | _RK_CONSUMER, "consume_cb", _RK_C_PTR, _RK(consume_cb),
|
|
1287
|
+
"Message consume callback (set with rd_kafka_conf_set_consume_cb())"},
|
|
1288
|
+
{_RK_GLOBAL | _RK_CONSUMER, "rebalance_cb", _RK_C_PTR, _RK(rebalance_cb),
|
|
1289
|
+
"Called after consumer group has been rebalanced "
|
|
1290
|
+
"(set with rd_kafka_conf_set_rebalance_cb())"},
|
|
1291
|
+
{_RK_GLOBAL | _RK_CONSUMER, "offset_commit_cb", _RK_C_PTR,
|
|
1292
|
+
_RK(offset_commit_cb),
|
|
1293
|
+
"Offset commit result propagation callback. "
|
|
1294
|
+
"(set with rd_kafka_conf_set_offset_commit_cb())"},
|
|
1295
|
+
{_RK_GLOBAL | _RK_CONSUMER, "enable.partition.eof", _RK_C_BOOL,
|
|
1296
|
+
_RK(enable_partition_eof),
|
|
1297
|
+
"Emit RD_KAFKA_RESP_ERR__PARTITION_EOF event whenever the "
|
|
1298
|
+
"consumer reaches the end of a partition.",
|
|
1299
|
+
0, 1, 0},
|
|
1300
|
+
{_RK_GLOBAL | _RK_CONSUMER | _RK_MED, "check.crcs", _RK_C_BOOL,
|
|
1301
|
+
_RK(check_crcs),
|
|
1302
|
+
"Verify CRC32 of consumed messages, ensuring no on-the-wire or "
|
|
1303
|
+
"on-disk corruption to the messages occurred. This check comes "
|
|
1304
|
+
"at slightly increased CPU usage.",
|
|
1305
|
+
0, 1, 0},
|
|
1306
|
+
{_RK_GLOBAL, "client.rack", _RK_C_KSTR, _RK(client_rack),
|
|
1307
|
+
"A rack identifier for this client. This can be any string value "
|
|
1308
|
+
"which indicates where this client is physically located. It "
|
|
1309
|
+
"corresponds with the broker config `broker.rack`.",
|
|
1310
|
+
.sdef = ""},
|
|
1311
|
+
|
|
1312
|
+
/* Global producer properties */
|
|
1313
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "transactional.id", _RK_C_STR,
|
|
1314
|
+
_RK(eos.transactional_id),
|
|
1315
|
+
"Enables the transactional producer. "
|
|
1316
|
+
"The transactional.id is used to identify the same transactional "
|
|
1317
|
+
"producer instance across process restarts. "
|
|
1318
|
+
"It allows the producer to guarantee that transactions corresponding "
|
|
1319
|
+
"to earlier instances of the same producer have been finalized "
|
|
1320
|
+
"prior to starting any new transactions, and that any "
|
|
1321
|
+
"zombie instances are fenced off. "
|
|
1322
|
+
"If no transactional.id is provided, then the producer is limited "
|
|
1323
|
+
"to idempotent delivery (if enable.idempotence is set). "
|
|
1324
|
+
"Requires broker version >= 0.11.0."},
|
|
1325
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_MED, "transaction.timeout.ms", _RK_C_INT,
|
|
1326
|
+
_RK(eos.transaction_timeout_ms),
|
|
1327
|
+
"The maximum amount of time in milliseconds that the transaction "
|
|
1328
|
+
"coordinator will wait for a transaction status update from the "
|
|
1329
|
+
"producer before proactively aborting the ongoing transaction. "
|
|
1330
|
+
"If this value is larger than the `transaction.max.timeout.ms` "
|
|
1331
|
+
"setting in the broker, the init_transactions() call will fail with "
|
|
1332
|
+
"ERR_INVALID_TRANSACTION_TIMEOUT. "
|
|
1333
|
+
"The transaction timeout automatically adjusts "
|
|
1334
|
+
"`message.timeout.ms` and `socket.timeout.ms`, unless explicitly "
|
|
1335
|
+
"configured in which case they must not exceed the "
|
|
1336
|
+
"transaction timeout (`socket.timeout.ms` must be at least 100ms "
|
|
1337
|
+
"lower than `transaction.timeout.ms`). "
|
|
1338
|
+
"This is also the default timeout value if no timeout (-1) is "
|
|
1339
|
+
"supplied to the transactional API methods.",
|
|
1340
|
+
1000, INT_MAX, 60000},
|
|
1341
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "enable.idempotence", _RK_C_BOOL,
|
|
1342
|
+
_RK(eos.idempotence),
|
|
1343
|
+
"When set to `true`, the producer will ensure that messages are "
|
|
1344
|
+
"successfully produced exactly once and in the original produce "
|
|
1345
|
+
"order. "
|
|
1346
|
+
"The following configuration properties are adjusted automatically "
|
|
1347
|
+
"(if not modified by the user) when idempotence is enabled: "
|
|
1348
|
+
"`max.in.flight.requests.per.connection=" RD_KAFKA_IDEMP_MAX_INFLIGHT_STR
|
|
1349
|
+
"` (must be less than or "
|
|
1350
|
+
"equal to " RD_KAFKA_IDEMP_MAX_INFLIGHT_STR "), `retries=INT32_MAX` "
|
|
1351
|
+
"(must be greater than 0), `acks=all`, `queuing.strategy=fifo`. "
|
|
1352
|
+
"Producer instantation will fail if user-supplied configuration "
|
|
1353
|
+
"is incompatible.",
|
|
1354
|
+
0, 1, 0},
|
|
1355
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_EXPERIMENTAL, "enable.gapless.guarantee",
|
|
1356
|
+
_RK_C_BOOL, _RK(eos.gapless),
|
|
1357
|
+
"When set to `true`, any error that could result in a gap "
|
|
1358
|
+
"in the produced message series when a batch of messages fails, "
|
|
1359
|
+
"will raise a fatal error (ERR__GAPLESS_GUARANTEE) and stop "
|
|
1360
|
+
"the producer. "
|
|
1361
|
+
"Messages failing due to `message.timeout.ms` are not covered "
|
|
1362
|
+
"by this guarantee. "
|
|
1363
|
+
"Requires `enable.idempotence=true`.",
|
|
1364
|
+
0, 1, 0},
|
|
1365
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "queue.buffering.max.messages",
|
|
1366
|
+
_RK_C_INT, _RK(queue_buffering_max_msgs),
|
|
1367
|
+
"Maximum number of messages allowed on the producer queue. "
|
|
1368
|
+
"This queue is shared by all topics and partitions. A value of 0 disables "
|
|
1369
|
+
"this limit.",
|
|
1370
|
+
0, INT_MAX, 100000},
|
|
1371
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "queue.buffering.max.kbytes",
|
|
1372
|
+
_RK_C_INT, _RK(queue_buffering_max_kbytes),
|
|
1373
|
+
"Maximum total message size sum allowed on the producer queue. "
|
|
1374
|
+
"This queue is shared by all topics and partitions. "
|
|
1375
|
+
"This property has higher priority than queue.buffering.max.messages.",
|
|
1376
|
+
1, INT_MAX, 0x100000 /*1GB*/},
|
|
1377
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "queue.buffering.max.ms", _RK_C_DBL,
|
|
1378
|
+
_RK(buffering_max_ms_dbl),
|
|
1379
|
+
"Delay in milliseconds to wait for messages in the producer queue "
|
|
1380
|
+
"to accumulate before constructing message batches (MessageSets) to "
|
|
1381
|
+
"transmit to brokers. "
|
|
1382
|
+
"A higher value allows larger and more effective "
|
|
1383
|
+
"(less overhead, improved compression) batches of messages to "
|
|
1384
|
+
"accumulate at the expense of increased message delivery latency.",
|
|
1385
|
+
.dmin = 0, .dmax = 900.0 * 1000.0, .ddef = 5.0},
|
|
1386
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "linger.ms", _RK_C_ALIAS,
|
|
1387
|
+
.sdef = "queue.buffering.max.ms"},
|
|
1388
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_HIGH, "message.send.max.retries",
|
|
1389
|
+
_RK_C_INT, _RK(max_retries),
|
|
1390
|
+
"How many times to retry sending a failing Message. "
|
|
1391
|
+
"**Note:** retrying may cause reordering unless "
|
|
1392
|
+
"`enable.idempotence` is set to true.",
|
|
1393
|
+
0, INT32_MAX, INT32_MAX},
|
|
1394
|
+
{_RK_GLOBAL | _RK_PRODUCER, "retries", _RK_C_ALIAS,
|
|
1395
|
+
.sdef = "message.send.max.retries"},
|
|
1396
|
+
|
|
1397
|
+
{_RK_GLOBAL | _RK_MED, "retry.backoff.ms", _RK_C_INT, _RK(retry_backoff_ms),
|
|
1398
|
+
"The backoff time in milliseconds before retrying a protocol request, "
|
|
1399
|
+
"this is the first backoff time, "
|
|
1400
|
+
"and will be backed off exponentially until number of retries is "
|
|
1401
|
+
"exhausted, and it's capped by retry.backoff.max.ms.",
|
|
1402
|
+
1, 300 * 1000, 100},
|
|
1403
|
+
|
|
1404
|
+
{_RK_GLOBAL | _RK_MED, "retry.backoff.max.ms", _RK_C_INT,
|
|
1405
|
+
_RK(retry_backoff_max_ms),
|
|
1406
|
+
"The max backoff time in milliseconds before retrying a protocol request, "
|
|
1407
|
+
"this is the atmost backoff allowed for exponentially backed off "
|
|
1408
|
+
"requests.",
|
|
1409
|
+
1, 300 * 1000, 1000},
|
|
1410
|
+
|
|
1411
|
+
{_RK_GLOBAL | _RK_PRODUCER, "queue.buffering.backpressure.threshold",
|
|
1412
|
+
_RK_C_INT, _RK(queue_backpressure_thres),
|
|
1413
|
+
"The threshold of outstanding not yet transmitted broker requests "
|
|
1414
|
+
"needed to backpressure the producer's message accumulator. "
|
|
1415
|
+
"If the number of not yet transmitted requests equals or exceeds "
|
|
1416
|
+
"this number, produce request creation that would have otherwise "
|
|
1417
|
+
"been triggered (for example, in accordance with linger.ms) will be "
|
|
1418
|
+
"delayed. A lower number yields larger and more effective batches. "
|
|
1419
|
+
"A higher value can improve latency when using compression on slow "
|
|
1420
|
+
"machines.",
|
|
1421
|
+
1, 1000000, 1},
|
|
1422
|
+
|
|
1423
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_MED, "compression.codec", _RK_C_S2I,
|
|
1424
|
+
_RK(compression_codec),
|
|
1425
|
+
"compression codec to use for compressing message sets. "
|
|
1426
|
+
"This is the default value for all topics, may be overridden by "
|
|
1427
|
+
"the topic configuration property `compression.codec`. ",
|
|
1428
|
+
.vdef = RD_KAFKA_COMPRESSION_NONE,
|
|
1429
|
+
.s2i = {{RD_KAFKA_COMPRESSION_NONE, "none"},
|
|
1430
|
+
{RD_KAFKA_COMPRESSION_GZIP, "gzip", _UNSUPPORTED_ZLIB},
|
|
1431
|
+
{RD_KAFKA_COMPRESSION_SNAPPY, "snappy", _UNSUPPORTED_SNAPPY},
|
|
1432
|
+
{RD_KAFKA_COMPRESSION_LZ4, "lz4"},
|
|
1433
|
+
{RD_KAFKA_COMPRESSION_ZSTD, "zstd", _UNSUPPORTED_ZSTD},
|
|
1434
|
+
{0}}},
|
|
1435
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_MED, "compression.type", _RK_C_ALIAS,
|
|
1436
|
+
.sdef = "compression.codec"},
|
|
1437
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_MED, "batch.num.messages", _RK_C_INT,
|
|
1438
|
+
_RK(batch_num_messages),
|
|
1439
|
+
"Maximum number of messages batched in one MessageSet. "
|
|
1440
|
+
"The total MessageSet size is also limited by batch.size and "
|
|
1441
|
+
"message.max.bytes.",
|
|
1442
|
+
1, 1000000, 10000},
|
|
1443
|
+
{_RK_GLOBAL | _RK_PRODUCER | _RK_MED, "batch.size", _RK_C_INT,
|
|
1444
|
+
_RK(batch_size),
|
|
1445
|
+
"Maximum size (in bytes) of all messages batched in one MessageSet, "
|
|
1446
|
+
"including protocol framing overhead. "
|
|
1447
|
+
"This limit is applied after the first message has been added "
|
|
1448
|
+
"to the batch, regardless of the first message's size, this is to "
|
|
1449
|
+
"ensure that messages that exceed batch.size are produced. "
|
|
1450
|
+
"The total MessageSet size is also limited by batch.num.messages and "
|
|
1451
|
+
"message.max.bytes.",
|
|
1452
|
+
1, INT_MAX, 1000000},
|
|
1453
|
+
{_RK_GLOBAL | _RK_PRODUCER, "delivery.report.only.error", _RK_C_BOOL,
|
|
1454
|
+
_RK(dr_err_only), "Only provide delivery reports for failed messages.", 0,
|
|
1455
|
+
1, 0},
|
|
1456
|
+
{_RK_GLOBAL | _RK_PRODUCER, "dr_cb", _RK_C_PTR, _RK(dr_cb),
|
|
1457
|
+
"Delivery report callback (set with rd_kafka_conf_set_dr_cb())"},
|
|
1458
|
+
{_RK_GLOBAL | _RK_PRODUCER, "dr_msg_cb", _RK_C_PTR, _RK(dr_msg_cb),
|
|
1459
|
+
"Delivery report callback (set with rd_kafka_conf_set_dr_msg_cb())"},
|
|
1460
|
+
{_RK_GLOBAL | _RK_PRODUCER, "sticky.partitioning.linger.ms", _RK_C_INT,
|
|
1461
|
+
_RK(sticky_partition_linger_ms),
|
|
1462
|
+
"Delay in milliseconds to wait to assign new sticky partitions for "
|
|
1463
|
+
"each topic. "
|
|
1464
|
+
"By default, set to double the time of linger.ms. To disable sticky "
|
|
1465
|
+
"behavior, set to 0. "
|
|
1466
|
+
"This behavior affects messages with the key NULL in all cases, and "
|
|
1467
|
+
"messages with key lengths of zero when the consistent_random "
|
|
1468
|
+
"partitioner is in use. "
|
|
1469
|
+
"These messages would otherwise be assigned randomly. "
|
|
1470
|
+
"A higher value allows for more effective batching of these "
|
|
1471
|
+
"messages.",
|
|
1472
|
+
0, 900000, 10},
|
|
1473
|
+
{_RK_GLOBAL, "client.dns.lookup", _RK_C_S2I, _RK(client_dns_lookup),
|
|
1474
|
+
"Controls how the client uses DNS lookups. By default, when the lookup "
|
|
1475
|
+
"returns multiple IP addresses for a hostname, they will all be attempted "
|
|
1476
|
+
"for connection before the connection is considered failed. This applies "
|
|
1477
|
+
"to both bootstrap and advertised servers. If the value is set to "
|
|
1478
|
+
"`resolve_canonical_bootstrap_servers_only`, each entry will be resolved "
|
|
1479
|
+
"and expanded into a list of canonical names. "
|
|
1480
|
+
"**WARNING**: `resolve_canonical_bootstrap_servers_only` "
|
|
1481
|
+
"must only be used with `GSSAPI` (Kerberos) as `sasl.mechanism`, "
|
|
1482
|
+
"as it's the only purpose of this configuration value. "
|
|
1483
|
+
"**NOTE**: Default here is different from the Java client's default "
|
|
1484
|
+
"behavior, which connects only to the first IP address returned for a "
|
|
1485
|
+
"hostname. ",
|
|
1486
|
+
.vdef = RD_KAFKA_USE_ALL_DNS_IPS,
|
|
1487
|
+
.s2i = {{RD_KAFKA_USE_ALL_DNS_IPS, "use_all_dns_ips"},
|
|
1488
|
+
{RD_KAFKA_RESOLVE_CANONICAL_BOOTSTRAP_SERVERS_ONLY,
|
|
1489
|
+
"resolve_canonical_bootstrap_servers_only"}}},
|
|
1490
|
+
{_RK_GLOBAL, "enable.metrics.push", _RK_C_BOOL, _RK(enable_metrics_push),
|
|
1491
|
+
"Whether to enable pushing of client metrics to the cluster, if the "
|
|
1492
|
+
"cluster has a client metrics subscription which matches this client",
|
|
1493
|
+
0, 1, 1},
|
|
1494
|
+
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
/*
|
|
1498
|
+
* Topic properties
|
|
1499
|
+
*/
|
|
1500
|
+
|
|
1501
|
+
/* Topic producer properties */
|
|
1502
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "request.required.acks", _RK_C_INT,
|
|
1503
|
+
_RKT(required_acks),
|
|
1504
|
+
"This field indicates the number of acknowledgements the leader "
|
|
1505
|
+
"broker must receive from ISR brokers before responding to the "
|
|
1506
|
+
"request: "
|
|
1507
|
+
"*0*=Broker does not send any response/ack to client, "
|
|
1508
|
+
"*-1* or *all*=Broker will block until message is committed by all "
|
|
1509
|
+
"in sync replicas (ISRs). If there are less than "
|
|
1510
|
+
"`min.insync.replicas` (broker configuration) in the ISR set the "
|
|
1511
|
+
"produce request will fail.",
|
|
1512
|
+
-1, 1000, -1,
|
|
1513
|
+
.s2i =
|
|
1514
|
+
{
|
|
1515
|
+
{-1, "all"},
|
|
1516
|
+
}},
|
|
1517
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "acks", _RK_C_ALIAS,
|
|
1518
|
+
.sdef = "request.required.acks"},
|
|
1519
|
+
|
|
1520
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_MED, "request.timeout.ms", _RK_C_INT,
|
|
1521
|
+
_RKT(request_timeout_ms),
|
|
1522
|
+
"The ack timeout of the producer request in milliseconds. "
|
|
1523
|
+
"This value is only enforced by the broker and relies "
|
|
1524
|
+
"on `request.required.acks` being != 0.",
|
|
1525
|
+
1, 900 * 1000, 30 * 1000},
|
|
1526
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "message.timeout.ms", _RK_C_INT,
|
|
1527
|
+
_RKT(message_timeout_ms),
|
|
1528
|
+
"Local message timeout. "
|
|
1529
|
+
"This value is only enforced locally and limits the time a "
|
|
1530
|
+
"produced message waits for successful delivery. "
|
|
1531
|
+
"A time of 0 is infinite. "
|
|
1532
|
+
"This is the maximum time librdkafka may use to deliver a message "
|
|
1533
|
+
"(including retries). Delivery error occurs when either the retry "
|
|
1534
|
+
"count or the message timeout are exceeded. "
|
|
1535
|
+
"The message timeout is automatically adjusted to "
|
|
1536
|
+
"`transaction.timeout.ms` if `transactional.id` is configured.",
|
|
1537
|
+
0, INT32_MAX, 300 * 1000},
|
|
1538
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "delivery.timeout.ms", _RK_C_ALIAS,
|
|
1539
|
+
.sdef = "message.timeout.ms"},
|
|
1540
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_DEPRECATED | _RK_EXPERIMENTAL,
|
|
1541
|
+
"queuing.strategy", _RK_C_S2I, _RKT(queuing_strategy),
|
|
1542
|
+
"Producer queuing strategy. FIFO preserves produce ordering, "
|
|
1543
|
+
"while LIFO prioritizes new messages.",
|
|
1544
|
+
.vdef = 0,
|
|
1545
|
+
.s2i = {{RD_KAFKA_QUEUE_FIFO, "fifo"}, {RD_KAFKA_QUEUE_LIFO, "lifo"}}},
|
|
1546
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_DEPRECATED, "produce.offset.report",
|
|
1547
|
+
_RK_C_BOOL, _RKT(produce_offset_report), "No longer used.", 0, 1, 0},
|
|
1548
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "partitioner", _RK_C_STR,
|
|
1549
|
+
_RKT(partitioner_str),
|
|
1550
|
+
"Partitioner: "
|
|
1551
|
+
"`random` - random distribution, "
|
|
1552
|
+
"`consistent` - CRC32 hash of key (Empty and NULL keys are mapped to "
|
|
1553
|
+
"single partition), "
|
|
1554
|
+
"`consistent_random` - CRC32 hash of key (Empty and NULL keys are "
|
|
1555
|
+
"randomly partitioned), "
|
|
1556
|
+
"`murmur2` - Java Producer compatible Murmur2 hash of key (NULL keys are "
|
|
1557
|
+
"mapped to single partition), "
|
|
1558
|
+
"`murmur2_random` - Java Producer compatible Murmur2 hash of key "
|
|
1559
|
+
"(NULL keys are randomly partitioned. This is functionally equivalent "
|
|
1560
|
+
"to the default partitioner in the Java Producer.), "
|
|
1561
|
+
"`fnv1a` - FNV-1a hash of key (NULL keys are mapped to single partition), "
|
|
1562
|
+
"`fnv1a_random` - FNV-1a hash of key (NULL keys are randomly "
|
|
1563
|
+
"partitioned).",
|
|
1564
|
+
.sdef = "consistent_random",
|
|
1565
|
+
.validate = rd_kafka_conf_validate_partitioner},
|
|
1566
|
+
{_RK_TOPIC | _RK_PRODUCER, "partitioner_cb", _RK_C_PTR, _RKT(partitioner),
|
|
1567
|
+
"Custom partitioner callback "
|
|
1568
|
+
"(set with rd_kafka_topic_conf_set_partitioner_cb())"},
|
|
1569
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_DEPRECATED | _RK_EXPERIMENTAL,
|
|
1570
|
+
"msg_order_cmp", _RK_C_PTR, _RKT(msg_order_cmp),
|
|
1571
|
+
"Message queue ordering comparator "
|
|
1572
|
+
"(set with rd_kafka_topic_conf_set_msg_order_cmp()). "
|
|
1573
|
+
"Also see `queuing.strategy`."},
|
|
1574
|
+
{_RK_TOPIC, "opaque", _RK_C_PTR, _RKT(opaque),
|
|
1575
|
+
"Application opaque (set with rd_kafka_topic_conf_set_opaque())"},
|
|
1576
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "compression.codec", _RK_C_S2I,
|
|
1577
|
+
_RKT(compression_codec),
|
|
1578
|
+
"Compression codec to use for compressing message sets. "
|
|
1579
|
+
"inherit = inherit global compression.codec configuration.",
|
|
1580
|
+
.vdef = RD_KAFKA_COMPRESSION_INHERIT,
|
|
1581
|
+
.s2i = {{RD_KAFKA_COMPRESSION_NONE, "none"},
|
|
1582
|
+
{RD_KAFKA_COMPRESSION_GZIP, "gzip", _UNSUPPORTED_ZLIB},
|
|
1583
|
+
{RD_KAFKA_COMPRESSION_SNAPPY, "snappy", _UNSUPPORTED_SNAPPY},
|
|
1584
|
+
{RD_KAFKA_COMPRESSION_LZ4, "lz4"},
|
|
1585
|
+
{RD_KAFKA_COMPRESSION_ZSTD, "zstd", _UNSUPPORTED_ZSTD},
|
|
1586
|
+
{RD_KAFKA_COMPRESSION_INHERIT, "inherit"},
|
|
1587
|
+
{0}}},
|
|
1588
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_HIGH, "compression.type", _RK_C_ALIAS,
|
|
1589
|
+
.sdef = "compression.codec"},
|
|
1590
|
+
{_RK_TOPIC | _RK_PRODUCER | _RK_MED, "compression.level", _RK_C_INT,
|
|
1591
|
+
_RKT(compression_level),
|
|
1592
|
+
"Compression level parameter for algorithm selected by configuration "
|
|
1593
|
+
"property `compression.codec`. Higher values will result in better "
|
|
1594
|
+
"compression at the cost of more CPU usage. Usable range is "
|
|
1595
|
+
"algorithm-dependent: [0-9] for gzip; [0-12] for lz4; only 0 for snappy; "
|
|
1596
|
+
"-1 = codec-dependent default compression level.",
|
|
1597
|
+
RD_KAFKA_COMPLEVEL_MIN, RD_KAFKA_COMPLEVEL_MAX,
|
|
1598
|
+
RD_KAFKA_COMPLEVEL_DEFAULT},
|
|
1599
|
+
|
|
1600
|
+
|
|
1601
|
+
/* Topic consumer properties */
|
|
1602
|
+
{_RK_TOPIC | _RK_CONSUMER | _RK_DEPRECATED, "auto.commit.enable",
|
|
1603
|
+
_RK_C_BOOL, _RKT(auto_commit),
|
|
1604
|
+
"[**LEGACY PROPERTY:** This property is used by the simple legacy "
|
|
1605
|
+
"consumer only. When using the high-level KafkaConsumer, the global "
|
|
1606
|
+
"`enable.auto.commit` property must be used instead]. "
|
|
1607
|
+
"If true, periodically commit offset of the last message handed "
|
|
1608
|
+
"to the application. This committed offset will be used when the "
|
|
1609
|
+
"process restarts to pick up where it left off. "
|
|
1610
|
+
"If false, the application will have to call "
|
|
1611
|
+
"`rd_kafka_offset_store()` to store an offset (optional). "
|
|
1612
|
+
"Offsets will be written to broker or local file according to "
|
|
1613
|
+
"offset.store.method.",
|
|
1614
|
+
0, 1, 1},
|
|
1615
|
+
{_RK_TOPIC | _RK_CONSUMER, "enable.auto.commit", _RK_C_ALIAS,
|
|
1616
|
+
.sdef = "auto.commit.enable"},
|
|
1617
|
+
{_RK_TOPIC | _RK_CONSUMER | _RK_HIGH, "auto.commit.interval.ms", _RK_C_INT,
|
|
1618
|
+
_RKT(auto_commit_interval_ms),
|
|
1619
|
+
"[**LEGACY PROPERTY:** This setting is used by the simple legacy "
|
|
1620
|
+
"consumer only. When using the high-level KafkaConsumer, the "
|
|
1621
|
+
"global `auto.commit.interval.ms` property must be used instead]. "
|
|
1622
|
+
"The frequency in milliseconds that the consumer offsets "
|
|
1623
|
+
"are committed (written) to offset storage.",
|
|
1624
|
+
10, 86400 * 1000, 60 * 1000},
|
|
1625
|
+
{_RK_TOPIC | _RK_CONSUMER | _RK_HIGH, "auto.offset.reset", _RK_C_S2I,
|
|
1626
|
+
_RKT(auto_offset_reset),
|
|
1627
|
+
"Action to take when there is no initial offset in offset store "
|
|
1628
|
+
"or the desired offset is out of range: "
|
|
1629
|
+
"'smallest','earliest' - automatically reset the offset to the smallest "
|
|
1630
|
+
"offset, "
|
|
1631
|
+
"'largest','latest' - automatically reset the offset to the largest "
|
|
1632
|
+
"offset, "
|
|
1633
|
+
"'error' - trigger an error (ERR__AUTO_OFFSET_RESET) which is "
|
|
1634
|
+
"retrieved by consuming messages and checking 'message->err'.",
|
|
1635
|
+
.vdef = RD_KAFKA_OFFSET_END,
|
|
1636
|
+
.s2i =
|
|
1637
|
+
{
|
|
1638
|
+
{RD_KAFKA_OFFSET_BEGINNING, "smallest"},
|
|
1639
|
+
{RD_KAFKA_OFFSET_BEGINNING, "earliest"},
|
|
1640
|
+
{RD_KAFKA_OFFSET_BEGINNING, "beginning"},
|
|
1641
|
+
{RD_KAFKA_OFFSET_END, "largest"},
|
|
1642
|
+
{RD_KAFKA_OFFSET_END, "latest"},
|
|
1643
|
+
{RD_KAFKA_OFFSET_END, "end"},
|
|
1644
|
+
{RD_KAFKA_OFFSET_INVALID, "error"},
|
|
1645
|
+
}},
|
|
1646
|
+
{_RK_TOPIC | _RK_CONSUMER | _RK_DEPRECATED, "offset.store.path", _RK_C_STR,
|
|
1647
|
+
_RKT(offset_store_path),
|
|
1648
|
+
"Path to local file for storing offsets. If the path is a directory "
|
|
1649
|
+
"a filename will be automatically generated in that directory based "
|
|
1650
|
+
"on the topic and partition. "
|
|
1651
|
+
"File-based offset storage will be removed in a future version.",
|
|
1652
|
+
.sdef = "."},
|
|
1653
|
+
|
|
1654
|
+
{_RK_TOPIC | _RK_CONSUMER | _RK_DEPRECATED, "offset.store.sync.interval.ms",
|
|
1655
|
+
_RK_C_INT, _RKT(offset_store_sync_interval_ms),
|
|
1656
|
+
"fsync() interval for the offset file, in milliseconds. "
|
|
1657
|
+
"Use -1 to disable syncing, and 0 for immediate sync after "
|
|
1658
|
+
"each write. "
|
|
1659
|
+
"File-based offset storage will be removed in a future version.",
|
|
1660
|
+
-1, 86400 * 1000, -1},
|
|
1661
|
+
|
|
1662
|
+
{_RK_TOPIC | _RK_CONSUMER | _RK_DEPRECATED, "offset.store.method",
|
|
1663
|
+
_RK_C_S2I, _RKT(offset_store_method),
|
|
1664
|
+
"Offset commit store method: "
|
|
1665
|
+
"'file' - DEPRECATED: local file store (offset.store.path, et.al), "
|
|
1666
|
+
"'broker' - broker commit store "
|
|
1667
|
+
"(requires \"group.id\" to be configured and "
|
|
1668
|
+
"Apache Kafka 0.8.2 or later on the broker.).",
|
|
1669
|
+
.vdef = RD_KAFKA_OFFSET_METHOD_BROKER,
|
|
1670
|
+
.s2i = {{RD_KAFKA_OFFSET_METHOD_FILE, "file"},
|
|
1671
|
+
{RD_KAFKA_OFFSET_METHOD_BROKER, "broker"}}},
|
|
1672
|
+
|
|
1673
|
+
{_RK_TOPIC | _RK_CONSUMER, "consume.callback.max.messages", _RK_C_INT,
|
|
1674
|
+
_RKT(consume_callback_max_msgs),
|
|
1675
|
+
"Maximum number of messages to dispatch in "
|
|
1676
|
+
"one `rd_kafka_consume_callback*()` call (0 = unlimited)",
|
|
1677
|
+
0, 1000000, 0},
|
|
1678
|
+
|
|
1679
|
+
{0, /* End */}};
|
|
1680
|
+
|
|
1681
|
+
/**
|
|
1682
|
+
* @returns the property object for \p name in \p scope, or NULL if not found.
|
|
1683
|
+
* @remark does not work with interceptor configs.
|
|
1684
|
+
*/
|
|
1685
|
+
const struct rd_kafka_property *rd_kafka_conf_prop_find(int scope,
|
|
1686
|
+
const char *name) {
|
|
1687
|
+
const struct rd_kafka_property *prop;
|
|
1688
|
+
|
|
1689
|
+
restart:
|
|
1690
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
1691
|
+
|
|
1692
|
+
if (!(prop->scope & scope))
|
|
1693
|
+
continue;
|
|
1694
|
+
|
|
1695
|
+
if (strcmp(prop->name, name))
|
|
1696
|
+
continue;
|
|
1697
|
+
|
|
1698
|
+
if (prop->type == _RK_C_ALIAS) {
|
|
1699
|
+
/* Caller supplied an alias, restart
|
|
1700
|
+
* search for real name. */
|
|
1701
|
+
name = prop->sdef;
|
|
1702
|
+
goto restart;
|
|
1703
|
+
}
|
|
1704
|
+
|
|
1705
|
+
return prop;
|
|
1706
|
+
}
|
|
1707
|
+
|
|
1708
|
+
return NULL;
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* @returns rd_true if property has been set/modified, else rd_false.
|
|
1713
|
+
*
|
|
1714
|
+
* @warning Asserts if the property does not exist.
|
|
1715
|
+
*/
|
|
1716
|
+
rd_bool_t rd_kafka_conf_is_modified(const rd_kafka_conf_t *conf,
|
|
1717
|
+
const char *name) {
|
|
1718
|
+
const struct rd_kafka_property *prop;
|
|
1719
|
+
|
|
1720
|
+
if (!(prop = rd_kafka_conf_prop_find(_RK_GLOBAL, name)))
|
|
1721
|
+
RD_BUG("Configuration property \"%s\" does not exist", name);
|
|
1722
|
+
|
|
1723
|
+
return rd_kafka_anyconf_is_modified(conf, prop);
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* @returns true if property has been set/modified, else 0.
|
|
1729
|
+
*
|
|
1730
|
+
* @warning Asserts if the property does not exist.
|
|
1731
|
+
*/
|
|
1732
|
+
static rd_bool_t
|
|
1733
|
+
rd_kafka_topic_conf_is_modified(const rd_kafka_topic_conf_t *conf,
|
|
1734
|
+
const char *name) {
|
|
1735
|
+
const struct rd_kafka_property *prop;
|
|
1736
|
+
|
|
1737
|
+
if (!(prop = rd_kafka_conf_prop_find(_RK_TOPIC, name)))
|
|
1738
|
+
RD_BUG("Topic configuration property \"%s\" does not exist",
|
|
1739
|
+
name);
|
|
1740
|
+
|
|
1741
|
+
return rd_kafka_anyconf_is_modified(conf, prop);
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
|
|
1745
|
+
|
|
1746
|
+
static rd_kafka_conf_res_t
|
|
1747
|
+
rd_kafka_anyconf_set_prop0(int scope,
|
|
1748
|
+
void *conf,
|
|
1749
|
+
const struct rd_kafka_property *prop,
|
|
1750
|
+
const char *istr,
|
|
1751
|
+
int ival,
|
|
1752
|
+
rd_kafka_conf_set_mode_t set_mode,
|
|
1753
|
+
char *errstr,
|
|
1754
|
+
size_t errstr_size) {
|
|
1755
|
+
rd_kafka_conf_res_t res;
|
|
1756
|
+
|
|
1757
|
+
#define _RK_PTR(TYPE, BASE, OFFSET) (TYPE)(void *)(((char *)(BASE)) + (OFFSET))
|
|
1758
|
+
|
|
1759
|
+
/* Try interceptors first (only for GLOBAL config) */
|
|
1760
|
+
if (scope & _RK_GLOBAL) {
|
|
1761
|
+
if (prop->type == _RK_C_PTR || prop->type == _RK_C_INTERNAL)
|
|
1762
|
+
res = RD_KAFKA_CONF_UNKNOWN;
|
|
1763
|
+
else
|
|
1764
|
+
res = rd_kafka_interceptors_on_conf_set(
|
|
1765
|
+
conf, prop->name, istr, errstr, errstr_size);
|
|
1766
|
+
if (res != RD_KAFKA_CONF_UNKNOWN)
|
|
1767
|
+
return res;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
|
|
1771
|
+
if (prop->set) {
|
|
1772
|
+
/* Custom setter */
|
|
1773
|
+
|
|
1774
|
+
res = prop->set(scope, conf, prop->name, istr,
|
|
1775
|
+
_RK_PTR(void *, conf, prop->offset), set_mode,
|
|
1776
|
+
errstr, errstr_size);
|
|
1777
|
+
|
|
1778
|
+
if (res != RD_KAFKA_CONF_OK)
|
|
1779
|
+
return res;
|
|
1780
|
+
|
|
1781
|
+
/* FALLTHRU so that property value is set. */
|
|
1782
|
+
}
|
|
1783
|
+
|
|
1784
|
+
switch (prop->type) {
|
|
1785
|
+
case _RK_C_STR: {
|
|
1786
|
+
char **str = _RK_PTR(char **, conf, prop->offset);
|
|
1787
|
+
if (*str)
|
|
1788
|
+
rd_free(*str);
|
|
1789
|
+
if (istr)
|
|
1790
|
+
*str = rd_strdup(istr);
|
|
1791
|
+
else
|
|
1792
|
+
*str = prop->sdef ? rd_strdup(prop->sdef) : NULL;
|
|
1793
|
+
break;
|
|
1794
|
+
}
|
|
1795
|
+
case _RK_C_KSTR: {
|
|
1796
|
+
rd_kafkap_str_t **kstr =
|
|
1797
|
+
_RK_PTR(rd_kafkap_str_t **, conf, prop->offset);
|
|
1798
|
+
if (*kstr)
|
|
1799
|
+
rd_kafkap_str_destroy(*kstr);
|
|
1800
|
+
if (istr)
|
|
1801
|
+
*kstr = rd_kafkap_str_new(istr, -1);
|
|
1802
|
+
else
|
|
1803
|
+
*kstr = prop->sdef ? rd_kafkap_str_new(prop->sdef, -1)
|
|
1804
|
+
: NULL;
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
case _RK_C_PTR:
|
|
1808
|
+
*_RK_PTR(const void **, conf, prop->offset) = istr;
|
|
1809
|
+
break;
|
|
1810
|
+
case _RK_C_BOOL:
|
|
1811
|
+
case _RK_C_INT:
|
|
1812
|
+
case _RK_C_S2I:
|
|
1813
|
+
case _RK_C_S2F: {
|
|
1814
|
+
int *val = _RK_PTR(int *, conf, prop->offset);
|
|
1815
|
+
|
|
1816
|
+
if (prop->type == _RK_C_S2F) {
|
|
1817
|
+
switch (set_mode) {
|
|
1818
|
+
case _RK_CONF_PROP_SET_REPLACE:
|
|
1819
|
+
*val = ival;
|
|
1820
|
+
break;
|
|
1821
|
+
case _RK_CONF_PROP_SET_ADD:
|
|
1822
|
+
*val |= ival;
|
|
1823
|
+
break;
|
|
1824
|
+
case _RK_CONF_PROP_SET_DEL:
|
|
1825
|
+
*val &= ~ival;
|
|
1826
|
+
break;
|
|
1827
|
+
}
|
|
1828
|
+
} else {
|
|
1829
|
+
/* Single assignment */
|
|
1830
|
+
*val = ival;
|
|
1831
|
+
}
|
|
1832
|
+
break;
|
|
1833
|
+
}
|
|
1834
|
+
case _RK_C_DBL: {
|
|
1835
|
+
double *val = _RK_PTR(double *, conf, prop->offset);
|
|
1836
|
+
if (istr) {
|
|
1837
|
+
char *endptr;
|
|
1838
|
+
double new_val = strtod(istr, &endptr);
|
|
1839
|
+
/* This is verified in set_prop() */
|
|
1840
|
+
rd_assert(endptr != istr);
|
|
1841
|
+
*val = new_val;
|
|
1842
|
+
} else
|
|
1843
|
+
*val = prop->ddef;
|
|
1844
|
+
break;
|
|
1845
|
+
}
|
|
1846
|
+
|
|
1847
|
+
case _RK_C_PATLIST: {
|
|
1848
|
+
/* Split comma-separated list into individual regex expressions
|
|
1849
|
+
* that are verified and then append to the provided list. */
|
|
1850
|
+
rd_kafka_pattern_list_t **plist;
|
|
1851
|
+
|
|
1852
|
+
plist = _RK_PTR(rd_kafka_pattern_list_t **, conf, prop->offset);
|
|
1853
|
+
|
|
1854
|
+
if (*plist)
|
|
1855
|
+
rd_kafka_pattern_list_destroy(*plist);
|
|
1856
|
+
|
|
1857
|
+
if (istr) {
|
|
1858
|
+
if (!(*plist = rd_kafka_pattern_list_new(
|
|
1859
|
+
istr, errstr, (int)errstr_size)))
|
|
1860
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1861
|
+
} else
|
|
1862
|
+
*plist = NULL;
|
|
1863
|
+
|
|
1864
|
+
break;
|
|
1865
|
+
}
|
|
1866
|
+
|
|
1867
|
+
case _RK_C_INTERNAL:
|
|
1868
|
+
/* Probably handled by setter */
|
|
1869
|
+
break;
|
|
1870
|
+
|
|
1871
|
+
default:
|
|
1872
|
+
rd_kafka_assert(NULL, !*"unknown conf type");
|
|
1873
|
+
}
|
|
1874
|
+
|
|
1875
|
+
|
|
1876
|
+
rd_kafka_anyconf_set_modified(conf, prop, 1 /*modified*/);
|
|
1877
|
+
return RD_KAFKA_CONF_OK;
|
|
1878
|
+
}
|
|
1879
|
+
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* @brief Find s2i (string-to-int mapping) entry and return its array index,
|
|
1883
|
+
* or -1 on miss.
|
|
1884
|
+
*/
|
|
1885
|
+
static int rd_kafka_conf_s2i_find(const struct rd_kafka_property *prop,
|
|
1886
|
+
const char *value) {
|
|
1887
|
+
int j;
|
|
1888
|
+
|
|
1889
|
+
for (j = 0; j < (int)RD_ARRAYSIZE(prop->s2i); j++) {
|
|
1890
|
+
if (prop->s2i[j].str && !rd_strcasecmp(prop->s2i[j].str, value))
|
|
1891
|
+
return j;
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
return -1;
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* @brief Set configuration property.
|
|
1900
|
+
*
|
|
1901
|
+
* @param allow_specific Allow rd_kafka_*conf_set_..() to be set,
|
|
1902
|
+
* such as rd_kafka_conf_set_log_cb().
|
|
1903
|
+
* Should not be allowed from the conf_set() string interface.
|
|
1904
|
+
*/
|
|
1905
|
+
static rd_kafka_conf_res_t
|
|
1906
|
+
rd_kafka_anyconf_set_prop(int scope,
|
|
1907
|
+
void *conf,
|
|
1908
|
+
const struct rd_kafka_property *prop,
|
|
1909
|
+
const char *value,
|
|
1910
|
+
int allow_specific,
|
|
1911
|
+
char *errstr,
|
|
1912
|
+
size_t errstr_size) {
|
|
1913
|
+
int ival;
|
|
1914
|
+
|
|
1915
|
+
if (prop->unsupported) {
|
|
1916
|
+
rd_snprintf(errstr, errstr_size,
|
|
1917
|
+
"Configuration property \"%s\" not supported "
|
|
1918
|
+
"in this build: %s",
|
|
1919
|
+
prop->name, prop->unsupported);
|
|
1920
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
switch (prop->type) {
|
|
1924
|
+
case _RK_C_STR:
|
|
1925
|
+
/* Left-trim string(likes) */
|
|
1926
|
+
if (value)
|
|
1927
|
+
while (isspace((int)*value))
|
|
1928
|
+
value++;
|
|
1929
|
+
|
|
1930
|
+
/* FALLTHRU */
|
|
1931
|
+
case _RK_C_KSTR:
|
|
1932
|
+
if (prop->s2i[0].str) {
|
|
1933
|
+
int match;
|
|
1934
|
+
|
|
1935
|
+
if (!value || (match = rd_kafka_conf_s2i_find(
|
|
1936
|
+
prop, value)) == -1) {
|
|
1937
|
+
rd_snprintf(errstr, errstr_size,
|
|
1938
|
+
"Invalid value for "
|
|
1939
|
+
"configuration property \"%s\": "
|
|
1940
|
+
"%s",
|
|
1941
|
+
prop->name, value);
|
|
1942
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/* Replace value string with canonical form */
|
|
1946
|
+
value = prop->s2i[match].str;
|
|
1947
|
+
}
|
|
1948
|
+
/* FALLTHRU */
|
|
1949
|
+
case _RK_C_PATLIST:
|
|
1950
|
+
if (prop->validate &&
|
|
1951
|
+
(!value || !prop->validate(prop, value, -1))) {
|
|
1952
|
+
rd_snprintf(errstr, errstr_size,
|
|
1953
|
+
"Invalid value for "
|
|
1954
|
+
"configuration property \"%s\": %s",
|
|
1955
|
+
prop->name, value);
|
|
1956
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
return rd_kafka_anyconf_set_prop0(scope, conf, prop, value, 0,
|
|
1960
|
+
_RK_CONF_PROP_SET_REPLACE,
|
|
1961
|
+
errstr, errstr_size);
|
|
1962
|
+
|
|
1963
|
+
case _RK_C_PTR:
|
|
1964
|
+
/* Allow hidden internal unit test properties to
|
|
1965
|
+
* be set from generic conf_set() interface. */
|
|
1966
|
+
if (!allow_specific && !(prop->scope & _RK_HIDDEN)) {
|
|
1967
|
+
rd_snprintf(errstr, errstr_size,
|
|
1968
|
+
"Property \"%s\" must be set through "
|
|
1969
|
+
"dedicated .._set_..() function",
|
|
1970
|
+
prop->name);
|
|
1971
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1972
|
+
}
|
|
1973
|
+
return rd_kafka_anyconf_set_prop0(scope, conf, prop, value, 0,
|
|
1974
|
+
_RK_CONF_PROP_SET_REPLACE,
|
|
1975
|
+
errstr, errstr_size);
|
|
1976
|
+
|
|
1977
|
+
case _RK_C_BOOL:
|
|
1978
|
+
if (!value) {
|
|
1979
|
+
rd_snprintf(errstr, errstr_size,
|
|
1980
|
+
"Bool configuration property \"%s\" cannot "
|
|
1981
|
+
"be set to empty value",
|
|
1982
|
+
prop->name);
|
|
1983
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
|
|
1987
|
+
if (!rd_strcasecmp(value, "true") ||
|
|
1988
|
+
!rd_strcasecmp(value, "t") || !strcmp(value, "1"))
|
|
1989
|
+
ival = 1;
|
|
1990
|
+
else if (!rd_strcasecmp(value, "false") ||
|
|
1991
|
+
!rd_strcasecmp(value, "f") || !strcmp(value, "0"))
|
|
1992
|
+
ival = 0;
|
|
1993
|
+
else {
|
|
1994
|
+
rd_snprintf(errstr, errstr_size,
|
|
1995
|
+
"Expected bool value for \"%s\": "
|
|
1996
|
+
"true or false",
|
|
1997
|
+
prop->name);
|
|
1998
|
+
return RD_KAFKA_CONF_INVALID;
|
|
1999
|
+
}
|
|
2000
|
+
|
|
2001
|
+
rd_kafka_anyconf_set_prop0(scope, conf, prop, value, ival,
|
|
2002
|
+
_RK_CONF_PROP_SET_REPLACE, errstr,
|
|
2003
|
+
errstr_size);
|
|
2004
|
+
return RD_KAFKA_CONF_OK;
|
|
2005
|
+
|
|
2006
|
+
case _RK_C_INT: {
|
|
2007
|
+
const char *end;
|
|
2008
|
+
|
|
2009
|
+
if (!value) {
|
|
2010
|
+
rd_snprintf(errstr, errstr_size,
|
|
2011
|
+
"Integer configuration "
|
|
2012
|
+
"property \"%s\" cannot be set "
|
|
2013
|
+
"to empty value",
|
|
2014
|
+
prop->name);
|
|
2015
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2016
|
+
}
|
|
2017
|
+
|
|
2018
|
+
ival = (int)strtol(value, (char **)&end, 0);
|
|
2019
|
+
if (end == value) {
|
|
2020
|
+
/* Non numeric, check s2i for string mapping */
|
|
2021
|
+
int match = rd_kafka_conf_s2i_find(prop, value);
|
|
2022
|
+
|
|
2023
|
+
if (match == -1) {
|
|
2024
|
+
rd_snprintf(errstr, errstr_size,
|
|
2025
|
+
"Invalid value for "
|
|
2026
|
+
"configuration property \"%s\"",
|
|
2027
|
+
prop->name);
|
|
2028
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
if (prop->s2i[match].unsupported) {
|
|
2032
|
+
rd_snprintf(errstr, errstr_size,
|
|
2033
|
+
"Unsupported value \"%s\" for "
|
|
2034
|
+
"configuration property \"%s\": %s",
|
|
2035
|
+
value, prop->name,
|
|
2036
|
+
prop->s2i[match].unsupported);
|
|
2037
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2038
|
+
}
|
|
2039
|
+
|
|
2040
|
+
ival = prop->s2i[match].val;
|
|
2041
|
+
}
|
|
2042
|
+
|
|
2043
|
+
if (ival < prop->vmin || ival > prop->vmax) {
|
|
2044
|
+
rd_snprintf(errstr, errstr_size,
|
|
2045
|
+
"Configuration property \"%s\" value "
|
|
2046
|
+
"%i is outside allowed range %i..%i\n",
|
|
2047
|
+
prop->name, ival, prop->vmin, prop->vmax);
|
|
2048
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
rd_kafka_anyconf_set_prop0(scope, conf, prop, value, ival,
|
|
2052
|
+
_RK_CONF_PROP_SET_REPLACE, errstr,
|
|
2053
|
+
errstr_size);
|
|
2054
|
+
return RD_KAFKA_CONF_OK;
|
|
2055
|
+
}
|
|
2056
|
+
|
|
2057
|
+
case _RK_C_DBL: {
|
|
2058
|
+
const char *end;
|
|
2059
|
+
double dval;
|
|
2060
|
+
|
|
2061
|
+
if (!value) {
|
|
2062
|
+
rd_snprintf(errstr, errstr_size,
|
|
2063
|
+
"Float configuration "
|
|
2064
|
+
"property \"%s\" cannot be set "
|
|
2065
|
+
"to empty value",
|
|
2066
|
+
prop->name);
|
|
2067
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2068
|
+
}
|
|
2069
|
+
|
|
2070
|
+
dval = strtod(value, (char **)&end);
|
|
2071
|
+
if (end == value) {
|
|
2072
|
+
rd_snprintf(errstr, errstr_size,
|
|
2073
|
+
"Invalid value for "
|
|
2074
|
+
"configuration property \"%s\"",
|
|
2075
|
+
prop->name);
|
|
2076
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2077
|
+
}
|
|
2078
|
+
|
|
2079
|
+
if (dval < prop->dmin || dval > prop->dmax) {
|
|
2080
|
+
rd_snprintf(errstr, errstr_size,
|
|
2081
|
+
"Configuration property \"%s\" value "
|
|
2082
|
+
"%g is outside allowed range %g..%g\n",
|
|
2083
|
+
prop->name, dval, prop->dmin, prop->dmax);
|
|
2084
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
rd_kafka_anyconf_set_prop0(scope, conf, prop, value, 0,
|
|
2088
|
+
_RK_CONF_PROP_SET_REPLACE, errstr,
|
|
2089
|
+
errstr_size);
|
|
2090
|
+
return RD_KAFKA_CONF_OK;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
case _RK_C_S2I:
|
|
2094
|
+
case _RK_C_S2F: {
|
|
2095
|
+
int j;
|
|
2096
|
+
const char *next;
|
|
2097
|
+
|
|
2098
|
+
if (!value) {
|
|
2099
|
+
rd_snprintf(errstr, errstr_size,
|
|
2100
|
+
"Configuration "
|
|
2101
|
+
"property \"%s\" cannot be set "
|
|
2102
|
+
"to empty value",
|
|
2103
|
+
prop->name);
|
|
2104
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2105
|
+
}
|
|
2106
|
+
|
|
2107
|
+
next = value;
|
|
2108
|
+
while (next && *next) {
|
|
2109
|
+
const char *s, *t;
|
|
2110
|
+
rd_kafka_conf_set_mode_t set_mode =
|
|
2111
|
+
_RK_CONF_PROP_SET_ADD; /* S2F */
|
|
2112
|
+
|
|
2113
|
+
s = next;
|
|
2114
|
+
|
|
2115
|
+
if (prop->type == _RK_C_S2F && (t = strchr(s, ','))) {
|
|
2116
|
+
/* CSV flag field */
|
|
2117
|
+
next = t + 1;
|
|
2118
|
+
} else {
|
|
2119
|
+
/* Single string */
|
|
2120
|
+
t = s + strlen(s);
|
|
2121
|
+
next = NULL;
|
|
2122
|
+
}
|
|
2123
|
+
|
|
2124
|
+
|
|
2125
|
+
/* Left trim */
|
|
2126
|
+
while (s < t && isspace((int)*s))
|
|
2127
|
+
s++;
|
|
2128
|
+
|
|
2129
|
+
/* Right trim */
|
|
2130
|
+
while (t > s && isspace((int)*t))
|
|
2131
|
+
t--;
|
|
2132
|
+
|
|
2133
|
+
/* S2F: +/- prefix */
|
|
2134
|
+
if (prop->type == _RK_C_S2F) {
|
|
2135
|
+
if (*s == '+') {
|
|
2136
|
+
set_mode = _RK_CONF_PROP_SET_ADD;
|
|
2137
|
+
s++;
|
|
2138
|
+
} else if (*s == '-') {
|
|
2139
|
+
set_mode = _RK_CONF_PROP_SET_DEL;
|
|
2140
|
+
s++;
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2143
|
+
|
|
2144
|
+
/* Empty string? */
|
|
2145
|
+
if (s == t)
|
|
2146
|
+
continue;
|
|
2147
|
+
|
|
2148
|
+
/* Match string to s2i table entry */
|
|
2149
|
+
for (j = 0; j < (int)RD_ARRAYSIZE(prop->s2i); j++) {
|
|
2150
|
+
int new_val;
|
|
2151
|
+
|
|
2152
|
+
if (!prop->s2i[j].str)
|
|
2153
|
+
continue;
|
|
2154
|
+
|
|
2155
|
+
if (strlen(prop->s2i[j].str) ==
|
|
2156
|
+
(size_t)(t - s) &&
|
|
2157
|
+
!rd_strncasecmp(prop->s2i[j].str, s,
|
|
2158
|
+
(int)(t - s)))
|
|
2159
|
+
new_val = prop->s2i[j].val;
|
|
2160
|
+
else
|
|
2161
|
+
continue;
|
|
2162
|
+
|
|
2163
|
+
if (prop->s2i[j].unsupported) {
|
|
2164
|
+
rd_snprintf(
|
|
2165
|
+
errstr, errstr_size,
|
|
2166
|
+
"Unsupported value \"%.*s\" "
|
|
2167
|
+
"for configuration property "
|
|
2168
|
+
"\"%s\": %s",
|
|
2169
|
+
(int)(t - s), s, prop->name,
|
|
2170
|
+
prop->s2i[j].unsupported);
|
|
2171
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
rd_kafka_anyconf_set_prop0(
|
|
2175
|
+
scope, conf, prop, value, new_val, set_mode,
|
|
2176
|
+
errstr, errstr_size);
|
|
2177
|
+
|
|
2178
|
+
if (prop->type == _RK_C_S2F) {
|
|
2179
|
+
/* Flags: OR it in: do next */
|
|
2180
|
+
break;
|
|
2181
|
+
} else {
|
|
2182
|
+
/* Single assignment */
|
|
2183
|
+
return RD_KAFKA_CONF_OK;
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
|
|
2187
|
+
/* S2F: Good match: continue with next */
|
|
2188
|
+
if (j < (int)RD_ARRAYSIZE(prop->s2i))
|
|
2189
|
+
continue;
|
|
2190
|
+
|
|
2191
|
+
/* No match */
|
|
2192
|
+
rd_snprintf(errstr, errstr_size,
|
|
2193
|
+
"Invalid value \"%.*s\" for "
|
|
2194
|
+
"configuration property \"%s\"",
|
|
2195
|
+
(int)(t - s), s, prop->name);
|
|
2196
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2197
|
+
}
|
|
2198
|
+
return RD_KAFKA_CONF_OK;
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
case _RK_C_INTERNAL:
|
|
2202
|
+
rd_snprintf(errstr, errstr_size,
|
|
2203
|
+
"Internal property \"%s\" not settable",
|
|
2204
|
+
prop->name);
|
|
2205
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2206
|
+
|
|
2207
|
+
case _RK_C_INVALID:
|
|
2208
|
+
rd_snprintf(errstr, errstr_size, "%s", prop->desc);
|
|
2209
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2210
|
+
|
|
2211
|
+
default:
|
|
2212
|
+
rd_kafka_assert(NULL, !*"unknown conf type");
|
|
2213
|
+
}
|
|
2214
|
+
|
|
2215
|
+
/* not reachable */
|
|
2216
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2217
|
+
}
|
|
2218
|
+
|
|
2219
|
+
|
|
2220
|
+
|
|
2221
|
+
static void rd_kafka_defaultconf_set(int scope, void *conf) {
|
|
2222
|
+
const struct rd_kafka_property *prop;
|
|
2223
|
+
|
|
2224
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
2225
|
+
if (!(prop->scope & scope))
|
|
2226
|
+
continue;
|
|
2227
|
+
|
|
2228
|
+
if (prop->type == _RK_C_ALIAS || prop->type == _RK_C_INVALID)
|
|
2229
|
+
continue;
|
|
2230
|
+
|
|
2231
|
+
if (prop->ctor)
|
|
2232
|
+
prop->ctor(scope, conf);
|
|
2233
|
+
|
|
2234
|
+
if (prop->sdef || prop->vdef || prop->pdef ||
|
|
2235
|
+
!rd_dbl_zero(prop->ddef))
|
|
2236
|
+
rd_kafka_anyconf_set_prop0(
|
|
2237
|
+
scope, conf, prop,
|
|
2238
|
+
prop->sdef ? prop->sdef : prop->pdef, prop->vdef,
|
|
2239
|
+
_RK_CONF_PROP_SET_REPLACE, NULL, 0);
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
rd_kafka_conf_t *rd_kafka_conf_new(void) {
|
|
2244
|
+
rd_kafka_conf_t *conf = rd_calloc(1, sizeof(*conf));
|
|
2245
|
+
rd_assert(RD_KAFKA_CONF_PROPS_IDX_MAX > sizeof(*conf) &&
|
|
2246
|
+
*"Increase RD_KAFKA_CONF_PROPS_IDX_MAX");
|
|
2247
|
+
rd_kafka_defaultconf_set(_RK_GLOBAL, conf);
|
|
2248
|
+
rd_kafka_anyconf_clear_all_is_modified(conf);
|
|
2249
|
+
return conf;
|
|
2250
|
+
}
|
|
2251
|
+
|
|
2252
|
+
rd_kafka_topic_conf_t *rd_kafka_topic_conf_new(void) {
|
|
2253
|
+
rd_kafka_topic_conf_t *tconf = rd_calloc(1, sizeof(*tconf));
|
|
2254
|
+
rd_assert(RD_KAFKA_CONF_PROPS_IDX_MAX > sizeof(*tconf) &&
|
|
2255
|
+
*"Increase RD_KAFKA_CONF_PROPS_IDX_MAX");
|
|
2256
|
+
rd_kafka_defaultconf_set(_RK_TOPIC, tconf);
|
|
2257
|
+
rd_kafka_anyconf_clear_all_is_modified(tconf);
|
|
2258
|
+
return tconf;
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
|
|
2262
|
+
static int rd_kafka_anyconf_set(int scope,
|
|
2263
|
+
void *conf,
|
|
2264
|
+
const char *name,
|
|
2265
|
+
const char *value,
|
|
2266
|
+
char *errstr,
|
|
2267
|
+
size_t errstr_size) {
|
|
2268
|
+
char estmp[1];
|
|
2269
|
+
const struct rd_kafka_property *prop;
|
|
2270
|
+
rd_kafka_conf_res_t res;
|
|
2271
|
+
|
|
2272
|
+
if (!errstr) {
|
|
2273
|
+
errstr = estmp;
|
|
2274
|
+
errstr_size = 0;
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2277
|
+
if (value && !*value)
|
|
2278
|
+
value = NULL;
|
|
2279
|
+
|
|
2280
|
+
/* Try interceptors first (only for GLOBAL config for now) */
|
|
2281
|
+
if (scope & _RK_GLOBAL) {
|
|
2282
|
+
res = rd_kafka_interceptors_on_conf_set(
|
|
2283
|
+
(rd_kafka_conf_t *)conf, name, value, errstr, errstr_size);
|
|
2284
|
+
/* Handled (successfully or not) by interceptor. */
|
|
2285
|
+
if (res != RD_KAFKA_CONF_UNKNOWN)
|
|
2286
|
+
return res;
|
|
2287
|
+
}
|
|
2288
|
+
|
|
2289
|
+
/* Then global config */
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
2293
|
+
|
|
2294
|
+
if (!(prop->scope & scope))
|
|
2295
|
+
continue;
|
|
2296
|
+
|
|
2297
|
+
if (strcmp(prop->name, name))
|
|
2298
|
+
continue;
|
|
2299
|
+
|
|
2300
|
+
if (prop->type == _RK_C_ALIAS)
|
|
2301
|
+
return rd_kafka_anyconf_set(scope, conf, prop->sdef,
|
|
2302
|
+
value, errstr, errstr_size);
|
|
2303
|
+
|
|
2304
|
+
return rd_kafka_anyconf_set_prop(scope, conf, prop, value,
|
|
2305
|
+
0 /*don't allow specifics*/,
|
|
2306
|
+
errstr, errstr_size);
|
|
2307
|
+
}
|
|
2308
|
+
|
|
2309
|
+
rd_snprintf(errstr, errstr_size,
|
|
2310
|
+
"No such configuration property: \"%s\"", name);
|
|
2311
|
+
|
|
2312
|
+
return RD_KAFKA_CONF_UNKNOWN;
|
|
2313
|
+
}
|
|
2314
|
+
|
|
2315
|
+
|
|
2316
|
+
/**
|
|
2317
|
+
* @brief Set a rd_kafka_*_conf_set_...() specific property, such as
|
|
2318
|
+
* rd_kafka_conf_set_error_cb().
|
|
2319
|
+
*
|
|
2320
|
+
* @warning Will not call interceptor's on_conf_set.
|
|
2321
|
+
* @warning Asserts if \p name is not known or value is incorrect.
|
|
2322
|
+
*
|
|
2323
|
+
* Implemented as a macro to have rd_assert() print the original function.
|
|
2324
|
+
*/
|
|
2325
|
+
|
|
2326
|
+
#define rd_kafka_anyconf_set_internal(SCOPE, CONF, NAME, VALUE) \
|
|
2327
|
+
do { \
|
|
2328
|
+
const struct rd_kafka_property *_prop; \
|
|
2329
|
+
rd_kafka_conf_res_t _res; \
|
|
2330
|
+
_prop = rd_kafka_conf_prop_find(SCOPE, NAME); \
|
|
2331
|
+
rd_assert(_prop && * "invalid property name"); \
|
|
2332
|
+
_res = rd_kafka_anyconf_set_prop( \
|
|
2333
|
+
SCOPE, CONF, _prop, (const void *)VALUE, \
|
|
2334
|
+
1 /*allow-specifics*/, NULL, 0); \
|
|
2335
|
+
rd_assert(_res == RD_KAFKA_CONF_OK); \
|
|
2336
|
+
} while (0)
|
|
2337
|
+
|
|
2338
|
+
|
|
2339
|
+
rd_kafka_conf_res_t rd_kafka_conf_set(rd_kafka_conf_t *conf,
|
|
2340
|
+
const char *name,
|
|
2341
|
+
const char *value,
|
|
2342
|
+
char *errstr,
|
|
2343
|
+
size_t errstr_size) {
|
|
2344
|
+
rd_kafka_conf_res_t res;
|
|
2345
|
+
|
|
2346
|
+
res = rd_kafka_anyconf_set(_RK_GLOBAL, conf, name, value, errstr,
|
|
2347
|
+
errstr_size);
|
|
2348
|
+
if (res != RD_KAFKA_CONF_UNKNOWN)
|
|
2349
|
+
return res;
|
|
2350
|
+
|
|
2351
|
+
/* Fallthru:
|
|
2352
|
+
* If the global property was unknown, try setting it on the
|
|
2353
|
+
* default topic config. */
|
|
2354
|
+
if (!conf->topic_conf) {
|
|
2355
|
+
/* Create topic config, might be over-written by application
|
|
2356
|
+
* later. */
|
|
2357
|
+
rd_kafka_conf_set_default_topic_conf(conf,
|
|
2358
|
+
rd_kafka_topic_conf_new());
|
|
2359
|
+
}
|
|
2360
|
+
|
|
2361
|
+
return rd_kafka_topic_conf_set(conf->topic_conf, name, value, errstr,
|
|
2362
|
+
errstr_size);
|
|
2363
|
+
}
|
|
2364
|
+
|
|
2365
|
+
|
|
2366
|
+
rd_kafka_conf_res_t rd_kafka_topic_conf_set(rd_kafka_topic_conf_t *conf,
|
|
2367
|
+
const char *name,
|
|
2368
|
+
const char *value,
|
|
2369
|
+
char *errstr,
|
|
2370
|
+
size_t errstr_size) {
|
|
2371
|
+
if (!strncmp(name, "topic.", strlen("topic.")))
|
|
2372
|
+
name += strlen("topic.");
|
|
2373
|
+
|
|
2374
|
+
return rd_kafka_anyconf_set(_RK_TOPIC, conf, name, value, errstr,
|
|
2375
|
+
errstr_size);
|
|
2376
|
+
}
|
|
2377
|
+
|
|
2378
|
+
|
|
2379
|
+
/**
|
|
2380
|
+
* @brief Overwrites the contents of \p str up until but not including
|
|
2381
|
+
* the nul-term.
|
|
2382
|
+
*/
|
|
2383
|
+
void rd_kafka_desensitize_str(char *str) {
|
|
2384
|
+
size_t len;
|
|
2385
|
+
static const char redacted[] = "(REDACTED)";
|
|
2386
|
+
|
|
2387
|
+
#ifdef _WIN32
|
|
2388
|
+
len = strlen(str);
|
|
2389
|
+
SecureZeroMemory(str, len);
|
|
2390
|
+
#else
|
|
2391
|
+
volatile char *volatile s;
|
|
2392
|
+
|
|
2393
|
+
for (s = str; *s; s++)
|
|
2394
|
+
*s = '\0';
|
|
2395
|
+
|
|
2396
|
+
len = (size_t)(s - str);
|
|
2397
|
+
#endif
|
|
2398
|
+
|
|
2399
|
+
if (len > sizeof(redacted))
|
|
2400
|
+
memcpy(str, redacted, sizeof(redacted));
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
|
|
2405
|
+
/**
|
|
2406
|
+
* @brief Overwrite the value of \p prop, if sensitive.
|
|
2407
|
+
*/
|
|
2408
|
+
static RD_INLINE void
|
|
2409
|
+
rd_kafka_anyconf_prop_desensitize(int scope,
|
|
2410
|
+
void *conf,
|
|
2411
|
+
const struct rd_kafka_property *prop) {
|
|
2412
|
+
if (likely(!(prop->scope & _RK_SENSITIVE)))
|
|
2413
|
+
return;
|
|
2414
|
+
|
|
2415
|
+
switch (prop->type) {
|
|
2416
|
+
case _RK_C_STR: {
|
|
2417
|
+
char **str = _RK_PTR(char **, conf, prop->offset);
|
|
2418
|
+
if (*str)
|
|
2419
|
+
rd_kafka_desensitize_str(*str);
|
|
2420
|
+
break;
|
|
2421
|
+
}
|
|
2422
|
+
|
|
2423
|
+
case _RK_C_INTERNAL:
|
|
2424
|
+
/* This is typically a pointer to something, the
|
|
2425
|
+
* _RK_SENSITIVE flag is set to get it redacted in
|
|
2426
|
+
* ..dump_dbg(), but we don't have to desensitize
|
|
2427
|
+
* anything here. */
|
|
2428
|
+
break;
|
|
2429
|
+
|
|
2430
|
+
default:
|
|
2431
|
+
rd_assert(!*"BUG: Don't know how to desensitize prop type");
|
|
2432
|
+
break;
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
|
|
2437
|
+
/**
|
|
2438
|
+
* @brief Desensitize all sensitive properties in \p conf
|
|
2439
|
+
*/
|
|
2440
|
+
static void rd_kafka_anyconf_desensitize(int scope, void *conf) {
|
|
2441
|
+
const struct rd_kafka_property *prop;
|
|
2442
|
+
|
|
2443
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
2444
|
+
if (!(prop->scope & scope))
|
|
2445
|
+
continue;
|
|
2446
|
+
|
|
2447
|
+
rd_kafka_anyconf_prop_desensitize(scope, conf, prop);
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* @brief Overwrite the values of sensitive properties
|
|
2453
|
+
*/
|
|
2454
|
+
void rd_kafka_conf_desensitize(rd_kafka_conf_t *conf) {
|
|
2455
|
+
if (conf->topic_conf)
|
|
2456
|
+
rd_kafka_anyconf_desensitize(_RK_TOPIC, conf->topic_conf);
|
|
2457
|
+
rd_kafka_anyconf_desensitize(_RK_GLOBAL, conf);
|
|
2458
|
+
}
|
|
2459
|
+
|
|
2460
|
+
/**
|
|
2461
|
+
* @brief Overwrite the values of sensitive properties
|
|
2462
|
+
*/
|
|
2463
|
+
void rd_kafka_topic_conf_desensitize(rd_kafka_topic_conf_t *tconf) {
|
|
2464
|
+
rd_kafka_anyconf_desensitize(_RK_TOPIC, tconf);
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
|
|
2468
|
+
static void rd_kafka_anyconf_clear(int scope,
|
|
2469
|
+
void *conf,
|
|
2470
|
+
const struct rd_kafka_property *prop) {
|
|
2471
|
+
|
|
2472
|
+
rd_kafka_anyconf_prop_desensitize(scope, conf, prop);
|
|
2473
|
+
|
|
2474
|
+
switch (prop->type) {
|
|
2475
|
+
case _RK_C_STR: {
|
|
2476
|
+
char **str = _RK_PTR(char **, conf, prop->offset);
|
|
2477
|
+
|
|
2478
|
+
if (*str) {
|
|
2479
|
+
if (prop->set) {
|
|
2480
|
+
prop->set(scope, conf, prop->name, NULL, *str,
|
|
2481
|
+
_RK_CONF_PROP_SET_DEL, NULL, 0);
|
|
2482
|
+
/* FALLTHRU */
|
|
2483
|
+
}
|
|
2484
|
+
rd_free(*str);
|
|
2485
|
+
*str = NULL;
|
|
2486
|
+
}
|
|
2487
|
+
} break;
|
|
2488
|
+
|
|
2489
|
+
case _RK_C_KSTR: {
|
|
2490
|
+
rd_kafkap_str_t **kstr =
|
|
2491
|
+
_RK_PTR(rd_kafkap_str_t **, conf, prop->offset);
|
|
2492
|
+
if (*kstr) {
|
|
2493
|
+
rd_kafkap_str_destroy(*kstr);
|
|
2494
|
+
*kstr = NULL;
|
|
2495
|
+
}
|
|
2496
|
+
} break;
|
|
2497
|
+
|
|
2498
|
+
case _RK_C_PATLIST: {
|
|
2499
|
+
rd_kafka_pattern_list_t **plist;
|
|
2500
|
+
plist = _RK_PTR(rd_kafka_pattern_list_t **, conf, prop->offset);
|
|
2501
|
+
if (*plist) {
|
|
2502
|
+
rd_kafka_pattern_list_destroy(*plist);
|
|
2503
|
+
*plist = NULL;
|
|
2504
|
+
}
|
|
2505
|
+
} break;
|
|
2506
|
+
|
|
2507
|
+
case _RK_C_PTR:
|
|
2508
|
+
if (_RK_PTR(void *, conf, prop->offset) != NULL) {
|
|
2509
|
+
if (!strcmp(prop->name, "default_topic_conf")) {
|
|
2510
|
+
rd_kafka_topic_conf_t **tconf;
|
|
2511
|
+
|
|
2512
|
+
tconf = _RK_PTR(rd_kafka_topic_conf_t **, conf,
|
|
2513
|
+
prop->offset);
|
|
2514
|
+
if (*tconf) {
|
|
2515
|
+
rd_kafka_topic_conf_destroy(*tconf);
|
|
2516
|
+
*tconf = NULL;
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
}
|
|
2520
|
+
break;
|
|
2521
|
+
|
|
2522
|
+
default:
|
|
2523
|
+
break;
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
if (prop->dtor)
|
|
2527
|
+
prop->dtor(scope, conf);
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
void rd_kafka_anyconf_destroy(int scope, void *conf) {
|
|
2531
|
+
const struct rd_kafka_property *prop;
|
|
2532
|
+
|
|
2533
|
+
/* Call on_conf_destroy() interceptors */
|
|
2534
|
+
if (scope == _RK_GLOBAL)
|
|
2535
|
+
rd_kafka_interceptors_on_conf_destroy(conf);
|
|
2536
|
+
|
|
2537
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
2538
|
+
if (!(prop->scope & scope))
|
|
2539
|
+
continue;
|
|
2540
|
+
|
|
2541
|
+
rd_kafka_anyconf_clear(scope, conf, prop);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
|
|
2546
|
+
void rd_kafka_conf_destroy(rd_kafka_conf_t *conf) {
|
|
2547
|
+
rd_kafka_anyconf_destroy(_RK_GLOBAL, conf);
|
|
2548
|
+
// FIXME: partition_assignors
|
|
2549
|
+
rd_free(conf);
|
|
2550
|
+
}
|
|
2551
|
+
|
|
2552
|
+
void rd_kafka_topic_conf_destroy(rd_kafka_topic_conf_t *topic_conf) {
|
|
2553
|
+
rd_kafka_anyconf_destroy(_RK_TOPIC, topic_conf);
|
|
2554
|
+
rd_free(topic_conf);
|
|
2555
|
+
}
|
|
2556
|
+
|
|
2557
|
+
|
|
2558
|
+
|
|
2559
|
+
static void rd_kafka_anyconf_copy(int scope,
|
|
2560
|
+
void *dst,
|
|
2561
|
+
const void *src,
|
|
2562
|
+
size_t filter_cnt,
|
|
2563
|
+
const char **filter) {
|
|
2564
|
+
const struct rd_kafka_property *prop;
|
|
2565
|
+
|
|
2566
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
2567
|
+
const char *val = NULL;
|
|
2568
|
+
int ival = 0;
|
|
2569
|
+
char *valstr;
|
|
2570
|
+
size_t valsz;
|
|
2571
|
+
size_t fi;
|
|
2572
|
+
size_t nlen;
|
|
2573
|
+
|
|
2574
|
+
if (!(prop->scope & scope))
|
|
2575
|
+
continue;
|
|
2576
|
+
|
|
2577
|
+
if (prop->type == _RK_C_ALIAS || prop->type == _RK_C_INVALID)
|
|
2578
|
+
continue;
|
|
2579
|
+
|
|
2580
|
+
/* Skip properties that have not been set,
|
|
2581
|
+
* unless it is an internal one which requires
|
|
2582
|
+
* extra logic, such as the interceptors. */
|
|
2583
|
+
if (!rd_kafka_anyconf_is_modified(src, prop) &&
|
|
2584
|
+
prop->type != _RK_C_INTERNAL)
|
|
2585
|
+
continue;
|
|
2586
|
+
|
|
2587
|
+
/* Apply filter, if any. */
|
|
2588
|
+
nlen = strlen(prop->name);
|
|
2589
|
+
for (fi = 0; fi < filter_cnt; fi++) {
|
|
2590
|
+
size_t flen = strlen(filter[fi]);
|
|
2591
|
+
if (nlen >= flen &&
|
|
2592
|
+
!strncmp(filter[fi], prop->name, flen))
|
|
2593
|
+
break;
|
|
2594
|
+
}
|
|
2595
|
+
if (fi < filter_cnt)
|
|
2596
|
+
continue; /* Filter matched */
|
|
2597
|
+
|
|
2598
|
+
switch (prop->type) {
|
|
2599
|
+
case _RK_C_STR:
|
|
2600
|
+
case _RK_C_PTR:
|
|
2601
|
+
val = *_RK_PTR(const char **, src, prop->offset);
|
|
2602
|
+
|
|
2603
|
+
if (!strcmp(prop->name, "default_topic_conf") && val)
|
|
2604
|
+
val = (void *)rd_kafka_topic_conf_dup(
|
|
2605
|
+
(const rd_kafka_topic_conf_t *)(void *)val);
|
|
2606
|
+
break;
|
|
2607
|
+
case _RK_C_KSTR: {
|
|
2608
|
+
rd_kafkap_str_t **kstr =
|
|
2609
|
+
_RK_PTR(rd_kafkap_str_t **, src, prop->offset);
|
|
2610
|
+
if (*kstr)
|
|
2611
|
+
val = (*kstr)->str;
|
|
2612
|
+
break;
|
|
2613
|
+
}
|
|
2614
|
+
|
|
2615
|
+
case _RK_C_BOOL:
|
|
2616
|
+
case _RK_C_INT:
|
|
2617
|
+
case _RK_C_S2I:
|
|
2618
|
+
case _RK_C_S2F:
|
|
2619
|
+
ival = *_RK_PTR(const int *, src, prop->offset);
|
|
2620
|
+
|
|
2621
|
+
/* Get string representation of configuration value. */
|
|
2622
|
+
valsz = 0;
|
|
2623
|
+
rd_kafka_anyconf_get0(src, prop, NULL, &valsz);
|
|
2624
|
+
valstr = rd_alloca(valsz);
|
|
2625
|
+
rd_kafka_anyconf_get0(src, prop, valstr, &valsz);
|
|
2626
|
+
val = valstr;
|
|
2627
|
+
break;
|
|
2628
|
+
case _RK_C_DBL:
|
|
2629
|
+
/* Get string representation of configuration value. */
|
|
2630
|
+
valsz = 0;
|
|
2631
|
+
rd_kafka_anyconf_get0(src, prop, NULL, &valsz);
|
|
2632
|
+
valstr = rd_alloca(valsz);
|
|
2633
|
+
rd_kafka_anyconf_get0(src, prop, valstr, &valsz);
|
|
2634
|
+
val = valstr;
|
|
2635
|
+
break;
|
|
2636
|
+
case _RK_C_PATLIST: {
|
|
2637
|
+
const rd_kafka_pattern_list_t **plist;
|
|
2638
|
+
plist = _RK_PTR(const rd_kafka_pattern_list_t **, src,
|
|
2639
|
+
prop->offset);
|
|
2640
|
+
if (*plist)
|
|
2641
|
+
val = (*plist)->rkpl_orig;
|
|
2642
|
+
break;
|
|
2643
|
+
}
|
|
2644
|
+
case _RK_C_INTERNAL:
|
|
2645
|
+
/* Handled by ->copy() below. */
|
|
2646
|
+
break;
|
|
2647
|
+
default:
|
|
2648
|
+
continue;
|
|
2649
|
+
}
|
|
2650
|
+
|
|
2651
|
+
if (prop->copy)
|
|
2652
|
+
prop->copy(scope, dst, src,
|
|
2653
|
+
_RK_PTR(void *, dst, prop->offset),
|
|
2654
|
+
_RK_PTR(const void *, src, prop->offset),
|
|
2655
|
+
filter_cnt, filter);
|
|
2656
|
+
|
|
2657
|
+
rd_kafka_anyconf_set_prop0(scope, dst, prop, val, ival,
|
|
2658
|
+
_RK_CONF_PROP_SET_REPLACE, NULL, 0);
|
|
2659
|
+
}
|
|
2660
|
+
}
|
|
2661
|
+
|
|
2662
|
+
|
|
2663
|
+
rd_kafka_conf_t *rd_kafka_conf_dup(const rd_kafka_conf_t *conf) {
|
|
2664
|
+
rd_kafka_conf_t *new = rd_kafka_conf_new();
|
|
2665
|
+
|
|
2666
|
+
rd_kafka_interceptors_on_conf_dup(new, conf, 0, NULL);
|
|
2667
|
+
|
|
2668
|
+
rd_kafka_anyconf_copy(_RK_GLOBAL, new, conf, 0, NULL);
|
|
2669
|
+
|
|
2670
|
+
return new;
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
rd_kafka_conf_t *rd_kafka_conf_dup_filter(const rd_kafka_conf_t *conf,
|
|
2674
|
+
size_t filter_cnt,
|
|
2675
|
+
const char **filter) {
|
|
2676
|
+
rd_kafka_conf_t *new = rd_kafka_conf_new();
|
|
2677
|
+
|
|
2678
|
+
rd_kafka_interceptors_on_conf_dup(new, conf, filter_cnt, filter);
|
|
2679
|
+
|
|
2680
|
+
rd_kafka_anyconf_copy(_RK_GLOBAL, new, conf, filter_cnt, filter);
|
|
2681
|
+
|
|
2682
|
+
return new;
|
|
2683
|
+
}
|
|
2684
|
+
|
|
2685
|
+
|
|
2686
|
+
rd_kafka_topic_conf_t *
|
|
2687
|
+
rd_kafka_topic_conf_dup(const rd_kafka_topic_conf_t *conf) {
|
|
2688
|
+
rd_kafka_topic_conf_t *new = rd_kafka_topic_conf_new();
|
|
2689
|
+
|
|
2690
|
+
rd_kafka_anyconf_copy(_RK_TOPIC, new, conf, 0, NULL);
|
|
2691
|
+
|
|
2692
|
+
return new;
|
|
2693
|
+
}
|
|
2694
|
+
|
|
2695
|
+
rd_kafka_topic_conf_t *rd_kafka_default_topic_conf_dup(rd_kafka_t *rk) {
|
|
2696
|
+
if (rk->rk_conf.topic_conf)
|
|
2697
|
+
return rd_kafka_topic_conf_dup(rk->rk_conf.topic_conf);
|
|
2698
|
+
else
|
|
2699
|
+
return rd_kafka_topic_conf_new();
|
|
2700
|
+
}
|
|
2701
|
+
|
|
2702
|
+
void rd_kafka_conf_set_events(rd_kafka_conf_t *conf, int events) {
|
|
2703
|
+
char tmp[32];
|
|
2704
|
+
rd_snprintf(tmp, sizeof(tmp), "%d", events);
|
|
2705
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "enabled_events", tmp);
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2708
|
+
void rd_kafka_conf_set_background_event_cb(
|
|
2709
|
+
rd_kafka_conf_t *conf,
|
|
2710
|
+
void (*event_cb)(rd_kafka_t *rk, rd_kafka_event_t *rkev, void *opaque)) {
|
|
2711
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "background_event_cb",
|
|
2712
|
+
event_cb);
|
|
2713
|
+
}
|
|
2714
|
+
|
|
2715
|
+
|
|
2716
|
+
void rd_kafka_conf_set_dr_cb(rd_kafka_conf_t *conf,
|
|
2717
|
+
void (*dr_cb)(rd_kafka_t *rk,
|
|
2718
|
+
void *payload,
|
|
2719
|
+
size_t len,
|
|
2720
|
+
rd_kafka_resp_err_t err,
|
|
2721
|
+
void *opaque,
|
|
2722
|
+
void *msg_opaque)) {
|
|
2723
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "dr_cb", dr_cb);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
|
|
2727
|
+
void rd_kafka_conf_set_dr_msg_cb(
|
|
2728
|
+
rd_kafka_conf_t *conf,
|
|
2729
|
+
void (*dr_msg_cb)(rd_kafka_t *rk,
|
|
2730
|
+
const rd_kafka_message_t *rkmessage,
|
|
2731
|
+
void *opaque)) {
|
|
2732
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "dr_msg_cb", dr_msg_cb);
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
|
|
2736
|
+
void rd_kafka_conf_set_consume_cb(
|
|
2737
|
+
rd_kafka_conf_t *conf,
|
|
2738
|
+
void (*consume_cb)(rd_kafka_message_t *rkmessage, void *opaque)) {
|
|
2739
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "consume_cb",
|
|
2740
|
+
consume_cb);
|
|
2741
|
+
}
|
|
2742
|
+
|
|
2743
|
+
void rd_kafka_conf_set_rebalance_cb(
|
|
2744
|
+
rd_kafka_conf_t *conf,
|
|
2745
|
+
void (*rebalance_cb)(rd_kafka_t *rk,
|
|
2746
|
+
rd_kafka_resp_err_t err,
|
|
2747
|
+
rd_kafka_topic_partition_list_t *partitions,
|
|
2748
|
+
void *opaque)) {
|
|
2749
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "rebalance_cb",
|
|
2750
|
+
rebalance_cb);
|
|
2751
|
+
}
|
|
2752
|
+
|
|
2753
|
+
void rd_kafka_conf_set_offset_commit_cb(
|
|
2754
|
+
rd_kafka_conf_t *conf,
|
|
2755
|
+
void (*offset_commit_cb)(rd_kafka_t *rk,
|
|
2756
|
+
rd_kafka_resp_err_t err,
|
|
2757
|
+
rd_kafka_topic_partition_list_t *offsets,
|
|
2758
|
+
void *opaque)) {
|
|
2759
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "offset_commit_cb",
|
|
2760
|
+
offset_commit_cb);
|
|
2761
|
+
}
|
|
2762
|
+
|
|
2763
|
+
|
|
2764
|
+
|
|
2765
|
+
void rd_kafka_conf_set_error_cb(rd_kafka_conf_t *conf,
|
|
2766
|
+
void (*error_cb)(rd_kafka_t *rk,
|
|
2767
|
+
int err,
|
|
2768
|
+
const char *reason,
|
|
2769
|
+
void *opaque)) {
|
|
2770
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "error_cb", error_cb);
|
|
2771
|
+
}
|
|
2772
|
+
|
|
2773
|
+
|
|
2774
|
+
void rd_kafka_conf_set_throttle_cb(rd_kafka_conf_t *conf,
|
|
2775
|
+
void (*throttle_cb)(rd_kafka_t *rk,
|
|
2776
|
+
const char *broker_name,
|
|
2777
|
+
int32_t broker_id,
|
|
2778
|
+
int throttle_time_ms,
|
|
2779
|
+
void *opaque)) {
|
|
2780
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "throttle_cb",
|
|
2781
|
+
throttle_cb);
|
|
2782
|
+
}
|
|
2783
|
+
|
|
2784
|
+
|
|
2785
|
+
void rd_kafka_conf_set_log_cb(rd_kafka_conf_t *conf,
|
|
2786
|
+
void (*log_cb)(const rd_kafka_t *rk,
|
|
2787
|
+
int level,
|
|
2788
|
+
const char *fac,
|
|
2789
|
+
const char *buf)) {
|
|
2790
|
+
#if !WITH_SYSLOG
|
|
2791
|
+
if (log_cb == rd_kafka_log_syslog)
|
|
2792
|
+
rd_assert(!*"syslog support not enabled in this build");
|
|
2793
|
+
#endif
|
|
2794
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "log_cb", log_cb);
|
|
2795
|
+
}
|
|
2796
|
+
|
|
2797
|
+
|
|
2798
|
+
void rd_kafka_conf_set_stats_cb(rd_kafka_conf_t *conf,
|
|
2799
|
+
int (*stats_cb)(rd_kafka_t *rk,
|
|
2800
|
+
char *json,
|
|
2801
|
+
size_t json_len,
|
|
2802
|
+
void *opaque)) {
|
|
2803
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "stats_cb", stats_cb);
|
|
2804
|
+
}
|
|
2805
|
+
|
|
2806
|
+
void rd_kafka_conf_set_oauthbearer_token_refresh_cb(
|
|
2807
|
+
rd_kafka_conf_t *conf,
|
|
2808
|
+
void (*oauthbearer_token_refresh_cb)(rd_kafka_t *rk,
|
|
2809
|
+
const char *oauthbearer_config,
|
|
2810
|
+
void *opaque)) {
|
|
2811
|
+
#if WITH_SASL_OAUTHBEARER
|
|
2812
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf,
|
|
2813
|
+
"oauthbearer_token_refresh_cb",
|
|
2814
|
+
oauthbearer_token_refresh_cb);
|
|
2815
|
+
#endif
|
|
2816
|
+
}
|
|
2817
|
+
|
|
2818
|
+
void rd_kafka_conf_enable_sasl_queue(rd_kafka_conf_t *conf, int enable) {
|
|
2819
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "enable_sasl_queue",
|
|
2820
|
+
(enable ? "true" : "false"));
|
|
2821
|
+
}
|
|
2822
|
+
|
|
2823
|
+
void rd_kafka_conf_set_socket_cb(
|
|
2824
|
+
rd_kafka_conf_t *conf,
|
|
2825
|
+
int (*socket_cb)(int domain, int type, int protocol, void *opaque)) {
|
|
2826
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "socket_cb", socket_cb);
|
|
2827
|
+
}
|
|
2828
|
+
|
|
2829
|
+
void rd_kafka_conf_set_connect_cb(rd_kafka_conf_t *conf,
|
|
2830
|
+
int (*connect_cb)(int sockfd,
|
|
2831
|
+
const struct sockaddr *addr,
|
|
2832
|
+
int addrlen,
|
|
2833
|
+
const char *id,
|
|
2834
|
+
void *opaque)) {
|
|
2835
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "connect_cb",
|
|
2836
|
+
connect_cb);
|
|
2837
|
+
}
|
|
2838
|
+
|
|
2839
|
+
void rd_kafka_conf_set_closesocket_cb(rd_kafka_conf_t *conf,
|
|
2840
|
+
int (*closesocket_cb)(int sockfd,
|
|
2841
|
+
void *opaque)) {
|
|
2842
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "closesocket_cb",
|
|
2843
|
+
closesocket_cb);
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
|
|
2847
|
+
|
|
2848
|
+
#ifndef _WIN32
|
|
2849
|
+
void rd_kafka_conf_set_open_cb(rd_kafka_conf_t *conf,
|
|
2850
|
+
int (*open_cb)(const char *pathname,
|
|
2851
|
+
int flags,
|
|
2852
|
+
mode_t mode,
|
|
2853
|
+
void *opaque)) {
|
|
2854
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "open_cb", open_cb);
|
|
2855
|
+
}
|
|
2856
|
+
#endif
|
|
2857
|
+
|
|
2858
|
+
void rd_kafka_conf_set_resolve_cb(
|
|
2859
|
+
rd_kafka_conf_t *conf,
|
|
2860
|
+
int (*resolve_cb)(const char *node,
|
|
2861
|
+
const char *service,
|
|
2862
|
+
const struct addrinfo *hints,
|
|
2863
|
+
struct addrinfo **res,
|
|
2864
|
+
void *opaque)) {
|
|
2865
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "resolve_cb",
|
|
2866
|
+
resolve_cb);
|
|
2867
|
+
}
|
|
2868
|
+
|
|
2869
|
+
rd_kafka_conf_res_t rd_kafka_conf_set_ssl_cert_verify_cb(
|
|
2870
|
+
rd_kafka_conf_t *conf,
|
|
2871
|
+
int (*ssl_cert_verify_cb)(rd_kafka_t *rk,
|
|
2872
|
+
const char *broker_name,
|
|
2873
|
+
int32_t broker_id,
|
|
2874
|
+
int *x509_set_error,
|
|
2875
|
+
int depth,
|
|
2876
|
+
const char *buf,
|
|
2877
|
+
size_t size,
|
|
2878
|
+
char *errstr,
|
|
2879
|
+
size_t errstr_size,
|
|
2880
|
+
void *opaque)) {
|
|
2881
|
+
#if !WITH_SSL
|
|
2882
|
+
return RD_KAFKA_CONF_INVALID;
|
|
2883
|
+
#else
|
|
2884
|
+
rd_kafka_anyconf_set_internal(
|
|
2885
|
+
_RK_GLOBAL, conf, "ssl.certificate.verify_cb", ssl_cert_verify_cb);
|
|
2886
|
+
return RD_KAFKA_CONF_OK;
|
|
2887
|
+
#endif
|
|
2888
|
+
}
|
|
2889
|
+
|
|
2890
|
+
|
|
2891
|
+
void rd_kafka_conf_set_opaque(rd_kafka_conf_t *conf, void *opaque) {
|
|
2892
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "opaque", opaque);
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
|
|
2896
|
+
void rd_kafka_conf_set_engine_callback_data(rd_kafka_conf_t *conf,
|
|
2897
|
+
void *callback_data) {
|
|
2898
|
+
rd_kafka_anyconf_set_internal(
|
|
2899
|
+
_RK_GLOBAL, conf, "ssl_engine_callback_data", callback_data);
|
|
2900
|
+
}
|
|
2901
|
+
|
|
2902
|
+
|
|
2903
|
+
void rd_kafka_conf_set_default_topic_conf(rd_kafka_conf_t *conf,
|
|
2904
|
+
rd_kafka_topic_conf_t *tconf) {
|
|
2905
|
+
if (conf->topic_conf) {
|
|
2906
|
+
if (rd_kafka_anyconf_is_any_modified(conf->topic_conf))
|
|
2907
|
+
conf->warn.default_topic_conf_overwritten = rd_true;
|
|
2908
|
+
rd_kafka_topic_conf_destroy(conf->topic_conf);
|
|
2909
|
+
}
|
|
2910
|
+
|
|
2911
|
+
rd_kafka_anyconf_set_internal(_RK_GLOBAL, conf, "default_topic_conf",
|
|
2912
|
+
tconf);
|
|
2913
|
+
}
|
|
2914
|
+
|
|
2915
|
+
rd_kafka_topic_conf_t *
|
|
2916
|
+
rd_kafka_conf_get_default_topic_conf(rd_kafka_conf_t *conf) {
|
|
2917
|
+
return conf->topic_conf;
|
|
2918
|
+
}
|
|
2919
|
+
|
|
2920
|
+
|
|
2921
|
+
void rd_kafka_topic_conf_set_partitioner_cb(
|
|
2922
|
+
rd_kafka_topic_conf_t *topic_conf,
|
|
2923
|
+
int32_t (*partitioner)(const rd_kafka_topic_t *rkt,
|
|
2924
|
+
const void *keydata,
|
|
2925
|
+
size_t keylen,
|
|
2926
|
+
int32_t partition_cnt,
|
|
2927
|
+
void *rkt_opaque,
|
|
2928
|
+
void *msg_opaque)) {
|
|
2929
|
+
rd_kafka_anyconf_set_internal(_RK_TOPIC, topic_conf, "partitioner_cb",
|
|
2930
|
+
partitioner);
|
|
2931
|
+
}
|
|
2932
|
+
|
|
2933
|
+
void rd_kafka_topic_conf_set_msg_order_cmp(
|
|
2934
|
+
rd_kafka_topic_conf_t *topic_conf,
|
|
2935
|
+
int (*msg_order_cmp)(const rd_kafka_message_t *a,
|
|
2936
|
+
const rd_kafka_message_t *b)) {
|
|
2937
|
+
rd_kafka_anyconf_set_internal(_RK_TOPIC, topic_conf, "msg_order_cmp",
|
|
2938
|
+
msg_order_cmp);
|
|
2939
|
+
}
|
|
2940
|
+
|
|
2941
|
+
void rd_kafka_topic_conf_set_opaque(rd_kafka_topic_conf_t *topic_conf,
|
|
2942
|
+
void *opaque) {
|
|
2943
|
+
rd_kafka_anyconf_set_internal(_RK_TOPIC, topic_conf, "opaque", opaque);
|
|
2944
|
+
}
|
|
2945
|
+
|
|
2946
|
+
|
|
2947
|
+
|
|
2948
|
+
/**
|
|
2949
|
+
* @brief Convert flags \p ival to csv-string using S2F property \p prop.
|
|
2950
|
+
*
|
|
2951
|
+
* This function has two modes: size query and write.
|
|
2952
|
+
* To query for needed size call with dest==NULL,
|
|
2953
|
+
* to write to buffer of size dest_size call with dest!=NULL.
|
|
2954
|
+
*
|
|
2955
|
+
* An \p ival of -1 means all.
|
|
2956
|
+
*
|
|
2957
|
+
* @param include_unsupported Include flag values that are unsupported
|
|
2958
|
+
* due to missing dependencies at build time.
|
|
2959
|
+
*
|
|
2960
|
+
* @returns the number of bytes written to \p dest (if not NULL), else the
|
|
2961
|
+
* total number of bytes needed.
|
|
2962
|
+
*
|
|
2963
|
+
*/
|
|
2964
|
+
static size_t rd_kafka_conf_flags2str(char *dest,
|
|
2965
|
+
size_t dest_size,
|
|
2966
|
+
const char *delim,
|
|
2967
|
+
const struct rd_kafka_property *prop,
|
|
2968
|
+
int ival,
|
|
2969
|
+
rd_bool_t include_unsupported) {
|
|
2970
|
+
size_t of = 0;
|
|
2971
|
+
int j;
|
|
2972
|
+
|
|
2973
|
+
if (dest && dest_size > 0)
|
|
2974
|
+
*dest = '\0';
|
|
2975
|
+
|
|
2976
|
+
/* Phase 1: scan for set flags, accumulate needed size.
|
|
2977
|
+
* Phase 2: write to dest */
|
|
2978
|
+
for (j = 0; j < (int)RD_ARRAYSIZE(prop->s2i) && prop->s2i[j].str; j++) {
|
|
2979
|
+
if (prop->type == _RK_C_S2F && ival != -1 &&
|
|
2980
|
+
(ival & prop->s2i[j].val) != prop->s2i[j].val)
|
|
2981
|
+
continue;
|
|
2982
|
+
else if (prop->type == _RK_C_S2I && ival != -1 &&
|
|
2983
|
+
prop->s2i[j].val != ival)
|
|
2984
|
+
continue;
|
|
2985
|
+
else if (prop->s2i[j].unsupported && !include_unsupported)
|
|
2986
|
+
continue;
|
|
2987
|
+
|
|
2988
|
+
if (!dest)
|
|
2989
|
+
of += strlen(prop->s2i[j].str) + (of > 0 ? 1 : 0);
|
|
2990
|
+
else {
|
|
2991
|
+
size_t r;
|
|
2992
|
+
r = rd_snprintf(dest + of, dest_size - of, "%s%s",
|
|
2993
|
+
of > 0 ? delim : "", prop->s2i[j].str);
|
|
2994
|
+
if (r > dest_size - of) {
|
|
2995
|
+
r = dest_size - of;
|
|
2996
|
+
break;
|
|
2997
|
+
}
|
|
2998
|
+
of += r;
|
|
2999
|
+
}
|
|
3000
|
+
}
|
|
3001
|
+
|
|
3002
|
+
return of + 1 /*nul*/;
|
|
3003
|
+
}
|
|
3004
|
+
|
|
3005
|
+
|
|
3006
|
+
/**
|
|
3007
|
+
* Return "original"(re-created) configuration value string
|
|
3008
|
+
*/
|
|
3009
|
+
static rd_kafka_conf_res_t
|
|
3010
|
+
rd_kafka_anyconf_get0(const void *conf,
|
|
3011
|
+
const struct rd_kafka_property *prop,
|
|
3012
|
+
char *dest,
|
|
3013
|
+
size_t *dest_size) {
|
|
3014
|
+
char tmp[22];
|
|
3015
|
+
const char *val = NULL;
|
|
3016
|
+
size_t val_len = 0;
|
|
3017
|
+
int j;
|
|
3018
|
+
|
|
3019
|
+
switch (prop->type) {
|
|
3020
|
+
case _RK_C_STR:
|
|
3021
|
+
val = *_RK_PTR(const char **, conf, prop->offset);
|
|
3022
|
+
break;
|
|
3023
|
+
|
|
3024
|
+
case _RK_C_KSTR: {
|
|
3025
|
+
const rd_kafkap_str_t **kstr =
|
|
3026
|
+
_RK_PTR(const rd_kafkap_str_t **, conf, prop->offset);
|
|
3027
|
+
if (*kstr)
|
|
3028
|
+
val = (*kstr)->str;
|
|
3029
|
+
break;
|
|
3030
|
+
}
|
|
3031
|
+
|
|
3032
|
+
case _RK_C_PTR:
|
|
3033
|
+
val = *_RK_PTR(const void **, conf, prop->offset);
|
|
3034
|
+
if (val) {
|
|
3035
|
+
rd_snprintf(tmp, sizeof(tmp), "%p", (void *)val);
|
|
3036
|
+
val = tmp;
|
|
3037
|
+
}
|
|
3038
|
+
break;
|
|
3039
|
+
|
|
3040
|
+
case _RK_C_BOOL:
|
|
3041
|
+
val = (*_RK_PTR(int *, conf, prop->offset) ? "true" : "false");
|
|
3042
|
+
break;
|
|
3043
|
+
|
|
3044
|
+
case _RK_C_INT:
|
|
3045
|
+
rd_snprintf(tmp, sizeof(tmp), "%i",
|
|
3046
|
+
*_RK_PTR(int *, conf, prop->offset));
|
|
3047
|
+
val = tmp;
|
|
3048
|
+
break;
|
|
3049
|
+
|
|
3050
|
+
case _RK_C_DBL:
|
|
3051
|
+
rd_snprintf(tmp, sizeof(tmp), "%g",
|
|
3052
|
+
*_RK_PTR(double *, conf, prop->offset));
|
|
3053
|
+
val = tmp;
|
|
3054
|
+
break;
|
|
3055
|
+
|
|
3056
|
+
case _RK_C_S2I:
|
|
3057
|
+
for (j = 0; j < (int)RD_ARRAYSIZE(prop->s2i); j++) {
|
|
3058
|
+
if (prop->s2i[j].val ==
|
|
3059
|
+
*_RK_PTR(int *, conf, prop->offset)) {
|
|
3060
|
+
val = prop->s2i[j].str;
|
|
3061
|
+
break;
|
|
3062
|
+
}
|
|
3063
|
+
}
|
|
3064
|
+
break;
|
|
3065
|
+
|
|
3066
|
+
case _RK_C_S2F: {
|
|
3067
|
+
const int ival = *_RK_PTR(const int *, conf, prop->offset);
|
|
3068
|
+
|
|
3069
|
+
val_len = rd_kafka_conf_flags2str(dest, dest ? *dest_size : 0,
|
|
3070
|
+
",", prop, ival,
|
|
3071
|
+
rd_false /*only supported*/);
|
|
3072
|
+
if (dest) {
|
|
3073
|
+
val_len = 0;
|
|
3074
|
+
val = dest;
|
|
3075
|
+
dest = NULL;
|
|
3076
|
+
}
|
|
3077
|
+
break;
|
|
3078
|
+
}
|
|
3079
|
+
|
|
3080
|
+
case _RK_C_PATLIST: {
|
|
3081
|
+
const rd_kafka_pattern_list_t **plist;
|
|
3082
|
+
plist = _RK_PTR(const rd_kafka_pattern_list_t **, conf,
|
|
3083
|
+
prop->offset);
|
|
3084
|
+
if (*plist)
|
|
3085
|
+
val = (*plist)->rkpl_orig;
|
|
3086
|
+
break;
|
|
3087
|
+
}
|
|
3088
|
+
|
|
3089
|
+
default:
|
|
3090
|
+
break;
|
|
3091
|
+
}
|
|
3092
|
+
|
|
3093
|
+
if (val_len) {
|
|
3094
|
+
*dest_size = val_len + 1;
|
|
3095
|
+
return RD_KAFKA_CONF_OK;
|
|
3096
|
+
}
|
|
3097
|
+
|
|
3098
|
+
if (!val)
|
|
3099
|
+
return RD_KAFKA_CONF_INVALID;
|
|
3100
|
+
|
|
3101
|
+
val_len = strlen(val);
|
|
3102
|
+
|
|
3103
|
+
if (dest) {
|
|
3104
|
+
size_t use_len = RD_MIN(val_len, (*dest_size) - 1);
|
|
3105
|
+
memcpy(dest, val, use_len);
|
|
3106
|
+
dest[use_len] = '\0';
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
/* Return needed size */
|
|
3110
|
+
*dest_size = val_len + 1;
|
|
3111
|
+
|
|
3112
|
+
return RD_KAFKA_CONF_OK;
|
|
3113
|
+
}
|
|
3114
|
+
|
|
3115
|
+
|
|
3116
|
+
static rd_kafka_conf_res_t rd_kafka_anyconf_get(int scope,
|
|
3117
|
+
const void *conf,
|
|
3118
|
+
const char *name,
|
|
3119
|
+
char *dest,
|
|
3120
|
+
size_t *dest_size) {
|
|
3121
|
+
const struct rd_kafka_property *prop;
|
|
3122
|
+
|
|
3123
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
3124
|
+
|
|
3125
|
+
if (!(prop->scope & scope) || strcmp(prop->name, name))
|
|
3126
|
+
continue;
|
|
3127
|
+
|
|
3128
|
+
if (prop->type == _RK_C_ALIAS)
|
|
3129
|
+
return rd_kafka_anyconf_get(scope, conf, prop->sdef,
|
|
3130
|
+
dest, dest_size);
|
|
3131
|
+
|
|
3132
|
+
if (rd_kafka_anyconf_get0(conf, prop, dest, dest_size) ==
|
|
3133
|
+
RD_KAFKA_CONF_OK)
|
|
3134
|
+
return RD_KAFKA_CONF_OK;
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
return RD_KAFKA_CONF_UNKNOWN;
|
|
3138
|
+
}
|
|
3139
|
+
|
|
3140
|
+
rd_kafka_conf_res_t rd_kafka_topic_conf_get(const rd_kafka_topic_conf_t *conf,
|
|
3141
|
+
const char *name,
|
|
3142
|
+
char *dest,
|
|
3143
|
+
size_t *dest_size) {
|
|
3144
|
+
return rd_kafka_anyconf_get(_RK_TOPIC, conf, name, dest, dest_size);
|
|
3145
|
+
}
|
|
3146
|
+
|
|
3147
|
+
rd_kafka_conf_res_t rd_kafka_conf_get(const rd_kafka_conf_t *conf,
|
|
3148
|
+
const char *name,
|
|
3149
|
+
char *dest,
|
|
3150
|
+
size_t *dest_size) {
|
|
3151
|
+
rd_kafka_conf_res_t res;
|
|
3152
|
+
res = rd_kafka_anyconf_get(_RK_GLOBAL, conf, name, dest, dest_size);
|
|
3153
|
+
if (res != RD_KAFKA_CONF_UNKNOWN || !conf->topic_conf)
|
|
3154
|
+
return res;
|
|
3155
|
+
|
|
3156
|
+
/* Fallthru:
|
|
3157
|
+
* If the global property was unknown, try getting it from the
|
|
3158
|
+
* default topic config, if any. */
|
|
3159
|
+
return rd_kafka_topic_conf_get(conf->topic_conf, name, dest, dest_size);
|
|
3160
|
+
}
|
|
3161
|
+
|
|
3162
|
+
|
|
3163
|
+
static const char **rd_kafka_anyconf_dump(int scope,
|
|
3164
|
+
const void *conf,
|
|
3165
|
+
size_t *cntp,
|
|
3166
|
+
rd_bool_t only_modified,
|
|
3167
|
+
rd_bool_t redact_sensitive) {
|
|
3168
|
+
const struct rd_kafka_property *prop;
|
|
3169
|
+
char **arr;
|
|
3170
|
+
int cnt = 0;
|
|
3171
|
+
|
|
3172
|
+
arr = rd_calloc(sizeof(char *), RD_ARRAYSIZE(rd_kafka_properties) * 2);
|
|
3173
|
+
|
|
3174
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
3175
|
+
char *val = NULL;
|
|
3176
|
+
size_t val_size;
|
|
3177
|
+
|
|
3178
|
+
if (!(prop->scope & scope))
|
|
3179
|
+
continue;
|
|
3180
|
+
|
|
3181
|
+
if (only_modified && !rd_kafka_anyconf_is_modified(conf, prop))
|
|
3182
|
+
continue;
|
|
3183
|
+
|
|
3184
|
+
/* Skip aliases, show original property instead.
|
|
3185
|
+
* Skip invalids. */
|
|
3186
|
+
if (prop->type == _RK_C_ALIAS || prop->type == _RK_C_INVALID)
|
|
3187
|
+
continue;
|
|
3188
|
+
|
|
3189
|
+
if (redact_sensitive && (prop->scope & _RK_SENSITIVE)) {
|
|
3190
|
+
val = rd_strdup("[redacted]");
|
|
3191
|
+
} else {
|
|
3192
|
+
/* Query value size */
|
|
3193
|
+
if (rd_kafka_anyconf_get0(conf, prop, NULL,
|
|
3194
|
+
&val_size) !=
|
|
3195
|
+
RD_KAFKA_CONF_OK)
|
|
3196
|
+
continue;
|
|
3197
|
+
|
|
3198
|
+
/* Get value */
|
|
3199
|
+
val = rd_malloc(val_size);
|
|
3200
|
+
rd_kafka_anyconf_get0(conf, prop, val, &val_size);
|
|
3201
|
+
}
|
|
3202
|
+
|
|
3203
|
+
arr[cnt++] = rd_strdup(prop->name);
|
|
3204
|
+
arr[cnt++] = val;
|
|
3205
|
+
}
|
|
3206
|
+
|
|
3207
|
+
*cntp = cnt;
|
|
3208
|
+
|
|
3209
|
+
return (const char **)arr;
|
|
3210
|
+
}
|
|
3211
|
+
|
|
3212
|
+
|
|
3213
|
+
const char **rd_kafka_conf_dump(rd_kafka_conf_t *conf, size_t *cntp) {
|
|
3214
|
+
return rd_kafka_anyconf_dump(_RK_GLOBAL, conf, cntp, rd_false /*all*/,
|
|
3215
|
+
rd_false /*don't redact*/);
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3218
|
+
const char **rd_kafka_topic_conf_dump(rd_kafka_topic_conf_t *conf,
|
|
3219
|
+
size_t *cntp) {
|
|
3220
|
+
return rd_kafka_anyconf_dump(_RK_TOPIC, conf, cntp, rd_false /*all*/,
|
|
3221
|
+
rd_false /*don't redact*/);
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
void rd_kafka_conf_dump_free(const char **arr, size_t cnt) {
|
|
3225
|
+
char **_arr = (char **)arr;
|
|
3226
|
+
unsigned int i;
|
|
3227
|
+
|
|
3228
|
+
for (i = 0; i < cnt; i++)
|
|
3229
|
+
if (_arr[i])
|
|
3230
|
+
rd_free(_arr[i]);
|
|
3231
|
+
|
|
3232
|
+
rd_free(_arr);
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
|
|
3236
|
+
|
|
3237
|
+
/**
|
|
3238
|
+
* @brief Dump configured properties to debug log.
|
|
3239
|
+
*/
|
|
3240
|
+
void rd_kafka_anyconf_dump_dbg(rd_kafka_t *rk,
|
|
3241
|
+
int scope,
|
|
3242
|
+
const void *conf,
|
|
3243
|
+
const char *description) {
|
|
3244
|
+
const char **arr;
|
|
3245
|
+
size_t cnt;
|
|
3246
|
+
size_t i;
|
|
3247
|
+
|
|
3248
|
+
arr =
|
|
3249
|
+
rd_kafka_anyconf_dump(scope, conf, &cnt, rd_true /*modified only*/,
|
|
3250
|
+
rd_true /*redact sensitive*/);
|
|
3251
|
+
if (cnt > 0)
|
|
3252
|
+
rd_kafka_dbg(rk, CONF, "CONF", "%s:", description);
|
|
3253
|
+
for (i = 0; i < cnt; i += 2)
|
|
3254
|
+
rd_kafka_dbg(rk, CONF, "CONF", " %s = %s", arr[i], arr[i + 1]);
|
|
3255
|
+
|
|
3256
|
+
rd_kafka_conf_dump_free(arr, cnt);
|
|
3257
|
+
}
|
|
3258
|
+
|
|
3259
|
+
void rd_kafka_conf_properties_show(FILE *fp) {
|
|
3260
|
+
const struct rd_kafka_property *prop0;
|
|
3261
|
+
int last = 0;
|
|
3262
|
+
int j;
|
|
3263
|
+
char tmp[512];
|
|
3264
|
+
const char *dash80 =
|
|
3265
|
+
"----------------------------------------"
|
|
3266
|
+
"----------------------------------------";
|
|
3267
|
+
|
|
3268
|
+
for (prop0 = rd_kafka_properties; prop0->name; prop0++) {
|
|
3269
|
+
const char *typeinfo = "";
|
|
3270
|
+
const char *importance;
|
|
3271
|
+
const struct rd_kafka_property *prop = prop0;
|
|
3272
|
+
|
|
3273
|
+
/* Skip hidden properties. */
|
|
3274
|
+
if (prop->scope & _RK_HIDDEN)
|
|
3275
|
+
continue;
|
|
3276
|
+
|
|
3277
|
+
/* Skip invalid properties. */
|
|
3278
|
+
if (prop->type == _RK_C_INVALID)
|
|
3279
|
+
continue;
|
|
3280
|
+
|
|
3281
|
+
if (!(prop->scope & last)) {
|
|
3282
|
+
fprintf(fp, "%s## %s configuration properties\n\n",
|
|
3283
|
+
last ? "\n\n" : "",
|
|
3284
|
+
prop->scope == _RK_GLOBAL ? "Global" : "Topic");
|
|
3285
|
+
|
|
3286
|
+
fprintf(fp,
|
|
3287
|
+
"%-40s | %3s | %-15s | %13s | %-10s | %-25s\n"
|
|
3288
|
+
"%.*s-|-%.*s-|-%.*s-|-%.*s:|-%.*s-| -%.*s\n",
|
|
3289
|
+
"Property", "C/P", "Range", "Default",
|
|
3290
|
+
"Importance", "Description", 40, dash80, 3,
|
|
3291
|
+
dash80, 15, dash80, 13, dash80, 10, dash80, 25,
|
|
3292
|
+
dash80);
|
|
3293
|
+
|
|
3294
|
+
last = prop->scope & (_RK_GLOBAL | _RK_TOPIC);
|
|
3295
|
+
}
|
|
3296
|
+
|
|
3297
|
+
fprintf(fp, "%-40s | ", prop->name);
|
|
3298
|
+
|
|
3299
|
+
/* For aliases, use the aliased property from here on
|
|
3300
|
+
* so that the alias property shows up with proper
|
|
3301
|
+
* ranges, defaults, etc. */
|
|
3302
|
+
if (prop->type == _RK_C_ALIAS) {
|
|
3303
|
+
prop = rd_kafka_conf_prop_find(prop->scope, prop->sdef);
|
|
3304
|
+
rd_assert(prop && *"BUG: "
|
|
3305
|
+
"alias points to unknown config property");
|
|
3306
|
+
}
|
|
3307
|
+
|
|
3308
|
+
fprintf(fp, "%3s | ",
|
|
3309
|
+
(!(prop->scope & _RK_PRODUCER) ==
|
|
3310
|
+
!(prop->scope & _RK_CONSUMER)
|
|
3311
|
+
? " * "
|
|
3312
|
+
: ((prop->scope & _RK_PRODUCER) ? " P " : " C ")));
|
|
3313
|
+
|
|
3314
|
+
switch (prop->type) {
|
|
3315
|
+
case _RK_C_STR:
|
|
3316
|
+
case _RK_C_KSTR:
|
|
3317
|
+
typeinfo = "string";
|
|
3318
|
+
case _RK_C_PATLIST:
|
|
3319
|
+
if (prop->type == _RK_C_PATLIST)
|
|
3320
|
+
typeinfo = "pattern list";
|
|
3321
|
+
if (prop->s2i[0].str) {
|
|
3322
|
+
rd_kafka_conf_flags2str(
|
|
3323
|
+
tmp, sizeof(tmp), ", ", prop, -1,
|
|
3324
|
+
rd_true /*include unsupported*/);
|
|
3325
|
+
fprintf(fp, "%-15s | %13s", tmp,
|
|
3326
|
+
prop->sdef ? prop->sdef : "");
|
|
3327
|
+
} else {
|
|
3328
|
+
fprintf(fp, "%-15s | %13s", "",
|
|
3329
|
+
prop->sdef ? prop->sdef : "");
|
|
3330
|
+
}
|
|
3331
|
+
break;
|
|
3332
|
+
case _RK_C_BOOL:
|
|
3333
|
+
typeinfo = "boolean";
|
|
3334
|
+
fprintf(fp, "%-15s | %13s", "true, false",
|
|
3335
|
+
prop->vdef ? "true" : "false");
|
|
3336
|
+
break;
|
|
3337
|
+
case _RK_C_INT:
|
|
3338
|
+
typeinfo = "integer";
|
|
3339
|
+
rd_snprintf(tmp, sizeof(tmp), "%d .. %d", prop->vmin,
|
|
3340
|
+
prop->vmax);
|
|
3341
|
+
fprintf(fp, "%-15s | %13i", tmp, prop->vdef);
|
|
3342
|
+
break;
|
|
3343
|
+
case _RK_C_DBL:
|
|
3344
|
+
typeinfo = "float"; /* more user-friendly than double */
|
|
3345
|
+
rd_snprintf(tmp, sizeof(tmp), "%g .. %g", prop->dmin,
|
|
3346
|
+
prop->dmax);
|
|
3347
|
+
fprintf(fp, "%-15s | %13g", tmp, prop->ddef);
|
|
3348
|
+
break;
|
|
3349
|
+
case _RK_C_S2I:
|
|
3350
|
+
typeinfo = "enum value";
|
|
3351
|
+
rd_kafka_conf_flags2str(
|
|
3352
|
+
tmp, sizeof(tmp), ", ", prop, -1,
|
|
3353
|
+
rd_true /*include unsupported*/);
|
|
3354
|
+
fprintf(fp, "%-15s | ", tmp);
|
|
3355
|
+
|
|
3356
|
+
for (j = 0; j < (int)RD_ARRAYSIZE(prop->s2i); j++) {
|
|
3357
|
+
if (prop->s2i[j].val == prop->vdef) {
|
|
3358
|
+
fprintf(fp, "%13s", prop->s2i[j].str);
|
|
3359
|
+
break;
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
if (j == RD_ARRAYSIZE(prop->s2i))
|
|
3363
|
+
fprintf(fp, "%13s", " ");
|
|
3364
|
+
break;
|
|
3365
|
+
|
|
3366
|
+
case _RK_C_S2F:
|
|
3367
|
+
typeinfo = "CSV flags";
|
|
3368
|
+
/* Dont duplicate builtin.features value in
|
|
3369
|
+
* both Range and Default */
|
|
3370
|
+
if (!strcmp(prop->name, "builtin.features"))
|
|
3371
|
+
*tmp = '\0';
|
|
3372
|
+
else
|
|
3373
|
+
rd_kafka_conf_flags2str(
|
|
3374
|
+
tmp, sizeof(tmp), ", ", prop, -1,
|
|
3375
|
+
rd_true /*include unsupported*/);
|
|
3376
|
+
fprintf(fp, "%-15s | ", tmp);
|
|
3377
|
+
rd_kafka_conf_flags2str(
|
|
3378
|
+
tmp, sizeof(tmp), ", ", prop, prop->vdef,
|
|
3379
|
+
rd_true /*include unsupported*/);
|
|
3380
|
+
fprintf(fp, "%13s", tmp);
|
|
3381
|
+
|
|
3382
|
+
break;
|
|
3383
|
+
case _RK_C_PTR:
|
|
3384
|
+
case _RK_C_INTERNAL:
|
|
3385
|
+
typeinfo = "see dedicated API";
|
|
3386
|
+
/* FALLTHRU */
|
|
3387
|
+
default:
|
|
3388
|
+
fprintf(fp, "%-15s | %-13s", "", " ");
|
|
3389
|
+
break;
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3392
|
+
if (prop->scope & _RK_HIGH)
|
|
3393
|
+
importance = "high";
|
|
3394
|
+
else if (prop->scope & _RK_MED)
|
|
3395
|
+
importance = "medium";
|
|
3396
|
+
else
|
|
3397
|
+
importance = "low";
|
|
3398
|
+
|
|
3399
|
+
fprintf(fp, " | %-10s | ", importance);
|
|
3400
|
+
|
|
3401
|
+
if (prop->scope & _RK_EXPERIMENTAL)
|
|
3402
|
+
fprintf(fp,
|
|
3403
|
+
"**EXPERIMENTAL**: "
|
|
3404
|
+
"subject to change or removal. ");
|
|
3405
|
+
|
|
3406
|
+
if (prop->scope & _RK_DEPRECATED)
|
|
3407
|
+
fprintf(fp, "**DEPRECATED** ");
|
|
3408
|
+
|
|
3409
|
+
/* If the original property is an alias, prefix the
|
|
3410
|
+
* description saying so. */
|
|
3411
|
+
if (prop0->type == _RK_C_ALIAS)
|
|
3412
|
+
fprintf(fp, "Alias for `%s`: ", prop0->sdef);
|
|
3413
|
+
|
|
3414
|
+
fprintf(fp, "%s <br>*Type: %s*\n", prop->desc, typeinfo);
|
|
3415
|
+
}
|
|
3416
|
+
fprintf(fp, "\n");
|
|
3417
|
+
fprintf(fp, "### C/P legend: C = Consumer, P = Producer, * = both\n");
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
|
|
3421
|
+
|
|
3422
|
+
/**
|
|
3423
|
+
* @name Configuration value methods
|
|
3424
|
+
*
|
|
3425
|
+
* @remark This generic interface will eventually replace the config property
|
|
3426
|
+
* used above.
|
|
3427
|
+
* @{
|
|
3428
|
+
*/
|
|
3429
|
+
|
|
3430
|
+
|
|
3431
|
+
/**
|
|
3432
|
+
* @brief Set up an INT confval.
|
|
3433
|
+
*
|
|
3434
|
+
* @oaram name Property name, must be a const static string (will not be copied)
|
|
3435
|
+
*/
|
|
3436
|
+
void rd_kafka_confval_init_int(rd_kafka_confval_t *confval,
|
|
3437
|
+
const char *name,
|
|
3438
|
+
int vmin,
|
|
3439
|
+
int vmax,
|
|
3440
|
+
int vdef) {
|
|
3441
|
+
confval->name = name;
|
|
3442
|
+
confval->is_enabled = 1;
|
|
3443
|
+
confval->valuetype = RD_KAFKA_CONFVAL_INT;
|
|
3444
|
+
confval->u.INT.vmin = vmin;
|
|
3445
|
+
confval->u.INT.vmax = vmax;
|
|
3446
|
+
confval->u.INT.vdef = vdef;
|
|
3447
|
+
confval->u.INT.v = vdef;
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
/**
|
|
3451
|
+
* @brief Set up a PTR confval.
|
|
3452
|
+
*
|
|
3453
|
+
* @oaram name Property name, must be a const static string (will not be copied)
|
|
3454
|
+
*/
|
|
3455
|
+
void rd_kafka_confval_init_ptr(rd_kafka_confval_t *confval, const char *name) {
|
|
3456
|
+
confval->name = name;
|
|
3457
|
+
confval->is_enabled = 1;
|
|
3458
|
+
confval->valuetype = RD_KAFKA_CONFVAL_PTR;
|
|
3459
|
+
confval->u.PTR = NULL;
|
|
3460
|
+
}
|
|
3461
|
+
|
|
3462
|
+
/**
|
|
3463
|
+
* @brief Set up but disable an intval, attempt to set this confval will fail.
|
|
3464
|
+
*
|
|
3465
|
+
* @oaram name Property name, must be a const static string (will not be copied)
|
|
3466
|
+
*/
|
|
3467
|
+
void rd_kafka_confval_disable(rd_kafka_confval_t *confval, const char *name) {
|
|
3468
|
+
confval->name = name;
|
|
3469
|
+
confval->is_enabled = 0;
|
|
3470
|
+
}
|
|
3471
|
+
|
|
3472
|
+
/**
|
|
3473
|
+
* @brief Set confval's value to \p valuep, verifying the passed
|
|
3474
|
+
* \p valuetype matches (or can be cast to) \p confval's type.
|
|
3475
|
+
*
|
|
3476
|
+
* @param dispname is the display name for the configuration value and is
|
|
3477
|
+
* included in error strings.
|
|
3478
|
+
* @param valuep is a pointer to the value, or NULL to revert to default.
|
|
3479
|
+
*
|
|
3480
|
+
* @returns RD_KAFKA_RESP_ERR_NO_ERROR if the new value was set, or
|
|
3481
|
+
* RD_KAFKA_RESP_ERR__INVALID_ARG if the value was of incorrect type,
|
|
3482
|
+
* out of range, or otherwise not a valid value.
|
|
3483
|
+
*/
|
|
3484
|
+
rd_kafka_resp_err_t rd_kafka_confval_set_type(rd_kafka_confval_t *confval,
|
|
3485
|
+
rd_kafka_confval_type_t valuetype,
|
|
3486
|
+
const void *valuep,
|
|
3487
|
+
char *errstr,
|
|
3488
|
+
size_t errstr_size) {
|
|
3489
|
+
|
|
3490
|
+
if (!confval->is_enabled) {
|
|
3491
|
+
rd_snprintf(errstr, errstr_size,
|
|
3492
|
+
"\"%s\" is not supported for this operation",
|
|
3493
|
+
confval->name);
|
|
3494
|
+
return RD_KAFKA_RESP_ERR__INVALID_ARG;
|
|
3495
|
+
}
|
|
3496
|
+
|
|
3497
|
+
switch (confval->valuetype) {
|
|
3498
|
+
case RD_KAFKA_CONFVAL_INT: {
|
|
3499
|
+
int v;
|
|
3500
|
+
const char *end;
|
|
3501
|
+
|
|
3502
|
+
if (!valuep) {
|
|
3503
|
+
/* Revert to default */
|
|
3504
|
+
confval->u.INT.v = confval->u.INT.vdef;
|
|
3505
|
+
confval->is_set = 0;
|
|
3506
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
3507
|
+
}
|
|
3508
|
+
|
|
3509
|
+
switch (valuetype) {
|
|
3510
|
+
case RD_KAFKA_CONFVAL_INT:
|
|
3511
|
+
v = *(const int *)valuep;
|
|
3512
|
+
break;
|
|
3513
|
+
case RD_KAFKA_CONFVAL_STR:
|
|
3514
|
+
v = (int)strtol((const char *)valuep, (char **)&end, 0);
|
|
3515
|
+
if (end == (const char *)valuep) {
|
|
3516
|
+
rd_snprintf(errstr, errstr_size,
|
|
3517
|
+
"Invalid value type for \"%s\": "
|
|
3518
|
+
"expecting integer",
|
|
3519
|
+
confval->name);
|
|
3520
|
+
return RD_KAFKA_RESP_ERR__INVALID_TYPE;
|
|
3521
|
+
}
|
|
3522
|
+
break;
|
|
3523
|
+
default:
|
|
3524
|
+
rd_snprintf(errstr, errstr_size,
|
|
3525
|
+
"Invalid value type for \"%s\": "
|
|
3526
|
+
"expecting integer",
|
|
3527
|
+
confval->name);
|
|
3528
|
+
return RD_KAFKA_RESP_ERR__INVALID_ARG;
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3531
|
+
|
|
3532
|
+
if ((confval->u.INT.vmin || confval->u.INT.vmax) &&
|
|
3533
|
+
(v < confval->u.INT.vmin || v > confval->u.INT.vmax)) {
|
|
3534
|
+
rd_snprintf(errstr, errstr_size,
|
|
3535
|
+
"Invalid value type for \"%s\": "
|
|
3536
|
+
"expecting integer in range %d..%d",
|
|
3537
|
+
confval->name, confval->u.INT.vmin,
|
|
3538
|
+
confval->u.INT.vmax);
|
|
3539
|
+
return RD_KAFKA_RESP_ERR__INVALID_ARG;
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
confval->u.INT.v = v;
|
|
3543
|
+
confval->is_set = 1;
|
|
3544
|
+
} break;
|
|
3545
|
+
|
|
3546
|
+
case RD_KAFKA_CONFVAL_STR: {
|
|
3547
|
+
size_t vlen;
|
|
3548
|
+
const char *v = (const char *)valuep;
|
|
3549
|
+
|
|
3550
|
+
if (!valuep) {
|
|
3551
|
+
confval->is_set = 0;
|
|
3552
|
+
if (confval->u.STR.vdef)
|
|
3553
|
+
confval->u.STR.v =
|
|
3554
|
+
rd_strdup(confval->u.STR.vdef);
|
|
3555
|
+
else
|
|
3556
|
+
confval->u.STR.v = NULL;
|
|
3557
|
+
}
|
|
3558
|
+
|
|
3559
|
+
if (valuetype != RD_KAFKA_CONFVAL_STR) {
|
|
3560
|
+
rd_snprintf(errstr, errstr_size,
|
|
3561
|
+
"Invalid value type for \"%s\": "
|
|
3562
|
+
"expecting string",
|
|
3563
|
+
confval->name);
|
|
3564
|
+
return RD_KAFKA_RESP_ERR__INVALID_ARG;
|
|
3565
|
+
}
|
|
3566
|
+
|
|
3567
|
+
vlen = strlen(v);
|
|
3568
|
+
if ((confval->u.STR.minlen || confval->u.STR.maxlen) &&
|
|
3569
|
+
(vlen < confval->u.STR.minlen ||
|
|
3570
|
+
vlen > confval->u.STR.maxlen)) {
|
|
3571
|
+
rd_snprintf(errstr, errstr_size,
|
|
3572
|
+
"Invalid value for \"%s\": "
|
|
3573
|
+
"expecting string with length "
|
|
3574
|
+
"%" PRIusz "..%" PRIusz,
|
|
3575
|
+
confval->name, confval->u.STR.minlen,
|
|
3576
|
+
confval->u.STR.maxlen);
|
|
3577
|
+
return RD_KAFKA_RESP_ERR__INVALID_ARG;
|
|
3578
|
+
}
|
|
3579
|
+
|
|
3580
|
+
if (confval->u.STR.v)
|
|
3581
|
+
rd_free(confval->u.STR.v);
|
|
3582
|
+
|
|
3583
|
+
confval->u.STR.v = rd_strdup(v);
|
|
3584
|
+
} break;
|
|
3585
|
+
|
|
3586
|
+
case RD_KAFKA_CONFVAL_PTR:
|
|
3587
|
+
confval->u.PTR = (void *)valuep;
|
|
3588
|
+
break;
|
|
3589
|
+
|
|
3590
|
+
default:
|
|
3591
|
+
RD_NOTREACHED();
|
|
3592
|
+
return RD_KAFKA_RESP_ERR__NOENT;
|
|
3593
|
+
}
|
|
3594
|
+
|
|
3595
|
+
return RD_KAFKA_RESP_ERR_NO_ERROR;
|
|
3596
|
+
}
|
|
3597
|
+
|
|
3598
|
+
|
|
3599
|
+
int rd_kafka_confval_get_int(const rd_kafka_confval_t *confval) {
|
|
3600
|
+
rd_assert(confval->valuetype == RD_KAFKA_CONFVAL_INT);
|
|
3601
|
+
return confval->u.INT.v;
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
|
|
3605
|
+
const char *rd_kafka_confval_get_str(const rd_kafka_confval_t *confval) {
|
|
3606
|
+
rd_assert(confval->valuetype == RD_KAFKA_CONFVAL_STR);
|
|
3607
|
+
return confval->u.STR.v;
|
|
3608
|
+
}
|
|
3609
|
+
|
|
3610
|
+
void *rd_kafka_confval_get_ptr(const rd_kafka_confval_t *confval) {
|
|
3611
|
+
rd_assert(confval->valuetype == RD_KAFKA_CONFVAL_PTR);
|
|
3612
|
+
return confval->u.PTR;
|
|
3613
|
+
}
|
|
3614
|
+
|
|
3615
|
+
|
|
3616
|
+
#define _is_alphanum(C) \
|
|
3617
|
+
(((C) >= 'a' && (C) <= 'z') || ((C) >= 'A' && (C) <= 'Z') || \
|
|
3618
|
+
((C) >= '0' && (C) <= '9'))
|
|
3619
|
+
|
|
3620
|
+
/**
|
|
3621
|
+
* @returns true if the string is KIP-511 safe, else false.
|
|
3622
|
+
*/
|
|
3623
|
+
static rd_bool_t rd_kafka_sw_str_is_safe(const char *str) {
|
|
3624
|
+
const char *s;
|
|
3625
|
+
|
|
3626
|
+
if (!*str)
|
|
3627
|
+
return rd_true;
|
|
3628
|
+
|
|
3629
|
+
for (s = str; *s; s++) {
|
|
3630
|
+
int c = (int)*s;
|
|
3631
|
+
|
|
3632
|
+
if (unlikely(!(_is_alphanum(c) || c == '-' || c == '.')))
|
|
3633
|
+
return rd_false;
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
/* Verify that the string begins and ends with a-zA-Z0-9 */
|
|
3637
|
+
if (!_is_alphanum(*str))
|
|
3638
|
+
return rd_false;
|
|
3639
|
+
if (!_is_alphanum(*(s - 1)))
|
|
3640
|
+
return rd_false;
|
|
3641
|
+
|
|
3642
|
+
return rd_true;
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
|
|
3646
|
+
/**
|
|
3647
|
+
* @brief Sanitize KIP-511 software name/version strings in-place,
|
|
3648
|
+
* replacing unaccepted characters with "-".
|
|
3649
|
+
*
|
|
3650
|
+
* @warning The \p str is modified in-place.
|
|
3651
|
+
*/
|
|
3652
|
+
static void rd_kafka_sw_str_sanitize_inplace(char *str) {
|
|
3653
|
+
char *s = str, *d = str;
|
|
3654
|
+
|
|
3655
|
+
/* Strip any leading non-alphanums */
|
|
3656
|
+
while (!_is_alphanum(*s))
|
|
3657
|
+
s++;
|
|
3658
|
+
|
|
3659
|
+
for (; *s; s++) {
|
|
3660
|
+
int c = (int)*s;
|
|
3661
|
+
|
|
3662
|
+
if (unlikely(!(_is_alphanum(c) || c == '-' || c == '.')))
|
|
3663
|
+
*d = '-';
|
|
3664
|
+
else
|
|
3665
|
+
*d = *s;
|
|
3666
|
+
d++;
|
|
3667
|
+
}
|
|
3668
|
+
|
|
3669
|
+
*d = '\0';
|
|
3670
|
+
|
|
3671
|
+
/* Strip any trailing non-alphanums */
|
|
3672
|
+
for (d = d - 1; d >= str && !_is_alphanum(*d); d--)
|
|
3673
|
+
*d = '\0';
|
|
3674
|
+
}
|
|
3675
|
+
|
|
3676
|
+
#undef _is_alphanum
|
|
3677
|
+
|
|
3678
|
+
|
|
3679
|
+
/**
|
|
3680
|
+
* @brief Create a staggered array of key-value pairs from
|
|
3681
|
+
* an array of "key=value" strings (typically from rd_string_split()).
|
|
3682
|
+
*
|
|
3683
|
+
* The output array will have element 0 being key0 and element 1 being
|
|
3684
|
+
* value0. Element 2 being key1 and element 3 being value1, and so on.
|
|
3685
|
+
* E.g.:
|
|
3686
|
+
* input { "key0=value0", "key1=value1" } incnt=2
|
|
3687
|
+
* returns { "key0", "value0", "key1", "value1" } cntp=4
|
|
3688
|
+
*
|
|
3689
|
+
* @returns NULL on error (no '=' separator), or a newly allocated array
|
|
3690
|
+
* on success. The array count is returned in \p cntp.
|
|
3691
|
+
* The returned pointer must be freed with rd_free().
|
|
3692
|
+
*/
|
|
3693
|
+
char **rd_kafka_conf_kv_split(const char **input, size_t incnt, size_t *cntp) {
|
|
3694
|
+
size_t i;
|
|
3695
|
+
char **out, *p;
|
|
3696
|
+
size_t lens = 0;
|
|
3697
|
+
size_t outcnt = 0;
|
|
3698
|
+
|
|
3699
|
+
/* First calculate total length needed for key-value strings. */
|
|
3700
|
+
for (i = 0; i < incnt; i++) {
|
|
3701
|
+
const char *t = strchr(input[i], '=');
|
|
3702
|
+
|
|
3703
|
+
/* No "=", or "=" at beginning of string. */
|
|
3704
|
+
if (!t || t == input[i])
|
|
3705
|
+
return NULL;
|
|
3706
|
+
|
|
3707
|
+
/* Length of key, '=' (will be \0), value, and \0 */
|
|
3708
|
+
lens += strlen(input[i]) + 1;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3711
|
+
/* Allocate array along with elements in one go */
|
|
3712
|
+
out = rd_malloc((sizeof(*out) * incnt * 2) + lens);
|
|
3713
|
+
p = (char *)(&out[incnt * 2]);
|
|
3714
|
+
|
|
3715
|
+
for (i = 0; i < incnt; i++) {
|
|
3716
|
+
const char *t = strchr(input[i], '=');
|
|
3717
|
+
size_t namelen = (size_t)(t - input[i]);
|
|
3718
|
+
size_t valuelen = strlen(t + 1);
|
|
3719
|
+
|
|
3720
|
+
/* Copy name */
|
|
3721
|
+
out[outcnt++] = p;
|
|
3722
|
+
memcpy(p, input[i], namelen);
|
|
3723
|
+
p += namelen;
|
|
3724
|
+
*(p++) = '\0';
|
|
3725
|
+
|
|
3726
|
+
/* Copy value */
|
|
3727
|
+
out[outcnt++] = p;
|
|
3728
|
+
memcpy(p, t + 1, valuelen + 1);
|
|
3729
|
+
p += valuelen;
|
|
3730
|
+
*(p++) = '\0';
|
|
3731
|
+
}
|
|
3732
|
+
|
|
3733
|
+
|
|
3734
|
+
*cntp = outcnt;
|
|
3735
|
+
return out;
|
|
3736
|
+
}
|
|
3737
|
+
|
|
3738
|
+
|
|
3739
|
+
/**
|
|
3740
|
+
* @brief Verify configuration \p conf is
|
|
3741
|
+
* correct/non-conflicting and finalize the configuration
|
|
3742
|
+
* settings for use.
|
|
3743
|
+
*
|
|
3744
|
+
* @returns an error string if configuration is incorrect, else NULL.
|
|
3745
|
+
*/
|
|
3746
|
+
const char *rd_kafka_conf_finalize(rd_kafka_type_t cltype,
|
|
3747
|
+
rd_kafka_conf_t *conf) {
|
|
3748
|
+
const char *errstr;
|
|
3749
|
+
|
|
3750
|
+
if (!conf->sw_name)
|
|
3751
|
+
rd_kafka_conf_set(conf, "client.software.name", "librdkafka",
|
|
3752
|
+
NULL, 0);
|
|
3753
|
+
if (!conf->sw_version)
|
|
3754
|
+
rd_kafka_conf_set(conf, "client.software.version",
|
|
3755
|
+
rd_kafka_version_str(), NULL, 0);
|
|
3756
|
+
|
|
3757
|
+
/* The client.software.name and .version are sent to the broker
|
|
3758
|
+
* with the ApiVersionRequest starting with AK 2.4.0 (KIP-511).
|
|
3759
|
+
* These strings need to be sanitized or the broker will reject them,
|
|
3760
|
+
* so modify them in-place here. */
|
|
3761
|
+
rd_assert(conf->sw_name && conf->sw_version);
|
|
3762
|
+
rd_kafka_sw_str_sanitize_inplace(conf->sw_name);
|
|
3763
|
+
rd_kafka_sw_str_sanitize_inplace(conf->sw_version);
|
|
3764
|
+
|
|
3765
|
+
/* Verify mandatory configuration */
|
|
3766
|
+
if (!conf->socket_cb)
|
|
3767
|
+
return "Mandatory config property `socket_cb` not set";
|
|
3768
|
+
|
|
3769
|
+
if (!conf->open_cb)
|
|
3770
|
+
return "Mandatory config property `open_cb` not set";
|
|
3771
|
+
|
|
3772
|
+
#if WITH_SSL
|
|
3773
|
+
if (conf->ssl.keystore_location && !conf->ssl.keystore_password)
|
|
3774
|
+
return "`ssl.keystore.password` is mandatory when "
|
|
3775
|
+
"`ssl.keystore.location` is set";
|
|
3776
|
+
if (conf->ssl.ca && (conf->ssl.ca_location || conf->ssl.ca_pem))
|
|
3777
|
+
return "`ssl.ca.location` or `ssl.ca.pem`, and memory-based "
|
|
3778
|
+
"set_ssl_cert(CERT_CA) are mutually exclusive.";
|
|
3779
|
+
#ifdef __APPLE__
|
|
3780
|
+
else if (!conf->ssl.ca && !conf->ssl.ca_location && !conf->ssl.ca_pem)
|
|
3781
|
+
/* Default ssl.ca.location to 'probe' on OSX */
|
|
3782
|
+
rd_kafka_conf_set(conf, "ssl.ca.location", "probe", NULL, 0);
|
|
3783
|
+
#endif
|
|
3784
|
+
#endif
|
|
3785
|
+
|
|
3786
|
+
#if WITH_SASL_OAUTHBEARER
|
|
3787
|
+
if (!rd_strcasecmp(conf->sasl.mechanisms, "OAUTHBEARER")) {
|
|
3788
|
+
if (conf->sasl.enable_oauthbearer_unsecure_jwt &&
|
|
3789
|
+
conf->sasl.oauthbearer.token_refresh_cb)
|
|
3790
|
+
return "`enable.sasl.oauthbearer.unsecure.jwt` and "
|
|
3791
|
+
"`oauthbearer_token_refresh_cb` are "
|
|
3792
|
+
"mutually exclusive";
|
|
3793
|
+
|
|
3794
|
+
if (conf->sasl.enable_oauthbearer_unsecure_jwt &&
|
|
3795
|
+
conf->sasl.oauthbearer.method ==
|
|
3796
|
+
RD_KAFKA_SASL_OAUTHBEARER_METHOD_OIDC)
|
|
3797
|
+
return "`enable.sasl.oauthbearer.unsecure.jwt` and "
|
|
3798
|
+
"`sasl.oauthbearer.method=oidc` are "
|
|
3799
|
+
"mutually exclusive";
|
|
3800
|
+
|
|
3801
|
+
if (conf->sasl.oauthbearer.method ==
|
|
3802
|
+
RD_KAFKA_SASL_OAUTHBEARER_METHOD_OIDC) {
|
|
3803
|
+
if (!conf->sasl.oauthbearer.client_id)
|
|
3804
|
+
return "`sasl.oauthbearer.client.id` is "
|
|
3805
|
+
"mandatory when "
|
|
3806
|
+
"`sasl.oauthbearer.method=oidc` is set";
|
|
3807
|
+
|
|
3808
|
+
if (!conf->sasl.oauthbearer.client_secret) {
|
|
3809
|
+
return "`sasl.oauthbearer.client.secret` is "
|
|
3810
|
+
"mandatory when "
|
|
3811
|
+
"`sasl.oauthbearer.method=oidc` is set";
|
|
3812
|
+
}
|
|
3813
|
+
|
|
3814
|
+
if (!conf->sasl.oauthbearer.token_endpoint_url) {
|
|
3815
|
+
return "`sasl.oauthbearer.token.endpoint.url` "
|
|
3816
|
+
"is mandatory when "
|
|
3817
|
+
"`sasl.oauthbearer.method=oidc` is set";
|
|
3818
|
+
}
|
|
3819
|
+
}
|
|
3820
|
+
|
|
3821
|
+
/* Enable background thread for the builtin OIDC handler,
|
|
3822
|
+
* unless a refresh callback has been set. */
|
|
3823
|
+
if (conf->sasl.oauthbearer.method ==
|
|
3824
|
+
RD_KAFKA_SASL_OAUTHBEARER_METHOD_OIDC &&
|
|
3825
|
+
!conf->sasl.oauthbearer.token_refresh_cb) {
|
|
3826
|
+
conf->enabled_events |= RD_KAFKA_EVENT_BACKGROUND;
|
|
3827
|
+
conf->sasl.enable_callback_queue = 1;
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
|
|
3831
|
+
#endif
|
|
3832
|
+
|
|
3833
|
+
if (cltype == RD_KAFKA_CONSUMER) {
|
|
3834
|
+
|
|
3835
|
+
/* Automatically adjust `fetch.max.bytes` to be >=
|
|
3836
|
+
* `message.max.bytes` and <= `queued.max.message.kbytes`
|
|
3837
|
+
* unless set by user. */
|
|
3838
|
+
if (rd_kafka_conf_is_modified(conf, "fetch.max.bytes")) {
|
|
3839
|
+
if (conf->fetch_max_bytes < conf->max_msg_size)
|
|
3840
|
+
return "`fetch.max.bytes` must be >= "
|
|
3841
|
+
"`message.max.bytes`";
|
|
3842
|
+
} else {
|
|
3843
|
+
conf->fetch_max_bytes =
|
|
3844
|
+
RD_MAX(RD_MIN(conf->fetch_max_bytes,
|
|
3845
|
+
conf->queued_max_msg_kbytes * 1024),
|
|
3846
|
+
conf->max_msg_size);
|
|
3847
|
+
}
|
|
3848
|
+
|
|
3849
|
+
/* Automatically adjust 'receive.message.max.bytes' to
|
|
3850
|
+
* be 512 bytes larger than 'fetch.max.bytes' to have enough
|
|
3851
|
+
* room for protocol framing (including topic name), unless
|
|
3852
|
+
* set by user. */
|
|
3853
|
+
if (rd_kafka_conf_is_modified(conf,
|
|
3854
|
+
"receive.message.max.bytes")) {
|
|
3855
|
+
if (conf->fetch_max_bytes + 512 >
|
|
3856
|
+
conf->recv_max_msg_size)
|
|
3857
|
+
return "`receive.message.max.bytes` must be >= "
|
|
3858
|
+
"`fetch.max.bytes` + 512";
|
|
3859
|
+
} else {
|
|
3860
|
+
conf->recv_max_msg_size =
|
|
3861
|
+
RD_MAX(conf->recv_max_msg_size,
|
|
3862
|
+
conf->fetch_max_bytes + 512);
|
|
3863
|
+
}
|
|
3864
|
+
|
|
3865
|
+
if (conf->max_poll_interval_ms < conf->group_session_timeout_ms)
|
|
3866
|
+
return "`max.poll.interval.ms`must be >= "
|
|
3867
|
+
"`session.timeout.ms`";
|
|
3868
|
+
|
|
3869
|
+
/* Simplifies rd_kafka_is_idempotent() which is producer-only */
|
|
3870
|
+
conf->eos.idempotence = 0;
|
|
3871
|
+
|
|
3872
|
+
} else if (cltype == RD_KAFKA_PRODUCER) {
|
|
3873
|
+
if (conf->eos.transactional_id) {
|
|
3874
|
+
if (!conf->eos.idempotence) {
|
|
3875
|
+
/* Auto enable idempotence unless
|
|
3876
|
+
* explicitly disabled */
|
|
3877
|
+
if (rd_kafka_conf_is_modified(
|
|
3878
|
+
conf, "enable.idempotence"))
|
|
3879
|
+
return "`transactional.id` requires "
|
|
3880
|
+
"`enable.idempotence=true`";
|
|
3881
|
+
|
|
3882
|
+
conf->eos.idempotence = rd_true;
|
|
3883
|
+
}
|
|
3884
|
+
|
|
3885
|
+
/* Make sure at least one request can be sent
|
|
3886
|
+
* before the transaction times out. */
|
|
3887
|
+
if (!rd_kafka_conf_is_modified(conf,
|
|
3888
|
+
"socket.timeout.ms"))
|
|
3889
|
+
conf->socket_timeout_ms = RD_MAX(
|
|
3890
|
+
conf->eos.transaction_timeout_ms - 100,
|
|
3891
|
+
900);
|
|
3892
|
+
else if (conf->eos.transaction_timeout_ms + 100 <
|
|
3893
|
+
conf->socket_timeout_ms)
|
|
3894
|
+
return "`socket.timeout.ms` must be set <= "
|
|
3895
|
+
"`transaction.timeout.ms` + 100";
|
|
3896
|
+
}
|
|
3897
|
+
|
|
3898
|
+
if (conf->eos.idempotence) {
|
|
3899
|
+
/* Adjust configuration values for idempotent producer*/
|
|
3900
|
+
|
|
3901
|
+
if (rd_kafka_conf_is_modified(conf, "max.in.flight")) {
|
|
3902
|
+
if (conf->max_inflight >
|
|
3903
|
+
RD_KAFKA_IDEMP_MAX_INFLIGHT)
|
|
3904
|
+
return "`max.in.flight` must be "
|
|
3905
|
+
"set "
|
|
3906
|
+
"<="
|
|
3907
|
+
" " RD_KAFKA_IDEMP_MAX_INFLIGHT_STR
|
|
3908
|
+
" when `enable.idempotence` "
|
|
3909
|
+
"is true";
|
|
3910
|
+
} else {
|
|
3911
|
+
conf->max_inflight =
|
|
3912
|
+
RD_MIN(conf->max_inflight,
|
|
3913
|
+
RD_KAFKA_IDEMP_MAX_INFLIGHT);
|
|
3914
|
+
}
|
|
3915
|
+
|
|
3916
|
+
|
|
3917
|
+
if (rd_kafka_conf_is_modified(conf, "retries")) {
|
|
3918
|
+
if (conf->max_retries < 1)
|
|
3919
|
+
return "`retries` must be set >= 1 "
|
|
3920
|
+
"when `enable.idempotence` is "
|
|
3921
|
+
"true";
|
|
3922
|
+
} else {
|
|
3923
|
+
conf->max_retries = INT32_MAX;
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3926
|
+
|
|
3927
|
+
if (rd_kafka_conf_is_modified(
|
|
3928
|
+
conf,
|
|
3929
|
+
"queue.buffering.backpressure.threshold") &&
|
|
3930
|
+
conf->queue_backpressure_thres > 1)
|
|
3931
|
+
return "`queue.buffering.backpressure."
|
|
3932
|
+
"threshold` "
|
|
3933
|
+
"must be set to 1 when "
|
|
3934
|
+
"`enable.idempotence` is true";
|
|
3935
|
+
else
|
|
3936
|
+
conf->queue_backpressure_thres = 1;
|
|
3937
|
+
|
|
3938
|
+
/* acks=all and queuing.strategy are set
|
|
3939
|
+
* in topic_conf_finalize() */
|
|
3940
|
+
|
|
3941
|
+
} else {
|
|
3942
|
+
if (conf->eos.gapless &&
|
|
3943
|
+
rd_kafka_conf_is_modified(
|
|
3944
|
+
conf, "enable.gapless.guarantee"))
|
|
3945
|
+
return "`enable.gapless.guarantee` requires "
|
|
3946
|
+
"`enable.idempotence` to be enabled";
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
if (!rd_kafka_conf_is_modified(conf,
|
|
3950
|
+
"sticky.partitioning.linger.ms"))
|
|
3951
|
+
conf->sticky_partition_linger_ms = (int)RD_MIN(
|
|
3952
|
+
900000, (rd_ts_t)(2 * conf->buffering_max_ms_dbl));
|
|
3953
|
+
}
|
|
3954
|
+
|
|
3955
|
+
|
|
3956
|
+
if (!rd_kafka_conf_is_modified(conf, "metadata.max.age.ms") &&
|
|
3957
|
+
conf->metadata_refresh_interval_ms > 0)
|
|
3958
|
+
conf->metadata_max_age_ms =
|
|
3959
|
+
conf->metadata_refresh_interval_ms * 3;
|
|
3960
|
+
|
|
3961
|
+
if (conf->reconnect_backoff_max_ms < conf->reconnect_backoff_ms)
|
|
3962
|
+
return "`reconnect.backoff.max.ms` must be >= "
|
|
3963
|
+
"`reconnect.max.ms`";
|
|
3964
|
+
|
|
3965
|
+
if (conf->sparse_connections) {
|
|
3966
|
+
/* Set sparse connection random selection interval to
|
|
3967
|
+
* 10 < reconnect.backoff.ms / 2 < 1000. */
|
|
3968
|
+
conf->sparse_connect_intvl =
|
|
3969
|
+
RD_MAX(11, RD_MIN(conf->reconnect_backoff_ms / 2, 1000));
|
|
3970
|
+
}
|
|
3971
|
+
if (!rd_kafka_conf_is_modified(
|
|
3972
|
+
conf, "topic.metadata.refresh.fast.interval.ms"))
|
|
3973
|
+
conf->metadata_refresh_fast_interval_ms =
|
|
3974
|
+
conf->retry_backoff_ms;
|
|
3975
|
+
|
|
3976
|
+
if (!rd_kafka_conf_is_modified(conf, "connections.max.idle.ms") &&
|
|
3977
|
+
conf->brokerlist && rd_strcasestr(conf->brokerlist, "azure")) {
|
|
3978
|
+
/* Issue #3109:
|
|
3979
|
+
* Default connections.max.idle.ms to <4 minutes on Azure. */
|
|
3980
|
+
conf->connections_max_idle_ms = (4 * 60 - 10) * 1000;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
if (!rd_kafka_conf_is_modified(conf, "allow.auto.create.topics")) {
|
|
3984
|
+
/* Consumer: Do not allow auto create by default.
|
|
3985
|
+
* Producer: Allow auto create by default. */
|
|
3986
|
+
if (cltype == RD_KAFKA_CONSUMER)
|
|
3987
|
+
conf->allow_auto_create_topics = rd_false;
|
|
3988
|
+
else if (cltype == RD_KAFKA_PRODUCER)
|
|
3989
|
+
conf->allow_auto_create_topics = rd_true;
|
|
3990
|
+
}
|
|
3991
|
+
|
|
3992
|
+
/* Finalize and verify the default.topic.config */
|
|
3993
|
+
if (conf->topic_conf) {
|
|
3994
|
+
|
|
3995
|
+
if (cltype == RD_KAFKA_PRODUCER) {
|
|
3996
|
+
rd_kafka_topic_conf_t *tconf = conf->topic_conf;
|
|
3997
|
+
|
|
3998
|
+
if (tconf->message_timeout_ms != 0 &&
|
|
3999
|
+
(double)tconf->message_timeout_ms <=
|
|
4000
|
+
conf->buffering_max_ms_dbl) {
|
|
4001
|
+
if (rd_kafka_conf_is_modified(conf,
|
|
4002
|
+
"linger.ms"))
|
|
4003
|
+
return "`message.timeout.ms` must be "
|
|
4004
|
+
"greater than `linger.ms`";
|
|
4005
|
+
else /* Auto adjust linger.ms to be lower
|
|
4006
|
+
* than message.timeout.ms */
|
|
4007
|
+
conf->buffering_max_ms_dbl =
|
|
4008
|
+
(double)tconf->message_timeout_ms -
|
|
4009
|
+
0.1;
|
|
4010
|
+
}
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
errstr = rd_kafka_topic_conf_finalize(cltype, conf,
|
|
4014
|
+
conf->topic_conf);
|
|
4015
|
+
if (errstr)
|
|
4016
|
+
return errstr;
|
|
4017
|
+
}
|
|
4018
|
+
|
|
4019
|
+
/* Convert double linger.ms to internal int microseconds after
|
|
4020
|
+
* finalizing default_topic_conf since it may
|
|
4021
|
+
* update buffering_max_ms_dbl. */
|
|
4022
|
+
conf->buffering_max_us = (rd_ts_t)(conf->buffering_max_ms_dbl * 1000);
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
return NULL;
|
|
4026
|
+
}
|
|
4027
|
+
|
|
4028
|
+
|
|
4029
|
+
/**
|
|
4030
|
+
* @brief Verify topic configuration \p tconf is
|
|
4031
|
+
* correct/non-conflicting and finalize the configuration
|
|
4032
|
+
* settings for use.
|
|
4033
|
+
*
|
|
4034
|
+
* @returns an error string if configuration is incorrect, else NULL.
|
|
4035
|
+
*/
|
|
4036
|
+
const char *rd_kafka_topic_conf_finalize(rd_kafka_type_t cltype,
|
|
4037
|
+
const rd_kafka_conf_t *conf,
|
|
4038
|
+
rd_kafka_topic_conf_t *tconf) {
|
|
4039
|
+
|
|
4040
|
+
if (cltype != RD_KAFKA_PRODUCER)
|
|
4041
|
+
return NULL;
|
|
4042
|
+
|
|
4043
|
+
if (conf->eos.idempotence) {
|
|
4044
|
+
/* Ensure acks=all */
|
|
4045
|
+
if (rd_kafka_topic_conf_is_modified(tconf, "acks")) {
|
|
4046
|
+
if (tconf->required_acks != -1)
|
|
4047
|
+
return "`acks` must be set to `all` when "
|
|
4048
|
+
"`enable.idempotence` is true";
|
|
4049
|
+
} else {
|
|
4050
|
+
tconf->required_acks = -1; /* all */
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
/* Ensure FIFO queueing */
|
|
4054
|
+
if (rd_kafka_topic_conf_is_modified(tconf,
|
|
4055
|
+
"queuing.strategy")) {
|
|
4056
|
+
if (tconf->queuing_strategy != RD_KAFKA_QUEUE_FIFO)
|
|
4057
|
+
return "`queuing.strategy` must be set to "
|
|
4058
|
+
"`fifo` when `enable.idempotence` is "
|
|
4059
|
+
"true";
|
|
4060
|
+
} else {
|
|
4061
|
+
tconf->queuing_strategy = RD_KAFKA_QUEUE_FIFO;
|
|
4062
|
+
}
|
|
4063
|
+
|
|
4064
|
+
/* Ensure message.timeout.ms <= transaction.timeout.ms */
|
|
4065
|
+
if (conf->eos.transactional_id) {
|
|
4066
|
+
if (!rd_kafka_topic_conf_is_modified(
|
|
4067
|
+
tconf, "message.timeout.ms"))
|
|
4068
|
+
tconf->message_timeout_ms =
|
|
4069
|
+
conf->eos.transaction_timeout_ms;
|
|
4070
|
+
else if (tconf->message_timeout_ms >
|
|
4071
|
+
conf->eos.transaction_timeout_ms)
|
|
4072
|
+
return "`message.timeout.ms` must be set <= "
|
|
4073
|
+
"`transaction.timeout.ms`";
|
|
4074
|
+
}
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
if (tconf->message_timeout_ms != 0 &&
|
|
4078
|
+
(double)tconf->message_timeout_ms <= conf->buffering_max_ms_dbl &&
|
|
4079
|
+
rd_kafka_conf_is_modified(conf, "linger.ms"))
|
|
4080
|
+
return "`message.timeout.ms` must be greater than `linger.ms`";
|
|
4081
|
+
|
|
4082
|
+
return NULL;
|
|
4083
|
+
}
|
|
4084
|
+
|
|
4085
|
+
|
|
4086
|
+
/**
|
|
4087
|
+
* @brief Log warnings for set deprecated or experimental
|
|
4088
|
+
* configuration properties.
|
|
4089
|
+
* @returns the number of warnings logged.
|
|
4090
|
+
*/
|
|
4091
|
+
static int rd_kafka_anyconf_warn_deprecated(rd_kafka_t *rk,
|
|
4092
|
+
rd_kafka_conf_scope_t scope,
|
|
4093
|
+
const void *conf) {
|
|
4094
|
+
const struct rd_kafka_property *prop;
|
|
4095
|
+
int warn_type =
|
|
4096
|
+
rk->rk_type == RD_KAFKA_PRODUCER ? _RK_CONSUMER : _RK_PRODUCER;
|
|
4097
|
+
int warn_on = _RK_DEPRECATED | _RK_EXPERIMENTAL | warn_type;
|
|
4098
|
+
|
|
4099
|
+
int cnt = 0;
|
|
4100
|
+
|
|
4101
|
+
for (prop = rd_kafka_properties; prop->name; prop++) {
|
|
4102
|
+
int match = prop->scope & warn_on;
|
|
4103
|
+
|
|
4104
|
+
if (likely(!(prop->scope & scope) || !match))
|
|
4105
|
+
continue;
|
|
4106
|
+
|
|
4107
|
+
if (likely(!rd_kafka_anyconf_is_modified(conf, prop)))
|
|
4108
|
+
continue;
|
|
4109
|
+
|
|
4110
|
+
if (match != warn_type)
|
|
4111
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4112
|
+
"Configuration property %s is %s%s%s: %s",
|
|
4113
|
+
prop->name,
|
|
4114
|
+
match & _RK_DEPRECATED ? "deprecated" : "",
|
|
4115
|
+
match == warn_on ? " and " : "",
|
|
4116
|
+
match & _RK_EXPERIMENTAL ? "experimental"
|
|
4117
|
+
: "",
|
|
4118
|
+
prop->desc);
|
|
4119
|
+
|
|
4120
|
+
if (match & warn_type)
|
|
4121
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4122
|
+
"Configuration property %s "
|
|
4123
|
+
"is a %s property and will be ignored by "
|
|
4124
|
+
"this %s instance",
|
|
4125
|
+
prop->name,
|
|
4126
|
+
warn_type == _RK_PRODUCER ? "producer"
|
|
4127
|
+
: "consumer",
|
|
4128
|
+
warn_type == _RK_PRODUCER ? "consumer"
|
|
4129
|
+
: "producer");
|
|
4130
|
+
|
|
4131
|
+
cnt++;
|
|
4132
|
+
}
|
|
4133
|
+
|
|
4134
|
+
return cnt;
|
|
4135
|
+
}
|
|
4136
|
+
|
|
4137
|
+
|
|
4138
|
+
/**
|
|
4139
|
+
* @brief Log configuration warnings (deprecated configuration properties,
|
|
4140
|
+
* unrecommended combinations, etc).
|
|
4141
|
+
*
|
|
4142
|
+
* @returns the number of warnings logged.
|
|
4143
|
+
*
|
|
4144
|
+
* @locality any
|
|
4145
|
+
* @locks none
|
|
4146
|
+
*/
|
|
4147
|
+
int rd_kafka_conf_warn(rd_kafka_t *rk) {
|
|
4148
|
+
int cnt = 0;
|
|
4149
|
+
|
|
4150
|
+
cnt = rd_kafka_anyconf_warn_deprecated(rk, _RK_GLOBAL, &rk->rk_conf);
|
|
4151
|
+
if (rk->rk_conf.topic_conf)
|
|
4152
|
+
cnt += rd_kafka_anyconf_warn_deprecated(rk, _RK_TOPIC,
|
|
4153
|
+
rk->rk_conf.topic_conf);
|
|
4154
|
+
|
|
4155
|
+
if (rk->rk_conf.warn.default_topic_conf_overwritten)
|
|
4156
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4157
|
+
"Topic configuration properties set in the "
|
|
4158
|
+
"global configuration were overwritten by "
|
|
4159
|
+
"explicitly setting a default_topic_conf: "
|
|
4160
|
+
"recommend not using set_default_topic_conf");
|
|
4161
|
+
|
|
4162
|
+
/* Additional warnings */
|
|
4163
|
+
if (rk->rk_conf.retry_backoff_ms > rk->rk_conf.retry_backoff_max_ms) {
|
|
4164
|
+
rd_kafka_log(
|
|
4165
|
+
rk, LOG_WARNING, "CONFWARN",
|
|
4166
|
+
"Configuration `retry.backoff.ms` with value %d is greater "
|
|
4167
|
+
"than configuration `retry.backoff.max.ms` with value %d. "
|
|
4168
|
+
"A static backoff with value `retry.backoff.max.ms` will "
|
|
4169
|
+
"be applied.",
|
|
4170
|
+
rk->rk_conf.retry_backoff_ms,
|
|
4171
|
+
rk->rk_conf.retry_backoff_max_ms);
|
|
4172
|
+
}
|
|
4173
|
+
|
|
4174
|
+
if (rd_kafka_conf_is_modified(
|
|
4175
|
+
&rk->rk_conf, "topic.metadata.refresh.fast.interval.ms") &&
|
|
4176
|
+
rk->rk_conf.metadata_refresh_fast_interval_ms >
|
|
4177
|
+
rk->rk_conf.retry_backoff_max_ms) {
|
|
4178
|
+
rd_kafka_log(
|
|
4179
|
+
rk, LOG_WARNING, "CONFWARN",
|
|
4180
|
+
"Configuration `topic.metadata.refresh.fast.interval.ms` "
|
|
4181
|
+
"with value %d is greater than configuration "
|
|
4182
|
+
"`retry.backoff.max.ms` with value %d. "
|
|
4183
|
+
"A static backoff with value `retry.backoff.max.ms` will "
|
|
4184
|
+
"be applied.",
|
|
4185
|
+
rk->rk_conf.metadata_refresh_fast_interval_ms,
|
|
4186
|
+
rk->rk_conf.retry_backoff_max_ms);
|
|
4187
|
+
}
|
|
4188
|
+
if (rk->rk_type == RD_KAFKA_CONSUMER) {
|
|
4189
|
+
if (rk->rk_conf.fetch_wait_max_ms + 1000 >
|
|
4190
|
+
rk->rk_conf.socket_timeout_ms)
|
|
4191
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4192
|
+
"Configuration property "
|
|
4193
|
+
"`fetch.wait.max.ms` (%d) should be "
|
|
4194
|
+
"set lower than `socket.timeout.ms` (%d) "
|
|
4195
|
+
"by at least 1000ms to avoid blocking "
|
|
4196
|
+
"and timing out sub-sequent requests",
|
|
4197
|
+
rk->rk_conf.fetch_wait_max_ms,
|
|
4198
|
+
rk->rk_conf.socket_timeout_ms);
|
|
4199
|
+
}
|
|
4200
|
+
|
|
4201
|
+
if (rd_kafka_conf_is_modified(&rk->rk_conf, "sasl.mechanisms") &&
|
|
4202
|
+
!(rk->rk_conf.security_protocol == RD_KAFKA_PROTO_SASL_SSL ||
|
|
4203
|
+
rk->rk_conf.security_protocol == RD_KAFKA_PROTO_SASL_PLAINTEXT)) {
|
|
4204
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4205
|
+
"Configuration property `sasl.mechanism` set to "
|
|
4206
|
+
"`%s` but `security.protocol` is not configured "
|
|
4207
|
+
"for SASL: recommend setting "
|
|
4208
|
+
"`security.protocol` to SASL_SSL or "
|
|
4209
|
+
"SASL_PLAINTEXT",
|
|
4210
|
+
rk->rk_conf.sasl.mechanisms);
|
|
4211
|
+
}
|
|
4212
|
+
|
|
4213
|
+
if (rd_kafka_conf_is_modified(&rk->rk_conf, "sasl.username") &&
|
|
4214
|
+
!(!strncmp(rk->rk_conf.sasl.mechanisms, "SCRAM", 5) ||
|
|
4215
|
+
!strcmp(rk->rk_conf.sasl.mechanisms, "PLAIN")))
|
|
4216
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4217
|
+
"Configuration property `sasl.username` only "
|
|
4218
|
+
"applies when `sasl.mechanism` is set to "
|
|
4219
|
+
"PLAIN or SCRAM-SHA-..");
|
|
4220
|
+
|
|
4221
|
+
if (rd_kafka_conf_is_modified(&rk->rk_conf, "client.software.name") &&
|
|
4222
|
+
!rd_kafka_sw_str_is_safe(rk->rk_conf.sw_name))
|
|
4223
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4224
|
+
"Configuration property `client.software.name` "
|
|
4225
|
+
"may only contain 'a-zA-Z0-9.-', other characters "
|
|
4226
|
+
"will be replaced with '-'");
|
|
4227
|
+
|
|
4228
|
+
if (rd_kafka_conf_is_modified(&rk->rk_conf,
|
|
4229
|
+
"client.software.version") &&
|
|
4230
|
+
!rd_kafka_sw_str_is_safe(rk->rk_conf.sw_version))
|
|
4231
|
+
rd_kafka_log(rk, LOG_WARNING, "CONFWARN",
|
|
4232
|
+
"Configuration property `client.software.verison` "
|
|
4233
|
+
"may only contain 'a-zA-Z0-9.-', other characters "
|
|
4234
|
+
"will be replaced with '-'");
|
|
4235
|
+
|
|
4236
|
+
if (rd_atomic32_get(&rk->rk_broker_cnt) == 0)
|
|
4237
|
+
rd_kafka_log(rk, LOG_NOTICE, "CONFWARN",
|
|
4238
|
+
"No `bootstrap.servers` configured: "
|
|
4239
|
+
"client will not be able to connect "
|
|
4240
|
+
"to Kafka cluster");
|
|
4241
|
+
|
|
4242
|
+
return cnt;
|
|
4243
|
+
}
|
|
4244
|
+
|
|
4245
|
+
|
|
4246
|
+
const rd_kafka_conf_t *rd_kafka_conf(rd_kafka_t *rk) {
|
|
4247
|
+
return &rk->rk_conf;
|
|
4248
|
+
}
|
|
4249
|
+
|
|
4250
|
+
|
|
4251
|
+
/**
|
|
4252
|
+
* @brief Unittests
|
|
4253
|
+
*/
|
|
4254
|
+
int unittest_conf(void) {
|
|
4255
|
+
rd_kafka_conf_t *conf;
|
|
4256
|
+
rd_kafka_topic_conf_t *tconf;
|
|
4257
|
+
rd_kafka_conf_res_t res, res2;
|
|
4258
|
+
char errstr[128];
|
|
4259
|
+
int iteration;
|
|
4260
|
+
const struct rd_kafka_property *prop;
|
|
4261
|
+
char readval[512];
|
|
4262
|
+
size_t readlen;
|
|
4263
|
+
const char *errstr2;
|
|
4264
|
+
|
|
4265
|
+
conf = rd_kafka_conf_new();
|
|
4266
|
+
tconf = rd_kafka_topic_conf_new();
|
|
4267
|
+
|
|
4268
|
+
res = rd_kafka_conf_set(conf, "unknown.thing", "foo", errstr,
|
|
4269
|
+
sizeof(errstr));
|
|
4270
|
+
RD_UT_ASSERT(res == RD_KAFKA_CONF_UNKNOWN, "fail");
|
|
4271
|
+
RD_UT_ASSERT(*errstr, "fail");
|
|
4272
|
+
|
|
4273
|
+
for (iteration = 0; iteration < 5; iteration++) {
|
|
4274
|
+
int cnt;
|
|
4275
|
+
|
|
4276
|
+
|
|
4277
|
+
/* Iterations:
|
|
4278
|
+
* 0 - Check is_modified
|
|
4279
|
+
* 1 - Set every other config property, read back and verify.
|
|
4280
|
+
* 2 - Check is_modified.
|
|
4281
|
+
* 3 - Set all config properties, read back and verify.
|
|
4282
|
+
* 4 - Check is_modified. */
|
|
4283
|
+
for (prop = rd_kafka_properties, cnt = 0; prop->name;
|
|
4284
|
+
prop++, cnt++) {
|
|
4285
|
+
const char *val;
|
|
4286
|
+
char tmp[64];
|
|
4287
|
+
int odd = cnt & 1;
|
|
4288
|
+
int do_set = iteration == 3 || (iteration == 1 && odd);
|
|
4289
|
+
rd_bool_t is_modified;
|
|
4290
|
+
int exp_is_modified =
|
|
4291
|
+
!prop->unsupported &&
|
|
4292
|
+
(iteration >= 3 ||
|
|
4293
|
+
(iteration > 0 && (do_set || odd)));
|
|
4294
|
+
|
|
4295
|
+
readlen = sizeof(readval);
|
|
4296
|
+
|
|
4297
|
+
/* Avoid some special configs */
|
|
4298
|
+
if (!strcmp(prop->name, "plugin.library.paths") ||
|
|
4299
|
+
!strcmp(prop->name, "builtin.features"))
|
|
4300
|
+
continue;
|
|
4301
|
+
|
|
4302
|
+
switch (prop->type) {
|
|
4303
|
+
case _RK_C_STR:
|
|
4304
|
+
case _RK_C_KSTR:
|
|
4305
|
+
case _RK_C_PATLIST:
|
|
4306
|
+
if (prop->sdef)
|
|
4307
|
+
val = prop->sdef;
|
|
4308
|
+
else
|
|
4309
|
+
val = "test";
|
|
4310
|
+
break;
|
|
4311
|
+
|
|
4312
|
+
case _RK_C_BOOL:
|
|
4313
|
+
val = "true";
|
|
4314
|
+
break;
|
|
4315
|
+
|
|
4316
|
+
case _RK_C_INT:
|
|
4317
|
+
rd_snprintf(tmp, sizeof(tmp), "%d", prop->vdef);
|
|
4318
|
+
val = tmp;
|
|
4319
|
+
break;
|
|
4320
|
+
|
|
4321
|
+
case _RK_C_DBL:
|
|
4322
|
+
rd_snprintf(tmp, sizeof(tmp), "%g", prop->ddef);
|
|
4323
|
+
val = tmp;
|
|
4324
|
+
break;
|
|
4325
|
+
|
|
4326
|
+
case _RK_C_S2F:
|
|
4327
|
+
case _RK_C_S2I:
|
|
4328
|
+
val = prop->s2i[0].str;
|
|
4329
|
+
break;
|
|
4330
|
+
|
|
4331
|
+
case _RK_C_PTR:
|
|
4332
|
+
case _RK_C_ALIAS:
|
|
4333
|
+
case _RK_C_INVALID:
|
|
4334
|
+
case _RK_C_INTERNAL:
|
|
4335
|
+
default:
|
|
4336
|
+
continue;
|
|
4337
|
+
}
|
|
4338
|
+
|
|
4339
|
+
|
|
4340
|
+
if (prop->scope & _RK_GLOBAL) {
|
|
4341
|
+
if (do_set)
|
|
4342
|
+
res = rd_kafka_conf_set(
|
|
4343
|
+
conf, prop->name, val, errstr,
|
|
4344
|
+
sizeof(errstr));
|
|
4345
|
+
|
|
4346
|
+
res2 = rd_kafka_conf_get(conf, prop->name,
|
|
4347
|
+
readval, &readlen);
|
|
4348
|
+
|
|
4349
|
+
is_modified =
|
|
4350
|
+
rd_kafka_conf_is_modified(conf, prop->name);
|
|
4351
|
+
|
|
4352
|
+
|
|
4353
|
+
} else if (prop->scope & _RK_TOPIC) {
|
|
4354
|
+
if (do_set)
|
|
4355
|
+
res = rd_kafka_topic_conf_set(
|
|
4356
|
+
tconf, prop->name, val, errstr,
|
|
4357
|
+
sizeof(errstr));
|
|
4358
|
+
|
|
4359
|
+
res2 = rd_kafka_topic_conf_get(
|
|
4360
|
+
tconf, prop->name, readval, &readlen);
|
|
4361
|
+
|
|
4362
|
+
is_modified = rd_kafka_topic_conf_is_modified(
|
|
4363
|
+
tconf, prop->name);
|
|
4364
|
+
|
|
4365
|
+
} else {
|
|
4366
|
+
RD_NOTREACHED();
|
|
4367
|
+
}
|
|
4368
|
+
|
|
4369
|
+
|
|
4370
|
+
|
|
4371
|
+
if (do_set && prop->unsupported) {
|
|
4372
|
+
RD_UT_ASSERT(res == RD_KAFKA_CONF_INVALID,
|
|
4373
|
+
"conf_set %s should've failed "
|
|
4374
|
+
"with CONF_INVALID, not %d: %s",
|
|
4375
|
+
prop->name, res, errstr);
|
|
4376
|
+
|
|
4377
|
+
} else if (do_set) {
|
|
4378
|
+
RD_UT_ASSERT(res == RD_KAFKA_CONF_OK,
|
|
4379
|
+
"conf_set %s failed: %d: %s",
|
|
4380
|
+
prop->name, res, errstr);
|
|
4381
|
+
RD_UT_ASSERT(res2 == RD_KAFKA_CONF_OK,
|
|
4382
|
+
"conf_get %s failed: %d",
|
|
4383
|
+
prop->name, res2);
|
|
4384
|
+
|
|
4385
|
+
RD_UT_ASSERT(!strcmp(readval, val),
|
|
4386
|
+
"conf_get %s "
|
|
4387
|
+
"returned \"%s\": "
|
|
4388
|
+
"expected \"%s\"",
|
|
4389
|
+
prop->name, readval, val);
|
|
4390
|
+
|
|
4391
|
+
RD_UT_ASSERT(is_modified,
|
|
4392
|
+
"Property %s was set but "
|
|
4393
|
+
"is_modified=%d",
|
|
4394
|
+
prop->name, is_modified);
|
|
4395
|
+
}
|
|
4396
|
+
|
|
4397
|
+
assert(is_modified == exp_is_modified);
|
|
4398
|
+
RD_UT_ASSERT(is_modified == exp_is_modified,
|
|
4399
|
+
"Property %s is_modified=%d, "
|
|
4400
|
+
"exp_is_modified=%d "
|
|
4401
|
+
"(iter %d, odd %d, do_set %d)",
|
|
4402
|
+
prop->name, is_modified, exp_is_modified,
|
|
4403
|
+
iteration, odd, do_set);
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
|
|
4407
|
+
/* Set an alias and make sure is_modified() works for it. */
|
|
4408
|
+
res = rd_kafka_conf_set(conf, "max.in.flight", "19", NULL, 0);
|
|
4409
|
+
RD_UT_ASSERT(res == RD_KAFKA_CONF_OK, "%d", res);
|
|
4410
|
+
|
|
4411
|
+
RD_UT_ASSERT(rd_kafka_conf_is_modified(conf, "max.in.flight") ==
|
|
4412
|
+
rd_true,
|
|
4413
|
+
"fail");
|
|
4414
|
+
RD_UT_ASSERT(rd_kafka_conf_is_modified(
|
|
4415
|
+
conf, "max.in.flight.requests.per.connection") ==
|
|
4416
|
+
rd_true,
|
|
4417
|
+
"fail");
|
|
4418
|
+
|
|
4419
|
+
rd_kafka_conf_destroy(conf);
|
|
4420
|
+
rd_kafka_topic_conf_destroy(tconf);
|
|
4421
|
+
|
|
4422
|
+
|
|
4423
|
+
/* Verify that software.client.* string-safing works */
|
|
4424
|
+
conf = rd_kafka_conf_new();
|
|
4425
|
+
res = rd_kafka_conf_set(conf, "client.software.name",
|
|
4426
|
+
" .~aba. va! !.~~", NULL, 0);
|
|
4427
|
+
RD_UT_ASSERT(res == RD_KAFKA_CONF_OK, "%d", res);
|
|
4428
|
+
res = rd_kafka_conf_set(conf, "client.software.version",
|
|
4429
|
+
"!1.2.3.4.5!!! a", NULL, 0);
|
|
4430
|
+
RD_UT_ASSERT(res == RD_KAFKA_CONF_OK, "%d", res);
|
|
4431
|
+
|
|
4432
|
+
errstr2 = rd_kafka_conf_finalize(RD_KAFKA_PRODUCER, conf);
|
|
4433
|
+
RD_UT_ASSERT(!errstr2, "conf_finalize() failed: %s", errstr2);
|
|
4434
|
+
|
|
4435
|
+
readlen = sizeof(readval);
|
|
4436
|
+
res2 =
|
|
4437
|
+
rd_kafka_conf_get(conf, "client.software.name", readval, &readlen);
|
|
4438
|
+
RD_UT_ASSERT(res2 == RD_KAFKA_CONF_OK, "%d", res2);
|
|
4439
|
+
RD_UT_ASSERT(!strcmp(readval, "aba.-va"),
|
|
4440
|
+
"client.software.* safification failed: \"%s\"", readval);
|
|
4441
|
+
RD_UT_SAY("Safified client.software.name=\"%s\"", readval);
|
|
4442
|
+
|
|
4443
|
+
readlen = sizeof(readval);
|
|
4444
|
+
res2 = rd_kafka_conf_get(conf, "client.software.version", readval,
|
|
4445
|
+
&readlen);
|
|
4446
|
+
RD_UT_ASSERT(res2 == RD_KAFKA_CONF_OK, "%d", res2);
|
|
4447
|
+
RD_UT_ASSERT(!strcmp(readval, "1.2.3.4.5----a"),
|
|
4448
|
+
"client.software.* safification failed: \"%s\"", readval);
|
|
4449
|
+
RD_UT_SAY("Safified client.software.version=\"%s\"", readval);
|
|
4450
|
+
|
|
4451
|
+
rd_kafka_conf_destroy(conf);
|
|
4452
|
+
|
|
4453
|
+
RD_UT_PASS();
|
|
4454
|
+
}
|
|
4455
|
+
|
|
4456
|
+
/**@}*/
|