@point3/node-rdkafka 3.6.0-1
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/LICENSE.txt +20 -0
- package/README.md +636 -0
- package/binding.gyp +154 -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/.github/CODEOWNERS +1 -0
- package/deps/librdkafka/.github/ISSUE_TEMPLATE +34 -0
- package/deps/librdkafka/.semaphore/run-all-tests.yml +77 -0
- package/deps/librdkafka/.semaphore/semaphore-integration.yml +250 -0
- package/deps/librdkafka/.semaphore/semaphore.yml +378 -0
- package/deps/librdkafka/.semaphore/verify-linux-packages.yml +41 -0
- package/deps/librdkafka/CHANGELOG.md +2208 -0
- package/deps/librdkafka/CMakeLists.txt +291 -0
- package/deps/librdkafka/CODE_OF_CONDUCT.md +46 -0
- package/deps/librdkafka/CONFIGURATION.md +209 -0
- package/deps/librdkafka/CONTRIBUTING.md +431 -0
- package/deps/librdkafka/Doxyfile +2375 -0
- package/deps/librdkafka/INTRODUCTION.md +2481 -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 +125 -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 +271 -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 +455 -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 +347 -0
- package/deps/librdkafka/examples/kafkatest_verifiable_client.cpp +945 -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 +248 -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 +491 -0
- package/deps/librdkafka/examples/win_ssl_cert_store.cpp +396 -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 +319 -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 +16 -0
- package/deps/librdkafka/packaging/cp/check_features.c +72 -0
- package/deps/librdkafka/packaging/cp/verify-deb.sh +33 -0
- package/deps/librdkafka/packaging/cp/verify-packages.sh +69 -0
- package/deps/librdkafka/packaging/cp/verify-rpm.sh +32 -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/docs +5 -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/export-variables.sh +13 -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/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/Dockerfile +31 -0
- package/deps/librdkafka/packaging/tools/build-configurations-checks.sh +12 -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/run-in-docker.sh +28 -0
- package/deps/librdkafka/packaging/tools/run-integration-tests.sh +31 -0
- package/deps/librdkafka/packaging/tools/run-style-check.sh +4 -0
- package/deps/librdkafka/packaging/tools/style-format.sh +149 -0
- package/deps/librdkafka/packaging/tools/update_rpcs_max_versions.py +100 -0
- package/deps/librdkafka/service.yml +172 -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 +584 -0
- package/deps/librdkafka/src/rdaddr.c +255 -0
- package/deps/librdkafka/src/rdaddr.h +202 -0
- package/deps/librdkafka/src/rdatomic.h +230 -0
- package/deps/librdkafka/src/rdavg.h +260 -0
- package/deps/librdkafka/src/rdavl.c +210 -0
- package/deps/librdkafka/src/rdavl.h +250 -0
- package/deps/librdkafka/src/rdbase64.c +200 -0
- package/deps/librdkafka/src/rdbase64.h +43 -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 +175 -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 +830 -0
- package/deps/librdkafka/src/rdhttp.h +101 -0
- package/deps/librdkafka/src/rdinterval.h +177 -0
- package/deps/librdkafka/src/rdkafka.c +5505 -0
- package/deps/librdkafka/src/rdkafka.h +10686 -0
- package/deps/librdkafka/src/rdkafka_admin.c +9794 -0
- package/deps/librdkafka/src/rdkafka_admin.h +661 -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 +6337 -0
- package/deps/librdkafka/src/rdkafka_broker.h +744 -0
- package/deps/librdkafka/src/rdkafka_buf.c +543 -0
- package/deps/librdkafka/src/rdkafka_buf.h +1525 -0
- package/deps/librdkafka/src/rdkafka_cert.c +576 -0
- package/deps/librdkafka/src/rdkafka_cert.h +62 -0
- package/deps/librdkafka/src/rdkafka_cgrp.c +7587 -0
- package/deps/librdkafka/src/rdkafka_cgrp.h +477 -0
- package/deps/librdkafka/src/rdkafka_conf.c +4880 -0
- package/deps/librdkafka/src/rdkafka_conf.h +732 -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 +898 -0
- package/deps/librdkafka/src/rdkafka_feature.h +104 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +1422 -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 +1260 -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 +2209 -0
- package/deps/librdkafka/src/rdkafka_metadata.h +345 -0
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +1183 -0
- package/deps/librdkafka/src/rdkafka_mock.c +3661 -0
- package/deps/librdkafka/src/rdkafka_mock.h +610 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +1876 -0
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +3113 -0
- package/deps/librdkafka/src/rdkafka_mock_int.h +710 -0
- package/deps/librdkafka/src/rdkafka_msg.c +2589 -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 +1474 -0
- package/deps/librdkafka/src/rdkafka_offset.c +1565 -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 +858 -0
- package/deps/librdkafka/src/rdkafka_partition.c +4896 -0
- package/deps/librdkafka/src/rdkafka_partition.h +1182 -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 +736 -0
- package/deps/librdkafka/src/rdkafka_protocol.h +128 -0
- package/deps/librdkafka/src/rdkafka_queue.c +1230 -0
- package/deps/librdkafka/src/rdkafka_queue.h +1220 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1748 -0
- package/deps/librdkafka/src/rdkafka_request.c +7089 -0
- package/deps/librdkafka/src/rdkafka_request.h +732 -0
- package/deps/librdkafka/src/rdkafka_roundrobin_assignor.c +123 -0
- package/deps/librdkafka/src/rdkafka_sasl.c +530 -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 +1833 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +1666 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +47 -0
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +142 -0
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +858 -0
- package/deps/librdkafka/src/rdkafka_sasl_win32.c +550 -0
- package/deps/librdkafka/src/rdkafka_ssl.c +2129 -0
- package/deps/librdkafka/src/rdkafka_ssl.h +86 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4785 -0
- package/deps/librdkafka/src/rdkafka_subscription.c +278 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +760 -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 +997 -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 +2161 -0
- package/deps/librdkafka/src/rdkafka_topic.h +334 -0
- package/deps/librdkafka/src/rdkafka_transport.c +1309 -0
- package/deps/librdkafka/src/rdkafka_transport.h +99 -0
- package/deps/librdkafka/src/rdkafka_transport_int.h +100 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +3256 -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 +508 -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 +80 -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 +356 -0
- package/deps/librdkafka/src/rdtypes.h +86 -0
- package/deps/librdkafka/src/rdunittest.c +549 -0
- package/deps/librdkafka/src/rdunittest.h +232 -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 +1352 -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 +199 -0
- package/deps/librdkafka/src/tinycthread_extra.h +212 -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 +3797 -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 +102 -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 +934 -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 +97 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +753 -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 +181 -0
- package/deps/librdkafka/tests/0017-compression.c +140 -0
- package/deps/librdkafka/tests/0018-cgrp_term.c +338 -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 +72 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +279 -0
- package/deps/librdkafka/tests/0025-timers.c +147 -0
- package/deps/librdkafka/tests/0026-consume_pause.c +547 -0
- package/deps/librdkafka/tests/0028-long_topicnames.c +79 -0
- package/deps/librdkafka/tests/0029-assign_offset.c +202 -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 +536 -0
- package/deps/librdkafka/tests/0034-offset_reset.c +398 -0
- package/deps/librdkafka/tests/0035-api_version.c +73 -0
- package/deps/librdkafka/tests/0036-partial_fetch.c +87 -0
- package/deps/librdkafka/tests/0037-destroy_hang_local.c +85 -0
- package/deps/librdkafka/tests/0038-performance.c +121 -0
- package/deps/librdkafka/tests/0039-event.c +284 -0
- package/deps/librdkafka/tests/0040-io_event.c +257 -0
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +97 -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 +94 -0
- package/deps/librdkafka/tests/0045-subscribe_update.c +1010 -0
- package/deps/librdkafka/tests/0046-rkt_cache.c +65 -0
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +98 -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 +145 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +126 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +238 -0
- package/deps/librdkafka/tests/0053-stats_cb.cpp +527 -0
- package/deps/librdkafka/tests/0054-offset_time.cpp +236 -0
- package/deps/librdkafka/tests/0055-producer_latency.c +539 -0
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +315 -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 +241 -0
- package/deps/librdkafka/tests/0060-op_prio.cpp +163 -0
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +295 -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 +151 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +136 -0
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +119 -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 +290 -0
- package/deps/librdkafka/tests/0076-produce_retry.c +452 -0
- package/deps/librdkafka/tests/0077-compaction.c +363 -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 +3095 -0
- package/deps/librdkafka/tests/0081-admin.c +5633 -0
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +137 -0
- package/deps/librdkafka/tests/0083-cb_event.c +233 -0
- package/deps/librdkafka/tests/0084-destroy_flags.c +208 -0
- package/deps/librdkafka/tests/0085-headers.cpp +392 -0
- package/deps/librdkafka/tests/0086-purge.c +368 -0
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +162 -0
- package/deps/librdkafka/tests/0089-max_poll_interval.c +511 -0
- package/deps/librdkafka/tests/0090-idempotence.c +171 -0
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +295 -0
- package/deps/librdkafka/tests/0092-mixed_msgver.c +103 -0
- package/deps/librdkafka/tests/0093-holb.c +200 -0
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +231 -0
- package/deps/librdkafka/tests/0095-all_brokers_down.cpp +122 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +658 -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 +836 -0
- package/deps/librdkafka/tests/0103-transactions.c +1383 -0
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +625 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +3930 -0
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +318 -0
- package/deps/librdkafka/tests/0107-topic_recreate.c +259 -0
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +278 -0
- package/deps/librdkafka/tests/0110-batch_size.cpp +182 -0
- package/deps/librdkafka/tests/0111-delay_create_topics.cpp +127 -0
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +87 -0
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +3473 -0
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +176 -0
- package/deps/librdkafka/tests/0115-producer_auth.cpp +182 -0
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +216 -0
- package/deps/librdkafka/tests/0117-mock_errors.c +331 -0
- package/deps/librdkafka/tests/0118-commit_rebalance.c +154 -0
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +167 -0
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +185 -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 +528 -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 +79 -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 +179 -0
- package/deps/librdkafka/tests/0133-ssl_keys.c +150 -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 +619 -0
- package/deps/librdkafka/tests/0138-admin_mock.c +281 -0
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +950 -0
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +108 -0
- package/deps/librdkafka/tests/0142-reauthentication.c +515 -0
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +552 -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 +505 -0
- package/deps/librdkafka/tests/0147-consumer_group_consumer_mock.c +952 -0
- package/deps/librdkafka/tests/0148-offset_fetch_commit_error_mock.c +563 -0
- package/deps/librdkafka/tests/0149-broker-same-host-port.c +140 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +651 -0
- package/deps/librdkafka/tests/0151-purge-brokers.c +566 -0
- package/deps/librdkafka/tests/0152-rebootstrap.c +59 -0
- package/deps/librdkafka/tests/0153-memberid.c +128 -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 +170 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +291 -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/oauthbearer/jwt_assertion_template.json +10 -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.intermediate.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.intermediate.pem +72 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +50 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.intermediate.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +168 -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 +13 -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-all-tests.sh +79 -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-batches.py +157 -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 +7778 -0
- package/deps/librdkafka/tests/test.conf.example +27 -0
- package/deps/librdkafka/tests/test.h +1028 -0
- package/deps/librdkafka/tests/testcpp.cpp +131 -0
- package/deps/librdkafka/tests/testcpp.h +388 -0
- package/deps/librdkafka/tests/testshared.h +416 -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/trivup/trivup-0.14.0.tar.gz +0 -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/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 +47 -0
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +34 -0
- package/deps/librdkafka/win32/tests/test.conf.example +25 -0
- package/deps/librdkafka/win32/tests/tests.vcxproj +253 -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 +101 -0
- package/deps/librdkafka/win32/wintime.h +33 -0
- package/deps/librdkafka.gyp +62 -0
- package/lib/admin.js +233 -0
- package/lib/client.js +573 -0
- package/lib/error.js +500 -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/package.json +61 -0
- package/prebuilds/darwin-arm64/@point3+node-rdkafka.node +0 -0
- package/prebuilds/linux-x64/@point3+node-rdkafka.node +0 -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
|
@@ -0,0 +1,3797 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* librdkafka - Apache Kafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2014-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
|
+
#ifndef _RDKAFKACPP_H_
|
|
31
|
+
#define _RDKAFKACPP_H_
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @file rdkafkacpp.h
|
|
35
|
+
* @brief Apache Kafka C/C++ consumer and producer client library.
|
|
36
|
+
*
|
|
37
|
+
* rdkafkacpp.h contains the public C++ API for librdkafka.
|
|
38
|
+
* The API is documented in this file as comments prefixing the class,
|
|
39
|
+
* function, type, enum, define, etc.
|
|
40
|
+
* For more information, see the C interface in rdkafka.h and read the
|
|
41
|
+
* manual in INTRODUCTION.md.
|
|
42
|
+
* The C++ interface is STD C++ '03 compliant and adheres to the
|
|
43
|
+
* Google C++ Style Guide.
|
|
44
|
+
|
|
45
|
+
* @sa For the C interface see rdkafka.h
|
|
46
|
+
*
|
|
47
|
+
* @tableofcontents
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/**@cond NO_DOC*/
|
|
51
|
+
#include <string>
|
|
52
|
+
#include <list>
|
|
53
|
+
#include <vector>
|
|
54
|
+
#include <cstdlib>
|
|
55
|
+
#include <cstring>
|
|
56
|
+
#include <stdint.h>
|
|
57
|
+
#include <sys/types.h>
|
|
58
|
+
|
|
59
|
+
#ifdef _WIN32
|
|
60
|
+
#ifndef ssize_t
|
|
61
|
+
#ifndef _BASETSD_H_
|
|
62
|
+
#include <basetsd.h>
|
|
63
|
+
#endif
|
|
64
|
+
#ifndef _SSIZE_T_DEFINED
|
|
65
|
+
#define _SSIZE_T_DEFINED
|
|
66
|
+
typedef SSIZE_T ssize_t;
|
|
67
|
+
#endif
|
|
68
|
+
#endif
|
|
69
|
+
#undef RD_EXPORT
|
|
70
|
+
#ifdef LIBRDKAFKA_STATICLIB
|
|
71
|
+
#define RD_EXPORT
|
|
72
|
+
#else
|
|
73
|
+
#ifdef LIBRDKAFKACPP_EXPORTS
|
|
74
|
+
#define RD_EXPORT __declspec(dllexport)
|
|
75
|
+
#else
|
|
76
|
+
#define RD_EXPORT __declspec(dllimport)
|
|
77
|
+
#endif
|
|
78
|
+
#endif
|
|
79
|
+
#else
|
|
80
|
+
#define RD_EXPORT
|
|
81
|
+
#endif
|
|
82
|
+
|
|
83
|
+
/**@endcond*/
|
|
84
|
+
|
|
85
|
+
extern "C" {
|
|
86
|
+
/* Forward declarations */
|
|
87
|
+
struct rd_kafka_s;
|
|
88
|
+
struct rd_kafka_topic_s;
|
|
89
|
+
struct rd_kafka_message_s;
|
|
90
|
+
struct rd_kafka_conf_s;
|
|
91
|
+
struct rd_kafka_topic_conf_s;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
namespace RdKafka {
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* @name Miscellaneous APIs
|
|
98
|
+
* @{
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @brief librdkafka version
|
|
103
|
+
*
|
|
104
|
+
* Interpreted as hex \c MM.mm.rr.xx:
|
|
105
|
+
* - MM = Major
|
|
106
|
+
* - mm = minor
|
|
107
|
+
* - rr = revision
|
|
108
|
+
* - xx = pre-release id (0xff is the final release)
|
|
109
|
+
*
|
|
110
|
+
* E.g.: \c 0x000801ff = 0.8.1
|
|
111
|
+
*
|
|
112
|
+
* @remark This value should only be used during compile time,
|
|
113
|
+
* for runtime checks of version use RdKafka::version()
|
|
114
|
+
*/
|
|
115
|
+
#define RD_KAFKA_VERSION 0x020c00ff
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* @brief Returns the librdkafka version as integer.
|
|
119
|
+
*
|
|
120
|
+
* @sa See RD_KAFKA_VERSION for how to parse the integer format.
|
|
121
|
+
*/
|
|
122
|
+
RD_EXPORT
|
|
123
|
+
int version();
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @brief Returns the librdkafka version as string.
|
|
127
|
+
*/
|
|
128
|
+
RD_EXPORT
|
|
129
|
+
std::string version_str();
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* @brief Returns a CSV list of the supported debug contexts
|
|
133
|
+
* for use with Conf::Set("debug", ..).
|
|
134
|
+
*/
|
|
135
|
+
RD_EXPORT
|
|
136
|
+
std::string get_debug_contexts();
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* @brief Wait for all rd_kafka_t objects to be destroyed.
|
|
140
|
+
*
|
|
141
|
+
* @returns 0 if all kafka objects are now destroyed, or -1 if the
|
|
142
|
+
* timeout was reached.
|
|
143
|
+
* Since RdKafka handle deletion is an asynch operation the
|
|
144
|
+
* \p wait_destroyed() function can be used for applications where
|
|
145
|
+
* a clean shutdown is required.
|
|
146
|
+
*/
|
|
147
|
+
RD_EXPORT
|
|
148
|
+
int wait_destroyed(int timeout_ms);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* @brief Allocate memory using the same allocator librdkafka uses.
|
|
152
|
+
*
|
|
153
|
+
* This is typically an abstraction for the malloc(3) call and makes sure
|
|
154
|
+
* the application can use the same memory allocator as librdkafka for
|
|
155
|
+
* allocating pointers that are used by librdkafka.
|
|
156
|
+
*
|
|
157
|
+
* @remark Memory allocated by mem_malloc() must be freed using
|
|
158
|
+
* mem_free().
|
|
159
|
+
*/
|
|
160
|
+
RD_EXPORT
|
|
161
|
+
void *mem_malloc(size_t size);
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* @brief Free pointer returned by librdkafka
|
|
165
|
+
*
|
|
166
|
+
* This is typically an abstraction for the free(3) call and makes sure
|
|
167
|
+
* the application can use the same memory allocator as librdkafka for
|
|
168
|
+
* freeing pointers returned by librdkafka.
|
|
169
|
+
*
|
|
170
|
+
* In standard setups it is usually not necessary to use this interface
|
|
171
|
+
* rather than the free(3) function.
|
|
172
|
+
*
|
|
173
|
+
* @remark mem_free() must only be used for pointers returned by APIs
|
|
174
|
+
* that explicitly mention using this function for freeing.
|
|
175
|
+
*/
|
|
176
|
+
RD_EXPORT
|
|
177
|
+
void mem_free(void *ptr);
|
|
178
|
+
|
|
179
|
+
/**@}*/
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* @name Constants, errors, types
|
|
185
|
+
* @{
|
|
186
|
+
*
|
|
187
|
+
*
|
|
188
|
+
*/
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @brief Error codes.
|
|
192
|
+
*
|
|
193
|
+
* The negative error codes delimited by two underscores
|
|
194
|
+
* (\c _ERR__..) denotes errors internal to librdkafka and are
|
|
195
|
+
* displayed as \c \"Local: \<error string..\>\", while the error codes
|
|
196
|
+
* delimited by a single underscore (\c ERR_..) denote broker
|
|
197
|
+
* errors and are displayed as \c \"Broker: \<error string..\>\".
|
|
198
|
+
*
|
|
199
|
+
* @sa Use RdKafka::err2str() to translate an error code a human readable string
|
|
200
|
+
*/
|
|
201
|
+
enum ErrorCode {
|
|
202
|
+
/* Internal errors to rdkafka: */
|
|
203
|
+
/** Begin internal error codes */
|
|
204
|
+
ERR__BEGIN = -200,
|
|
205
|
+
/** Received message is incorrect */
|
|
206
|
+
ERR__BAD_MSG = -199,
|
|
207
|
+
/** Bad/unknown compression */
|
|
208
|
+
ERR__BAD_COMPRESSION = -198,
|
|
209
|
+
/** Broker is going away */
|
|
210
|
+
ERR__DESTROY = -197,
|
|
211
|
+
/** Generic failure */
|
|
212
|
+
ERR__FAIL = -196,
|
|
213
|
+
/** Broker transport failure */
|
|
214
|
+
ERR__TRANSPORT = -195,
|
|
215
|
+
/** Critical system resource */
|
|
216
|
+
ERR__CRIT_SYS_RESOURCE = -194,
|
|
217
|
+
/** Failed to resolve broker */
|
|
218
|
+
ERR__RESOLVE = -193,
|
|
219
|
+
/** Produced message timed out*/
|
|
220
|
+
ERR__MSG_TIMED_OUT = -192,
|
|
221
|
+
/** Reached the end of the topic+partition queue on
|
|
222
|
+
* the broker. Not really an error.
|
|
223
|
+
* This event is disabled by default,
|
|
224
|
+
* see the `enable.partition.eof` configuration property. */
|
|
225
|
+
ERR__PARTITION_EOF = -191,
|
|
226
|
+
/** Permanent: Partition does not exist in cluster. */
|
|
227
|
+
ERR__UNKNOWN_PARTITION = -190,
|
|
228
|
+
/** File or filesystem error */
|
|
229
|
+
ERR__FS = -189,
|
|
230
|
+
/** Permanent: Topic does not exist in cluster. */
|
|
231
|
+
ERR__UNKNOWN_TOPIC = -188,
|
|
232
|
+
/** All broker connections are down. */
|
|
233
|
+
ERR__ALL_BROKERS_DOWN = -187,
|
|
234
|
+
/** Invalid argument, or invalid configuration */
|
|
235
|
+
ERR__INVALID_ARG = -186,
|
|
236
|
+
/** Operation timed out */
|
|
237
|
+
ERR__TIMED_OUT = -185,
|
|
238
|
+
/** Queue is full */
|
|
239
|
+
ERR__QUEUE_FULL = -184,
|
|
240
|
+
/** ISR count < required.acks */
|
|
241
|
+
ERR__ISR_INSUFF = -183,
|
|
242
|
+
/** Broker node update */
|
|
243
|
+
ERR__NODE_UPDATE = -182,
|
|
244
|
+
/** SSL error */
|
|
245
|
+
ERR__SSL = -181,
|
|
246
|
+
/** Waiting for coordinator to become available. */
|
|
247
|
+
ERR__WAIT_COORD = -180,
|
|
248
|
+
/** Unknown client group */
|
|
249
|
+
ERR__UNKNOWN_GROUP = -179,
|
|
250
|
+
/** Operation in progress */
|
|
251
|
+
ERR__IN_PROGRESS = -178,
|
|
252
|
+
/** Previous operation in progress, wait for it to finish. */
|
|
253
|
+
ERR__PREV_IN_PROGRESS = -177,
|
|
254
|
+
/** This operation would interfere with an existing subscription */
|
|
255
|
+
ERR__EXISTING_SUBSCRIPTION = -176,
|
|
256
|
+
/** Assigned partitions (rebalance_cb) */
|
|
257
|
+
ERR__ASSIGN_PARTITIONS = -175,
|
|
258
|
+
/** Revoked partitions (rebalance_cb) */
|
|
259
|
+
ERR__REVOKE_PARTITIONS = -174,
|
|
260
|
+
/** Conflicting use */
|
|
261
|
+
ERR__CONFLICT = -173,
|
|
262
|
+
/** Wrong state */
|
|
263
|
+
ERR__STATE = -172,
|
|
264
|
+
/** Unknown protocol */
|
|
265
|
+
ERR__UNKNOWN_PROTOCOL = -171,
|
|
266
|
+
/** Not implemented */
|
|
267
|
+
ERR__NOT_IMPLEMENTED = -170,
|
|
268
|
+
/** Authentication failure*/
|
|
269
|
+
ERR__AUTHENTICATION = -169,
|
|
270
|
+
/** No stored offset */
|
|
271
|
+
ERR__NO_OFFSET = -168,
|
|
272
|
+
/** Outdated */
|
|
273
|
+
ERR__OUTDATED = -167,
|
|
274
|
+
/** Timed out in queue */
|
|
275
|
+
ERR__TIMED_OUT_QUEUE = -166,
|
|
276
|
+
/** Feature not supported by broker */
|
|
277
|
+
ERR__UNSUPPORTED_FEATURE = -165,
|
|
278
|
+
/** Awaiting cache update */
|
|
279
|
+
ERR__WAIT_CACHE = -164,
|
|
280
|
+
/** Operation interrupted */
|
|
281
|
+
ERR__INTR = -163,
|
|
282
|
+
/** Key serialization error */
|
|
283
|
+
ERR__KEY_SERIALIZATION = -162,
|
|
284
|
+
/** Value serialization error */
|
|
285
|
+
ERR__VALUE_SERIALIZATION = -161,
|
|
286
|
+
/** Key deserialization error */
|
|
287
|
+
ERR__KEY_DESERIALIZATION = -160,
|
|
288
|
+
/** Value deserialization error */
|
|
289
|
+
ERR__VALUE_DESERIALIZATION = -159,
|
|
290
|
+
/** Partial response */
|
|
291
|
+
ERR__PARTIAL = -158,
|
|
292
|
+
/** Modification attempted on read-only object */
|
|
293
|
+
ERR__READ_ONLY = -157,
|
|
294
|
+
/** No such entry / item not found */
|
|
295
|
+
ERR__NOENT = -156,
|
|
296
|
+
/** Read underflow */
|
|
297
|
+
ERR__UNDERFLOW = -155,
|
|
298
|
+
/** Invalid type */
|
|
299
|
+
ERR__INVALID_TYPE = -154,
|
|
300
|
+
/** Retry operation */
|
|
301
|
+
ERR__RETRY = -153,
|
|
302
|
+
/** Purged in queue */
|
|
303
|
+
ERR__PURGE_QUEUE = -152,
|
|
304
|
+
/** Purged in flight */
|
|
305
|
+
ERR__PURGE_INFLIGHT = -151,
|
|
306
|
+
/** Fatal error: see RdKafka::Handle::fatal_error() */
|
|
307
|
+
ERR__FATAL = -150,
|
|
308
|
+
/** Inconsistent state */
|
|
309
|
+
ERR__INCONSISTENT = -149,
|
|
310
|
+
/** Gap-less ordering would not be guaranteed if proceeding */
|
|
311
|
+
ERR__GAPLESS_GUARANTEE = -148,
|
|
312
|
+
/** Maximum poll interval exceeded */
|
|
313
|
+
ERR__MAX_POLL_EXCEEDED = -147,
|
|
314
|
+
/** Unknown broker */
|
|
315
|
+
ERR__UNKNOWN_BROKER = -146,
|
|
316
|
+
/** Functionality not configured */
|
|
317
|
+
ERR__NOT_CONFIGURED = -145,
|
|
318
|
+
/** Instance has been fenced */
|
|
319
|
+
ERR__FENCED = -144,
|
|
320
|
+
/** Application generated error */
|
|
321
|
+
ERR__APPLICATION = -143,
|
|
322
|
+
/** Assignment lost */
|
|
323
|
+
ERR__ASSIGNMENT_LOST = -142,
|
|
324
|
+
/** No operation performed */
|
|
325
|
+
ERR__NOOP = -141,
|
|
326
|
+
/** No offset to automatically reset to */
|
|
327
|
+
ERR__AUTO_OFFSET_RESET = -140,
|
|
328
|
+
/** Partition log truncation detected */
|
|
329
|
+
ERR__LOG_TRUNCATION = -139,
|
|
330
|
+
/** A different record in the batch was invalid
|
|
331
|
+
* and this message failed persisting. */
|
|
332
|
+
ERR__INVALID_DIFFERENT_RECORD = -138,
|
|
333
|
+
/** Broker is going away but client isn't terminating */
|
|
334
|
+
ERR__DESTROY_BROKER = -137,
|
|
335
|
+
|
|
336
|
+
/** End internal error codes */
|
|
337
|
+
ERR__END = -100,
|
|
338
|
+
|
|
339
|
+
/* Kafka broker errors: */
|
|
340
|
+
/** Unknown broker error */
|
|
341
|
+
ERR_UNKNOWN = -1,
|
|
342
|
+
/** Success */
|
|
343
|
+
ERR_NO_ERROR = 0,
|
|
344
|
+
/** Offset out of range */
|
|
345
|
+
ERR_OFFSET_OUT_OF_RANGE = 1,
|
|
346
|
+
/** Invalid message */
|
|
347
|
+
ERR_INVALID_MSG = 2,
|
|
348
|
+
/** Unknown topic or partition */
|
|
349
|
+
ERR_UNKNOWN_TOPIC_OR_PART = 3,
|
|
350
|
+
/** Invalid message size */
|
|
351
|
+
ERR_INVALID_MSG_SIZE = 4,
|
|
352
|
+
/** Leader not available */
|
|
353
|
+
ERR_LEADER_NOT_AVAILABLE = 5,
|
|
354
|
+
/** Not leader for partition */
|
|
355
|
+
ERR_NOT_LEADER_FOR_PARTITION = 6,
|
|
356
|
+
/** Request timed out */
|
|
357
|
+
ERR_REQUEST_TIMED_OUT = 7,
|
|
358
|
+
/** Broker not available */
|
|
359
|
+
ERR_BROKER_NOT_AVAILABLE = 8,
|
|
360
|
+
/** Replica not available */
|
|
361
|
+
ERR_REPLICA_NOT_AVAILABLE = 9,
|
|
362
|
+
/** Message size too large */
|
|
363
|
+
ERR_MSG_SIZE_TOO_LARGE = 10,
|
|
364
|
+
/** StaleControllerEpochCode */
|
|
365
|
+
ERR_STALE_CTRL_EPOCH = 11,
|
|
366
|
+
/** Offset metadata string too large */
|
|
367
|
+
ERR_OFFSET_METADATA_TOO_LARGE = 12,
|
|
368
|
+
/** Broker disconnected before response received */
|
|
369
|
+
ERR_NETWORK_EXCEPTION = 13,
|
|
370
|
+
/** Coordinator load in progress */
|
|
371
|
+
ERR_COORDINATOR_LOAD_IN_PROGRESS = 14,
|
|
372
|
+
/** Group coordinator load in progress */
|
|
373
|
+
#define ERR_GROUP_LOAD_IN_PROGRESS ERR_COORDINATOR_LOAD_IN_PROGRESS
|
|
374
|
+
/** Coordinator not available */
|
|
375
|
+
ERR_COORDINATOR_NOT_AVAILABLE = 15,
|
|
376
|
+
/** Group coordinator not available */
|
|
377
|
+
#define ERR_GROUP_COORDINATOR_NOT_AVAILABLE ERR_COORDINATOR_NOT_AVAILABLE
|
|
378
|
+
/** Not coordinator */
|
|
379
|
+
ERR_NOT_COORDINATOR = 16,
|
|
380
|
+
/** Not coordinator for group */
|
|
381
|
+
#define ERR_NOT_COORDINATOR_FOR_GROUP ERR_NOT_COORDINATOR
|
|
382
|
+
/** Invalid topic */
|
|
383
|
+
ERR_TOPIC_EXCEPTION = 17,
|
|
384
|
+
/** Message batch larger than configured server segment size */
|
|
385
|
+
ERR_RECORD_LIST_TOO_LARGE = 18,
|
|
386
|
+
/** Not enough in-sync replicas */
|
|
387
|
+
ERR_NOT_ENOUGH_REPLICAS = 19,
|
|
388
|
+
/** Message(s) written to insufficient number of in-sync replicas */
|
|
389
|
+
ERR_NOT_ENOUGH_REPLICAS_AFTER_APPEND = 20,
|
|
390
|
+
/** Invalid required acks value */
|
|
391
|
+
ERR_INVALID_REQUIRED_ACKS = 21,
|
|
392
|
+
/** Specified group generation id is not valid */
|
|
393
|
+
ERR_ILLEGAL_GENERATION = 22,
|
|
394
|
+
/** Inconsistent group protocol */
|
|
395
|
+
ERR_INCONSISTENT_GROUP_PROTOCOL = 23,
|
|
396
|
+
/** Invalid group.id */
|
|
397
|
+
ERR_INVALID_GROUP_ID = 24,
|
|
398
|
+
/** Unknown member */
|
|
399
|
+
ERR_UNKNOWN_MEMBER_ID = 25,
|
|
400
|
+
/** Invalid session timeout */
|
|
401
|
+
ERR_INVALID_SESSION_TIMEOUT = 26,
|
|
402
|
+
/** Group rebalance in progress */
|
|
403
|
+
ERR_REBALANCE_IN_PROGRESS = 27,
|
|
404
|
+
/** Commit offset data size is not valid */
|
|
405
|
+
ERR_INVALID_COMMIT_OFFSET_SIZE = 28,
|
|
406
|
+
/** Topic authorization failed */
|
|
407
|
+
ERR_TOPIC_AUTHORIZATION_FAILED = 29,
|
|
408
|
+
/** Group authorization failed */
|
|
409
|
+
ERR_GROUP_AUTHORIZATION_FAILED = 30,
|
|
410
|
+
/** Cluster authorization failed */
|
|
411
|
+
ERR_CLUSTER_AUTHORIZATION_FAILED = 31,
|
|
412
|
+
/** Invalid timestamp */
|
|
413
|
+
ERR_INVALID_TIMESTAMP = 32,
|
|
414
|
+
/** Unsupported SASL mechanism */
|
|
415
|
+
ERR_UNSUPPORTED_SASL_MECHANISM = 33,
|
|
416
|
+
/** Illegal SASL state */
|
|
417
|
+
ERR_ILLEGAL_SASL_STATE = 34,
|
|
418
|
+
/** Unuspported version */
|
|
419
|
+
ERR_UNSUPPORTED_VERSION = 35,
|
|
420
|
+
/** Topic already exists */
|
|
421
|
+
ERR_TOPIC_ALREADY_EXISTS = 36,
|
|
422
|
+
/** Invalid number of partitions */
|
|
423
|
+
ERR_INVALID_PARTITIONS = 37,
|
|
424
|
+
/** Invalid replication factor */
|
|
425
|
+
ERR_INVALID_REPLICATION_FACTOR = 38,
|
|
426
|
+
/** Invalid replica assignment */
|
|
427
|
+
ERR_INVALID_REPLICA_ASSIGNMENT = 39,
|
|
428
|
+
/** Invalid config */
|
|
429
|
+
ERR_INVALID_CONFIG = 40,
|
|
430
|
+
/** Not controller for cluster */
|
|
431
|
+
ERR_NOT_CONTROLLER = 41,
|
|
432
|
+
/** Invalid request */
|
|
433
|
+
ERR_INVALID_REQUEST = 42,
|
|
434
|
+
/** Message format on broker does not support request */
|
|
435
|
+
ERR_UNSUPPORTED_FOR_MESSAGE_FORMAT = 43,
|
|
436
|
+
/** Policy violation */
|
|
437
|
+
ERR_POLICY_VIOLATION = 44,
|
|
438
|
+
/** Broker received an out of order sequence number */
|
|
439
|
+
ERR_OUT_OF_ORDER_SEQUENCE_NUMBER = 45,
|
|
440
|
+
/** Broker received a duplicate sequence number */
|
|
441
|
+
ERR_DUPLICATE_SEQUENCE_NUMBER = 46,
|
|
442
|
+
/** Producer attempted an operation with an old epoch */
|
|
443
|
+
ERR_INVALID_PRODUCER_EPOCH = 47,
|
|
444
|
+
/** Producer attempted a transactional operation in an invalid state */
|
|
445
|
+
ERR_INVALID_TXN_STATE = 48,
|
|
446
|
+
/** Producer attempted to use a producer id which is not
|
|
447
|
+
* currently assigned to its transactional id */
|
|
448
|
+
ERR_INVALID_PRODUCER_ID_MAPPING = 49,
|
|
449
|
+
/** Transaction timeout is larger than the maximum
|
|
450
|
+
* value allowed by the broker's max.transaction.timeout.ms */
|
|
451
|
+
ERR_INVALID_TRANSACTION_TIMEOUT = 50,
|
|
452
|
+
/** Producer attempted to update a transaction while another
|
|
453
|
+
* concurrent operation on the same transaction was ongoing */
|
|
454
|
+
ERR_CONCURRENT_TRANSACTIONS = 51,
|
|
455
|
+
/** Indicates that the transaction coordinator sending a
|
|
456
|
+
* WriteTxnMarker is no longer the current coordinator for a
|
|
457
|
+
* given producer */
|
|
458
|
+
ERR_TRANSACTION_COORDINATOR_FENCED = 52,
|
|
459
|
+
/** Transactional Id authorization failed */
|
|
460
|
+
ERR_TRANSACTIONAL_ID_AUTHORIZATION_FAILED = 53,
|
|
461
|
+
/** Security features are disabled */
|
|
462
|
+
ERR_SECURITY_DISABLED = 54,
|
|
463
|
+
/** Operation not attempted */
|
|
464
|
+
ERR_OPERATION_NOT_ATTEMPTED = 55,
|
|
465
|
+
/** Disk error when trying to access log file on the disk */
|
|
466
|
+
ERR_KAFKA_STORAGE_ERROR = 56,
|
|
467
|
+
/** The user-specified log directory is not found in the broker config */
|
|
468
|
+
ERR_LOG_DIR_NOT_FOUND = 57,
|
|
469
|
+
/** SASL Authentication failed */
|
|
470
|
+
ERR_SASL_AUTHENTICATION_FAILED = 58,
|
|
471
|
+
/** Unknown Producer Id */
|
|
472
|
+
ERR_UNKNOWN_PRODUCER_ID = 59,
|
|
473
|
+
/** Partition reassignment is in progress */
|
|
474
|
+
ERR_REASSIGNMENT_IN_PROGRESS = 60,
|
|
475
|
+
/** Delegation Token feature is not enabled */
|
|
476
|
+
ERR_DELEGATION_TOKEN_AUTH_DISABLED = 61,
|
|
477
|
+
/** Delegation Token is not found on server */
|
|
478
|
+
ERR_DELEGATION_TOKEN_NOT_FOUND = 62,
|
|
479
|
+
/** Specified Principal is not valid Owner/Renewer */
|
|
480
|
+
ERR_DELEGATION_TOKEN_OWNER_MISMATCH = 63,
|
|
481
|
+
/** Delegation Token requests are not allowed on this connection */
|
|
482
|
+
ERR_DELEGATION_TOKEN_REQUEST_NOT_ALLOWED = 64,
|
|
483
|
+
/** Delegation Token authorization failed */
|
|
484
|
+
ERR_DELEGATION_TOKEN_AUTHORIZATION_FAILED = 65,
|
|
485
|
+
/** Delegation Token is expired */
|
|
486
|
+
ERR_DELEGATION_TOKEN_EXPIRED = 66,
|
|
487
|
+
/** Supplied principalType is not supported */
|
|
488
|
+
ERR_INVALID_PRINCIPAL_TYPE = 67,
|
|
489
|
+
/** The group is not empty */
|
|
490
|
+
ERR_NON_EMPTY_GROUP = 68,
|
|
491
|
+
/** The group id does not exist */
|
|
492
|
+
ERR_GROUP_ID_NOT_FOUND = 69,
|
|
493
|
+
/** The fetch session ID was not found */
|
|
494
|
+
ERR_FETCH_SESSION_ID_NOT_FOUND = 70,
|
|
495
|
+
/** The fetch session epoch is invalid */
|
|
496
|
+
ERR_INVALID_FETCH_SESSION_EPOCH = 71,
|
|
497
|
+
/** No matching listener */
|
|
498
|
+
ERR_LISTENER_NOT_FOUND = 72,
|
|
499
|
+
/** Topic deletion is disabled */
|
|
500
|
+
ERR_TOPIC_DELETION_DISABLED = 73,
|
|
501
|
+
/** Leader epoch is older than broker epoch */
|
|
502
|
+
ERR_FENCED_LEADER_EPOCH = 74,
|
|
503
|
+
/** Leader epoch is newer than broker epoch */
|
|
504
|
+
ERR_UNKNOWN_LEADER_EPOCH = 75,
|
|
505
|
+
/** Unsupported compression type */
|
|
506
|
+
ERR_UNSUPPORTED_COMPRESSION_TYPE = 76,
|
|
507
|
+
/** Broker epoch has changed */
|
|
508
|
+
ERR_STALE_BROKER_EPOCH = 77,
|
|
509
|
+
/** Leader high watermark is not caught up */
|
|
510
|
+
ERR_OFFSET_NOT_AVAILABLE = 78,
|
|
511
|
+
/** Group member needs a valid member ID */
|
|
512
|
+
ERR_MEMBER_ID_REQUIRED = 79,
|
|
513
|
+
/** Preferred leader was not available */
|
|
514
|
+
ERR_PREFERRED_LEADER_NOT_AVAILABLE = 80,
|
|
515
|
+
/** Consumer group has reached maximum size */
|
|
516
|
+
ERR_GROUP_MAX_SIZE_REACHED = 81,
|
|
517
|
+
/** Static consumer fenced by other consumer with same
|
|
518
|
+
* group.instance.id. */
|
|
519
|
+
ERR_FENCED_INSTANCE_ID = 82,
|
|
520
|
+
/** Eligible partition leaders are not available */
|
|
521
|
+
ERR_ELIGIBLE_LEADERS_NOT_AVAILABLE = 83,
|
|
522
|
+
/** Leader election not needed for topic partition */
|
|
523
|
+
ERR_ELECTION_NOT_NEEDED = 84,
|
|
524
|
+
/** No partition reassignment is in progress */
|
|
525
|
+
ERR_NO_REASSIGNMENT_IN_PROGRESS = 85,
|
|
526
|
+
/** Deleting offsets of a topic while the consumer group is
|
|
527
|
+
* subscribed to it */
|
|
528
|
+
ERR_GROUP_SUBSCRIBED_TO_TOPIC = 86,
|
|
529
|
+
/** Broker failed to validate record */
|
|
530
|
+
ERR_INVALID_RECORD = 87,
|
|
531
|
+
/** There are unstable offsets that need to be cleared */
|
|
532
|
+
ERR_UNSTABLE_OFFSET_COMMIT = 88,
|
|
533
|
+
/** Throttling quota has been exceeded */
|
|
534
|
+
ERR_THROTTLING_QUOTA_EXCEEDED = 89,
|
|
535
|
+
/** There is a newer producer with the same transactionalId
|
|
536
|
+
* which fences the current one */
|
|
537
|
+
ERR_PRODUCER_FENCED = 90,
|
|
538
|
+
/** Request illegally referred to resource that does not exist */
|
|
539
|
+
ERR_RESOURCE_NOT_FOUND = 91,
|
|
540
|
+
/** Request illegally referred to the same resource twice */
|
|
541
|
+
ERR_DUPLICATE_RESOURCE = 92,
|
|
542
|
+
/** Requested credential would not meet criteria for acceptability */
|
|
543
|
+
ERR_UNACCEPTABLE_CREDENTIAL = 93,
|
|
544
|
+
/** Indicates that the either the sender or recipient of a
|
|
545
|
+
* voter-only request is not one of the expected voters */
|
|
546
|
+
ERR_INCONSISTENT_VOTER_SET = 94,
|
|
547
|
+
/** Invalid update version */
|
|
548
|
+
ERR_INVALID_UPDATE_VERSION = 95,
|
|
549
|
+
/** Unable to update finalized features due to server error */
|
|
550
|
+
ERR_FEATURE_UPDATE_FAILED = 96,
|
|
551
|
+
/** Request principal deserialization failed during forwarding */
|
|
552
|
+
ERR_PRINCIPAL_DESERIALIZATION_FAILURE = 97,
|
|
553
|
+
/** Unknown Topic Id */
|
|
554
|
+
ERR_UNKNOWN_TOPIC_ID = 100,
|
|
555
|
+
/** The member epoch is fenced by the group coordinator */
|
|
556
|
+
ERR_FENCED_MEMBER_EPOCH = 110,
|
|
557
|
+
/** The instance ID is still used by another member in the
|
|
558
|
+
* consumer group */
|
|
559
|
+
ERR_UNRELEASED_INSTANCE_ID = 111,
|
|
560
|
+
/** The assignor or its version range is not supported by the consumer
|
|
561
|
+
* group */
|
|
562
|
+
ERR_UNSUPPORTED_ASSIGNOR = 112,
|
|
563
|
+
/** The member epoch is stale */
|
|
564
|
+
ERR_STALE_MEMBER_EPOCH = 113,
|
|
565
|
+
/** Client sent a push telemetry request with an invalid or outdated
|
|
566
|
+
* subscription ID. */
|
|
567
|
+
ERR_UNKNOWN_SUBSCRIPTION_ID = 117,
|
|
568
|
+
/** Client sent a push telemetry request larger than the maximum size
|
|
569
|
+
* the broker will accept. */
|
|
570
|
+
ERR_TELEMETRY_TOO_LARGE = 118,
|
|
571
|
+
/** Client metadata is stale,
|
|
572
|
+
* client should rebootstrap to obtain new metadata. */
|
|
573
|
+
ERR_REBOOTSTRAP_REQUIRED = 129
|
|
574
|
+
};
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* @brief Returns a human readable representation of a kafka error.
|
|
579
|
+
*/
|
|
580
|
+
RD_EXPORT
|
|
581
|
+
std::string err2str(RdKafka::ErrorCode err);
|
|
582
|
+
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* @enum CertificateType
|
|
587
|
+
* @brief SSL certificate types
|
|
588
|
+
*/
|
|
589
|
+
enum CertificateType {
|
|
590
|
+
CERT_PUBLIC_KEY, /**< Client's public key */
|
|
591
|
+
CERT_PRIVATE_KEY, /**< Client's private key */
|
|
592
|
+
CERT_CA, /**< CA certificate */
|
|
593
|
+
CERT__CNT
|
|
594
|
+
};
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* @enum CertificateEncoding
|
|
598
|
+
* @brief SSL certificate encoding
|
|
599
|
+
*/
|
|
600
|
+
enum CertificateEncoding {
|
|
601
|
+
CERT_ENC_PKCS12, /**< PKCS#12 */
|
|
602
|
+
CERT_ENC_DER, /**< DER / binary X.509 ASN1 */
|
|
603
|
+
CERT_ENC_PEM, /**< PEM */
|
|
604
|
+
CERT_ENC__CNT
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
/**@} */
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
|
|
611
|
+
/**@cond NO_DOC*/
|
|
612
|
+
/* Forward declarations */
|
|
613
|
+
class Handle;
|
|
614
|
+
class Producer;
|
|
615
|
+
class Message;
|
|
616
|
+
class Headers;
|
|
617
|
+
class Queue;
|
|
618
|
+
class Event;
|
|
619
|
+
class Topic;
|
|
620
|
+
class TopicPartition;
|
|
621
|
+
class Metadata;
|
|
622
|
+
class KafkaConsumer;
|
|
623
|
+
/**@endcond*/
|
|
624
|
+
|
|
625
|
+
|
|
626
|
+
/**
|
|
627
|
+
* @name Error class
|
|
628
|
+
* @{
|
|
629
|
+
*
|
|
630
|
+
*/
|
|
631
|
+
|
|
632
|
+
/**
|
|
633
|
+
* @brief The Error class is used as a return value from APIs to propagate
|
|
634
|
+
* an error. The error consists of an error code which is to be used
|
|
635
|
+
* programatically, an error string for showing to the user,
|
|
636
|
+
* and various error flags that can be used programmatically to decide
|
|
637
|
+
* how to handle the error; e.g., should the operation be retried,
|
|
638
|
+
* was it a fatal error, etc.
|
|
639
|
+
*
|
|
640
|
+
* Error objects must be deleted explicitly to free its resources.
|
|
641
|
+
*/
|
|
642
|
+
class RD_EXPORT Error {
|
|
643
|
+
public:
|
|
644
|
+
/**
|
|
645
|
+
* @brief Create error object.
|
|
646
|
+
*/
|
|
647
|
+
static Error *create(ErrorCode code, const std::string *errstr);
|
|
648
|
+
|
|
649
|
+
virtual ~Error() {
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
/*
|
|
653
|
+
* Error accessor methods
|
|
654
|
+
*/
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* @returns the error code, e.g., RdKafka::ERR_UNKNOWN_MEMBER_ID.
|
|
658
|
+
*/
|
|
659
|
+
virtual ErrorCode code() const = 0;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* @returns the error code name, e.g, "ERR_UNKNOWN_MEMBER_ID".
|
|
663
|
+
*/
|
|
664
|
+
virtual std::string name() const = 0;
|
|
665
|
+
|
|
666
|
+
/**
|
|
667
|
+
* @returns a human readable error string.
|
|
668
|
+
*/
|
|
669
|
+
virtual std::string str() const = 0;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* @returns true if the error is a fatal error, indicating that the client
|
|
673
|
+
* instance is no longer usable, else false.
|
|
674
|
+
*/
|
|
675
|
+
virtual bool is_fatal() const = 0;
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* @returns true if the operation may be retried, else false.
|
|
679
|
+
*/
|
|
680
|
+
virtual bool is_retriable() const = 0;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* @returns true if the error is an abortable transaction error in which case
|
|
684
|
+
* the application must call RdKafka::Producer::abort_transaction()
|
|
685
|
+
* and start a new transaction with
|
|
686
|
+
* RdKafka::Producer::begin_transaction() if it wishes to proceed
|
|
687
|
+
* with transactions.
|
|
688
|
+
* Else returns false.
|
|
689
|
+
*
|
|
690
|
+
* @remark The return value of this method is only valid for errors returned
|
|
691
|
+
* by the transactional API.
|
|
692
|
+
*/
|
|
693
|
+
virtual bool txn_requires_abort() const = 0;
|
|
694
|
+
};
|
|
695
|
+
|
|
696
|
+
/**@}*/
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
/**
|
|
700
|
+
* @name Callback classes
|
|
701
|
+
* @{
|
|
702
|
+
*
|
|
703
|
+
*
|
|
704
|
+
* librdkafka uses (optional) callbacks to propagate information and
|
|
705
|
+
* delegate decisions to the application logic.
|
|
706
|
+
*
|
|
707
|
+
* An application must call RdKafka::poll() at regular intervals to
|
|
708
|
+
* serve queued callbacks.
|
|
709
|
+
*/
|
|
710
|
+
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* @brief Delivery Report callback class
|
|
714
|
+
*
|
|
715
|
+
* The delivery report callback will be called once for each message
|
|
716
|
+
* accepted by RdKafka::Producer::produce() (et.al) with
|
|
717
|
+
* RdKafka::Message::err() set to indicate the result of the produce request.
|
|
718
|
+
*
|
|
719
|
+
* The callback is called when a message is succesfully produced or
|
|
720
|
+
* if librdkafka encountered a permanent failure, or the retry counter for
|
|
721
|
+
* temporary errors has been exhausted.
|
|
722
|
+
*
|
|
723
|
+
* An application must call RdKafka::poll() at regular intervals to
|
|
724
|
+
* serve queued delivery report callbacks.
|
|
725
|
+
|
|
726
|
+
*/
|
|
727
|
+
class RD_EXPORT DeliveryReportCb {
|
|
728
|
+
public:
|
|
729
|
+
/**
|
|
730
|
+
* @brief Delivery report callback.
|
|
731
|
+
*/
|
|
732
|
+
virtual void dr_cb(Message &message) = 0;
|
|
733
|
+
|
|
734
|
+
virtual ~DeliveryReportCb() {
|
|
735
|
+
}
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
|
|
739
|
+
/**
|
|
740
|
+
* @brief SASL/OAUTHBEARER token refresh callback class
|
|
741
|
+
*
|
|
742
|
+
* The SASL/OAUTHBEARER token refresh callback is triggered via RdKafka::poll()
|
|
743
|
+
* whenever OAUTHBEARER is the SASL mechanism and a token needs to be retrieved,
|
|
744
|
+
* typically based on the configuration defined in \c sasl.oauthbearer.config.
|
|
745
|
+
*
|
|
746
|
+
* The \c oauthbearer_config argument is the value of the
|
|
747
|
+
* \c sasl.oauthbearer.config configuration property.
|
|
748
|
+
*
|
|
749
|
+
* The callback should invoke RdKafka::Handle::oauthbearer_set_token() or
|
|
750
|
+
* RdKafka::Handle::oauthbearer_set_token_failure() to indicate success or
|
|
751
|
+
* failure, respectively.
|
|
752
|
+
*
|
|
753
|
+
* The refresh operation is eventable and may be received when an event
|
|
754
|
+
* callback handler is set with an event type of
|
|
755
|
+
* \c RdKafka::Event::EVENT_OAUTHBEARER_TOKEN_REFRESH.
|
|
756
|
+
*
|
|
757
|
+
* Note that before any SASL/OAUTHBEARER broker connection can succeed the
|
|
758
|
+
* application must call RdKafka::Handle::oauthbearer_set_token() once -- either
|
|
759
|
+
* directly or, more typically, by invoking RdKafka::poll() -- in order to
|
|
760
|
+
* cause retrieval of an initial token to occur.
|
|
761
|
+
*
|
|
762
|
+
* An application must call RdKafka::poll() at regular intervals to
|
|
763
|
+
* serve queued SASL/OAUTHBEARER token refresh callbacks (when
|
|
764
|
+
* OAUTHBEARER is the SASL mechanism).
|
|
765
|
+
*/
|
|
766
|
+
class RD_EXPORT OAuthBearerTokenRefreshCb {
|
|
767
|
+
public:
|
|
768
|
+
/**
|
|
769
|
+
* @brief SASL/OAUTHBEARER token refresh callback class.
|
|
770
|
+
*
|
|
771
|
+
* @param handle The RdKafka::Handle which requires a refreshed token.
|
|
772
|
+
* @param oauthbearer_config The value of the
|
|
773
|
+
* \p sasl.oauthbearer.config configuration property for \p handle.
|
|
774
|
+
*/
|
|
775
|
+
virtual void oauthbearer_token_refresh_cb(
|
|
776
|
+
RdKafka::Handle *handle,
|
|
777
|
+
const std::string &oauthbearer_config) = 0;
|
|
778
|
+
|
|
779
|
+
virtual ~OAuthBearerTokenRefreshCb() {
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
/**
|
|
785
|
+
* @brief Partitioner callback class
|
|
786
|
+
*
|
|
787
|
+
* Generic partitioner callback class for implementing custom partitioners.
|
|
788
|
+
*
|
|
789
|
+
* @sa RdKafka::Conf::set() \c "partitioner_cb"
|
|
790
|
+
*/
|
|
791
|
+
class RD_EXPORT PartitionerCb {
|
|
792
|
+
public:
|
|
793
|
+
/**
|
|
794
|
+
* @brief Partitioner callback
|
|
795
|
+
*
|
|
796
|
+
* Return the partition to use for \p key in \p topic.
|
|
797
|
+
*
|
|
798
|
+
* The \p msg_opaque is the same \p msg_opaque provided in the
|
|
799
|
+
* RdKafka::Producer::produce() call.
|
|
800
|
+
*
|
|
801
|
+
* @remark \p key may be NULL or the empty.
|
|
802
|
+
*
|
|
803
|
+
* @returns Must return a value between 0 and \p partition_cnt
|
|
804
|
+
* (non-inclusive). May return RD_KAFKA_PARTITION_UA (-1) if partitioning
|
|
805
|
+
* failed.
|
|
806
|
+
*
|
|
807
|
+
* @sa The callback may use RdKafka::Topic::partition_available() to check
|
|
808
|
+
* if a partition has an active leader broker.
|
|
809
|
+
*/
|
|
810
|
+
virtual int32_t partitioner_cb(const Topic *topic,
|
|
811
|
+
const std::string *key,
|
|
812
|
+
int32_t partition_cnt,
|
|
813
|
+
void *msg_opaque) = 0;
|
|
814
|
+
|
|
815
|
+
virtual ~PartitionerCb() {
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* @brief Variant partitioner with key pointer
|
|
821
|
+
*
|
|
822
|
+
*/
|
|
823
|
+
class PartitionerKeyPointerCb {
|
|
824
|
+
public:
|
|
825
|
+
/**
|
|
826
|
+
* @brief Variant partitioner callback that gets \p key as pointer and length
|
|
827
|
+
* instead of as a const std::string *.
|
|
828
|
+
*
|
|
829
|
+
* @remark \p key may be NULL or have \p key_len 0.
|
|
830
|
+
*
|
|
831
|
+
* @sa See RdKafka::PartitionerCb::partitioner_cb() for exact semantics
|
|
832
|
+
*/
|
|
833
|
+
virtual int32_t partitioner_cb(const Topic *topic,
|
|
834
|
+
const void *key,
|
|
835
|
+
size_t key_len,
|
|
836
|
+
int32_t partition_cnt,
|
|
837
|
+
void *msg_opaque) = 0;
|
|
838
|
+
|
|
839
|
+
virtual ~PartitionerKeyPointerCb() {
|
|
840
|
+
}
|
|
841
|
+
};
|
|
842
|
+
|
|
843
|
+
|
|
844
|
+
|
|
845
|
+
/**
|
|
846
|
+
* @brief Event callback class
|
|
847
|
+
*
|
|
848
|
+
* Events are a generic interface for propagating errors, statistics, logs, etc
|
|
849
|
+
* from librdkafka to the application.
|
|
850
|
+
*
|
|
851
|
+
* @sa RdKafka::Event
|
|
852
|
+
*/
|
|
853
|
+
class RD_EXPORT EventCb {
|
|
854
|
+
public:
|
|
855
|
+
/**
|
|
856
|
+
* @brief Event callback
|
|
857
|
+
*
|
|
858
|
+
* @sa RdKafka::Event
|
|
859
|
+
*/
|
|
860
|
+
virtual void event_cb(Event &event) = 0;
|
|
861
|
+
|
|
862
|
+
virtual ~EventCb() {
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
/**
|
|
868
|
+
* @brief Event object class as passed to the EventCb callback.
|
|
869
|
+
*/
|
|
870
|
+
class RD_EXPORT Event {
|
|
871
|
+
public:
|
|
872
|
+
/** @brief Event type */
|
|
873
|
+
enum Type {
|
|
874
|
+
EVENT_ERROR, /**< Event is an error condition */
|
|
875
|
+
EVENT_STATS, /**< Event is a statistics JSON document */
|
|
876
|
+
EVENT_LOG, /**< Event is a log message */
|
|
877
|
+
EVENT_THROTTLE /**< Event is a throttle level signaling from the broker */
|
|
878
|
+
};
|
|
879
|
+
|
|
880
|
+
/** @brief EVENT_LOG severities (conforms to syslog(3) severities) */
|
|
881
|
+
enum Severity {
|
|
882
|
+
EVENT_SEVERITY_EMERG = 0,
|
|
883
|
+
EVENT_SEVERITY_ALERT = 1,
|
|
884
|
+
EVENT_SEVERITY_CRITICAL = 2,
|
|
885
|
+
EVENT_SEVERITY_ERROR = 3,
|
|
886
|
+
EVENT_SEVERITY_WARNING = 4,
|
|
887
|
+
EVENT_SEVERITY_NOTICE = 5,
|
|
888
|
+
EVENT_SEVERITY_INFO = 6,
|
|
889
|
+
EVENT_SEVERITY_DEBUG = 7
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
virtual ~Event() {
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/*
|
|
896
|
+
* Event Accessor methods
|
|
897
|
+
*/
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* @returns The event type
|
|
901
|
+
* @remark Applies to all event types
|
|
902
|
+
*/
|
|
903
|
+
virtual Type type() const = 0;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* @returns Event error, if any.
|
|
907
|
+
* @remark Applies to all event types except THROTTLE
|
|
908
|
+
*/
|
|
909
|
+
virtual ErrorCode err() const = 0;
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* @returns Log severity level.
|
|
913
|
+
* @remark Applies to LOG event type.
|
|
914
|
+
*/
|
|
915
|
+
virtual Severity severity() const = 0;
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* @returns Log facility string.
|
|
919
|
+
* @remark Applies to LOG event type.
|
|
920
|
+
*/
|
|
921
|
+
virtual std::string fac() const = 0;
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* @returns Log message string.
|
|
925
|
+
*
|
|
926
|
+
* \c EVENT_LOG: Log message string.
|
|
927
|
+
* \c EVENT_STATS: JSON object (as string).
|
|
928
|
+
*
|
|
929
|
+
* @remark Applies to LOG event type.
|
|
930
|
+
*/
|
|
931
|
+
virtual std::string str() const = 0;
|
|
932
|
+
|
|
933
|
+
/**
|
|
934
|
+
* @returns Throttle time in milliseconds.
|
|
935
|
+
* @remark Applies to THROTTLE event type.
|
|
936
|
+
*/
|
|
937
|
+
virtual int throttle_time() const = 0;
|
|
938
|
+
|
|
939
|
+
/**
|
|
940
|
+
* @returns Throttling broker's name.
|
|
941
|
+
* @remark Applies to THROTTLE event type.
|
|
942
|
+
*/
|
|
943
|
+
virtual std::string broker_name() const = 0;
|
|
944
|
+
|
|
945
|
+
/**
|
|
946
|
+
* @returns Throttling broker's id.
|
|
947
|
+
* @remark Applies to THROTTLE event type.
|
|
948
|
+
*/
|
|
949
|
+
virtual int broker_id() const = 0;
|
|
950
|
+
|
|
951
|
+
|
|
952
|
+
/**
|
|
953
|
+
* @returns true if this is a fatal error.
|
|
954
|
+
* @remark Applies to ERROR event type.
|
|
955
|
+
* @sa RdKafka::Handle::fatal_error()
|
|
956
|
+
*/
|
|
957
|
+
virtual bool fatal() const = 0;
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
/**
|
|
963
|
+
* @brief Consume callback class
|
|
964
|
+
*/
|
|
965
|
+
class RD_EXPORT ConsumeCb {
|
|
966
|
+
public:
|
|
967
|
+
/**
|
|
968
|
+
* @brief The consume callback is used with
|
|
969
|
+
* RdKafka::Consumer::consume_callback()
|
|
970
|
+
* methods and will be called for each consumed \p message.
|
|
971
|
+
*
|
|
972
|
+
* The callback interface is optional but provides increased performance.
|
|
973
|
+
*/
|
|
974
|
+
virtual void consume_cb(Message &message, void *opaque) = 0;
|
|
975
|
+
|
|
976
|
+
virtual ~ConsumeCb() {
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
|
|
980
|
+
|
|
981
|
+
/**
|
|
982
|
+
* @brief \b KafkaConsumer: Rebalance callback class
|
|
983
|
+
*/
|
|
984
|
+
class RD_EXPORT RebalanceCb {
|
|
985
|
+
public:
|
|
986
|
+
/**
|
|
987
|
+
* @brief Group rebalance callback for use with RdKafka::KafkaConsumer
|
|
988
|
+
*
|
|
989
|
+
* Registering a \p rebalance_cb turns off librdkafka's automatic
|
|
990
|
+
* partition assignment/revocation and instead delegates that responsibility
|
|
991
|
+
* to the application's \p rebalance_cb.
|
|
992
|
+
*
|
|
993
|
+
* The rebalance callback is responsible for updating librdkafka's
|
|
994
|
+
* assignment set based on the two events: RdKafka::ERR__ASSIGN_PARTITIONS
|
|
995
|
+
* and RdKafka::ERR__REVOKE_PARTITIONS but should also be able to handle
|
|
996
|
+
* arbitrary rebalancing failures where \p err is neither of those.
|
|
997
|
+
* @remark In this latter case (arbitrary error), the application must
|
|
998
|
+
* call unassign() to synchronize state.
|
|
999
|
+
*
|
|
1000
|
+
* For eager/non-cooperative `partition.assignment.strategy` assignors,
|
|
1001
|
+
* such as `range` and `roundrobin`, the application must use
|
|
1002
|
+
* assign assign() to set and unassign() to clear the entire assignment.
|
|
1003
|
+
* For the cooperative assignors, such as `cooperative-sticky`, the
|
|
1004
|
+
* application must use incremental_assign() for ERR__ASSIGN_PARTITIONS and
|
|
1005
|
+
* incremental_unassign() for ERR__REVOKE_PARTITIONS.
|
|
1006
|
+
*
|
|
1007
|
+
* Without a rebalance callback this is done automatically by librdkafka
|
|
1008
|
+
* but registering a rebalance callback gives the application flexibility
|
|
1009
|
+
* in performing other operations along with the assinging/revocation,
|
|
1010
|
+
* such as fetching offsets from an alternate location (on assign)
|
|
1011
|
+
* or manually committing offsets (on revoke).
|
|
1012
|
+
*
|
|
1013
|
+
* @sa RdKafka::KafkaConsumer::assign()
|
|
1014
|
+
* @sa RdKafka::KafkaConsumer::incremental_assign()
|
|
1015
|
+
* @sa RdKafka::KafkaConsumer::incremental_unassign()
|
|
1016
|
+
* @sa RdKafka::KafkaConsumer::assignment_lost()
|
|
1017
|
+
* @sa RdKafka::KafkaConsumer::rebalance_protocol()
|
|
1018
|
+
*
|
|
1019
|
+
* The following example show's the application's responsibilities:
|
|
1020
|
+
* @code
|
|
1021
|
+
* class MyRebalanceCb : public RdKafka::RebalanceCb {
|
|
1022
|
+
* public:
|
|
1023
|
+
* void rebalance_cb (RdKafka::KafkaConsumer *consumer,
|
|
1024
|
+
* RdKafka::ErrorCode err,
|
|
1025
|
+
* std::vector<RdKafka::TopicPartition*> &partitions) {
|
|
1026
|
+
* if (err == RdKafka::ERR__ASSIGN_PARTITIONS) {
|
|
1027
|
+
* // application may load offets from arbitrary external
|
|
1028
|
+
* // storage here and update \p partitions
|
|
1029
|
+
* if (consumer->rebalance_protocol() == "COOPERATIVE")
|
|
1030
|
+
* consumer->incremental_assign(partitions);
|
|
1031
|
+
* else
|
|
1032
|
+
* consumer->assign(partitions);
|
|
1033
|
+
*
|
|
1034
|
+
* } else if (err == RdKafka::ERR__REVOKE_PARTITIONS) {
|
|
1035
|
+
* // Application may commit offsets manually here
|
|
1036
|
+
* // if auto.commit.enable=false
|
|
1037
|
+
* if (consumer->rebalance_protocol() == "COOPERATIVE")
|
|
1038
|
+
* consumer->incremental_unassign(partitions);
|
|
1039
|
+
* else
|
|
1040
|
+
* consumer->unassign();
|
|
1041
|
+
*
|
|
1042
|
+
* } else {
|
|
1043
|
+
* std::cerr << "Rebalancing error: " <<
|
|
1044
|
+
* RdKafka::err2str(err) << std::endl;
|
|
1045
|
+
* consumer->unassign();
|
|
1046
|
+
* }
|
|
1047
|
+
* }
|
|
1048
|
+
* }
|
|
1049
|
+
* @endcode
|
|
1050
|
+
*
|
|
1051
|
+
* @remark The above example lacks error handling for assign calls, see
|
|
1052
|
+
* the examples/ directory.
|
|
1053
|
+
*/
|
|
1054
|
+
virtual void rebalance_cb(RdKafka::KafkaConsumer *consumer,
|
|
1055
|
+
RdKafka::ErrorCode err,
|
|
1056
|
+
std::vector<TopicPartition *> &partitions) = 0;
|
|
1057
|
+
|
|
1058
|
+
virtual ~RebalanceCb() {
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
|
|
1062
|
+
|
|
1063
|
+
/**
|
|
1064
|
+
* @brief Offset Commit callback class
|
|
1065
|
+
*/
|
|
1066
|
+
class RD_EXPORT OffsetCommitCb {
|
|
1067
|
+
public:
|
|
1068
|
+
/**
|
|
1069
|
+
* @brief Set offset commit callback for use with consumer groups
|
|
1070
|
+
*
|
|
1071
|
+
* The results of automatic or manual offset commits will be scheduled
|
|
1072
|
+
* for this callback and is served by RdKafka::KafkaConsumer::consume().
|
|
1073
|
+
*
|
|
1074
|
+
* If no partitions had valid offsets to commit this callback will be called
|
|
1075
|
+
* with \p err == ERR__NO_OFFSET which is not to be considered an error.
|
|
1076
|
+
*
|
|
1077
|
+
* The \p offsets list contains per-partition information:
|
|
1078
|
+
* - \c topic The topic committed
|
|
1079
|
+
* - \c partition The partition committed
|
|
1080
|
+
* - \c offset: Committed offset (attempted)
|
|
1081
|
+
* - \c err: Commit error
|
|
1082
|
+
*/
|
|
1083
|
+
virtual void offset_commit_cb(RdKafka::ErrorCode err,
|
|
1084
|
+
std::vector<TopicPartition *> &offsets) = 0;
|
|
1085
|
+
|
|
1086
|
+
virtual ~OffsetCommitCb() {
|
|
1087
|
+
}
|
|
1088
|
+
};
|
|
1089
|
+
|
|
1090
|
+
|
|
1091
|
+
|
|
1092
|
+
/**
|
|
1093
|
+
* @brief SSL broker certificate verification class.
|
|
1094
|
+
*
|
|
1095
|
+
* @remark Class instance must outlive the RdKafka client instance.
|
|
1096
|
+
*/
|
|
1097
|
+
class RD_EXPORT SslCertificateVerifyCb {
|
|
1098
|
+
public:
|
|
1099
|
+
/**
|
|
1100
|
+
* @brief SSL broker certificate verification callback.
|
|
1101
|
+
*
|
|
1102
|
+
* The verification callback is triggered from internal librdkafka threads
|
|
1103
|
+
* upon connecting to a broker. On each connection attempt the callback
|
|
1104
|
+
* will be called for each certificate in the broker's certificate chain,
|
|
1105
|
+
* starting at the root certification, as long as the application callback
|
|
1106
|
+
* returns 1 (valid certificate).
|
|
1107
|
+
*
|
|
1108
|
+
* \p broker_name and \p broker_id correspond to the broker the connection
|
|
1109
|
+
* is being made to.
|
|
1110
|
+
* The \c x509_error argument indicates if OpenSSL's verification of
|
|
1111
|
+
* the certificate succeed (0) or failed (an OpenSSL error code).
|
|
1112
|
+
* The application may set the SSL context error code by returning 0
|
|
1113
|
+
* from the verify callback and providing a non-zero SSL context error code
|
|
1114
|
+
* in \p x509_error.
|
|
1115
|
+
* If the verify callback sets \p x509_error to 0, returns 1, and the
|
|
1116
|
+
* original \p x509_error was non-zero, the error on the SSL context will
|
|
1117
|
+
* be cleared.
|
|
1118
|
+
* \p x509_error is always a valid pointer to an int.
|
|
1119
|
+
*
|
|
1120
|
+
* \p depth is the depth of the current certificate in the chain, starting
|
|
1121
|
+
* at the root certificate.
|
|
1122
|
+
*
|
|
1123
|
+
* The certificate itself is passed in binary DER format in \p buf of
|
|
1124
|
+
* size \p size.
|
|
1125
|
+
*
|
|
1126
|
+
* The callback must 1 if verification succeeds, or 0 if verification fails
|
|
1127
|
+
* and write a human-readable error message
|
|
1128
|
+
* to \p errstr.
|
|
1129
|
+
*
|
|
1130
|
+
* @warning This callback will be called from internal librdkafka threads.
|
|
1131
|
+
*
|
|
1132
|
+
* @remark See <openssl/x509_vfy.h> in the OpenSSL source distribution
|
|
1133
|
+
* for a list of \p x509_error codes.
|
|
1134
|
+
*/
|
|
1135
|
+
virtual bool ssl_cert_verify_cb(const std::string &broker_name,
|
|
1136
|
+
int32_t broker_id,
|
|
1137
|
+
int *x509_error,
|
|
1138
|
+
int depth,
|
|
1139
|
+
const char *buf,
|
|
1140
|
+
size_t size,
|
|
1141
|
+
std::string &errstr) = 0;
|
|
1142
|
+
|
|
1143
|
+
virtual ~SslCertificateVerifyCb() {
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
1146
|
+
|
|
1147
|
+
|
|
1148
|
+
/**
|
|
1149
|
+
* @brief \b Portability: SocketCb callback class
|
|
1150
|
+
*
|
|
1151
|
+
*/
|
|
1152
|
+
class RD_EXPORT SocketCb {
|
|
1153
|
+
public:
|
|
1154
|
+
/**
|
|
1155
|
+
* @brief Socket callback
|
|
1156
|
+
*
|
|
1157
|
+
* The socket callback is responsible for opening a socket
|
|
1158
|
+
* according to the supplied \p domain, \p type and \p protocol.
|
|
1159
|
+
* The socket shall be created with \c CLOEXEC set in a racefree fashion, if
|
|
1160
|
+
* possible.
|
|
1161
|
+
*
|
|
1162
|
+
* It is typically not required to register an alternative socket
|
|
1163
|
+
* implementation
|
|
1164
|
+
*
|
|
1165
|
+
* @returns The socket file descriptor or -1 on error (\c errno must be set)
|
|
1166
|
+
*/
|
|
1167
|
+
virtual int socket_cb(int domain, int type, int protocol) = 0;
|
|
1168
|
+
|
|
1169
|
+
virtual ~SocketCb() {
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
1172
|
+
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* @brief \b Portability: OpenCb callback class
|
|
1176
|
+
*
|
|
1177
|
+
*/
|
|
1178
|
+
class RD_EXPORT OpenCb {
|
|
1179
|
+
public:
|
|
1180
|
+
/**
|
|
1181
|
+
* @brief Open callback
|
|
1182
|
+
* The open callback is responsible for opening the file specified by
|
|
1183
|
+
* \p pathname, using \p flags and \p mode.
|
|
1184
|
+
* The file shall be opened with \c CLOEXEC set in a racefree fashion, if
|
|
1185
|
+
* possible.
|
|
1186
|
+
*
|
|
1187
|
+
* It is typically not required to register an alternative open implementation
|
|
1188
|
+
*
|
|
1189
|
+
* @remark Not currently available on native Win32
|
|
1190
|
+
*/
|
|
1191
|
+
virtual int open_cb(const std::string &path, int flags, int mode) = 0;
|
|
1192
|
+
|
|
1193
|
+
virtual ~OpenCb() {
|
|
1194
|
+
}
|
|
1195
|
+
};
|
|
1196
|
+
|
|
1197
|
+
|
|
1198
|
+
/**@}*/
|
|
1199
|
+
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
/**
|
|
1203
|
+
* @name Configuration interface
|
|
1204
|
+
* @{
|
|
1205
|
+
*
|
|
1206
|
+
*/
|
|
1207
|
+
|
|
1208
|
+
/**
|
|
1209
|
+
* @brief Configuration interface
|
|
1210
|
+
*
|
|
1211
|
+
* Holds either global or topic configuration that are passed to
|
|
1212
|
+
* RdKafka::Consumer::create(), RdKafka::Producer::create(),
|
|
1213
|
+
* RdKafka::KafkaConsumer::create(), etc.
|
|
1214
|
+
*
|
|
1215
|
+
* @sa CONFIGURATION.md for the full list of supported properties.
|
|
1216
|
+
*/
|
|
1217
|
+
class RD_EXPORT Conf {
|
|
1218
|
+
public:
|
|
1219
|
+
/**
|
|
1220
|
+
* @brief Configuration object type
|
|
1221
|
+
*/
|
|
1222
|
+
enum ConfType {
|
|
1223
|
+
CONF_GLOBAL, /**< Global configuration */
|
|
1224
|
+
CONF_TOPIC /**< Topic specific configuration */
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
/**
|
|
1228
|
+
* @brief RdKafka::Conf::Set() result code
|
|
1229
|
+
*/
|
|
1230
|
+
enum ConfResult {
|
|
1231
|
+
CONF_UNKNOWN = -2, /**< Unknown configuration property */
|
|
1232
|
+
CONF_INVALID = -1, /**< Invalid configuration value */
|
|
1233
|
+
CONF_OK = 0 /**< Configuration property was succesfully set */
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* @brief Create configuration object
|
|
1239
|
+
*/
|
|
1240
|
+
static Conf *create(ConfType type);
|
|
1241
|
+
|
|
1242
|
+
virtual ~Conf() {
|
|
1243
|
+
}
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* @brief Set configuration property \p name to value \p value.
|
|
1247
|
+
*
|
|
1248
|
+
* Fallthrough:
|
|
1249
|
+
* Topic-level configuration properties may be set using this interface
|
|
1250
|
+
* in which case they are applied on the \c default_topic_conf.
|
|
1251
|
+
* If no \c default_topic_conf has been set one will be created.
|
|
1252
|
+
* Any sub-sequent set("default_topic_conf", ..) calls will
|
|
1253
|
+
* replace the current default topic configuration.
|
|
1254
|
+
|
|
1255
|
+
* @returns CONF_OK on success, else writes a human readable error
|
|
1256
|
+
* description to \p errstr on error.
|
|
1257
|
+
*/
|
|
1258
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1259
|
+
const std::string &value,
|
|
1260
|
+
std::string &errstr) = 0;
|
|
1261
|
+
|
|
1262
|
+
/** @brief Use with \p name = \c \"dr_cb\" */
|
|
1263
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1264
|
+
DeliveryReportCb *dr_cb,
|
|
1265
|
+
std::string &errstr) = 0;
|
|
1266
|
+
|
|
1267
|
+
/** @brief Use with \p name = \c \"oauthbearer_token_refresh_cb\" */
|
|
1268
|
+
virtual Conf::ConfResult set(
|
|
1269
|
+
const std::string &name,
|
|
1270
|
+
OAuthBearerTokenRefreshCb *oauthbearer_token_refresh_cb,
|
|
1271
|
+
std::string &errstr) = 0;
|
|
1272
|
+
|
|
1273
|
+
/** @brief Use with \p name = \c \"event_cb\" */
|
|
1274
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1275
|
+
EventCb *event_cb,
|
|
1276
|
+
std::string &errstr) = 0;
|
|
1277
|
+
|
|
1278
|
+
/** @brief Use with \p name = \c \"default_topic_conf\"
|
|
1279
|
+
*
|
|
1280
|
+
* Sets the default topic configuration to use for for automatically
|
|
1281
|
+
* subscribed topics.
|
|
1282
|
+
*
|
|
1283
|
+
* @sa RdKafka::KafkaConsumer::subscribe()
|
|
1284
|
+
*/
|
|
1285
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1286
|
+
const Conf *topic_conf,
|
|
1287
|
+
std::string &errstr) = 0;
|
|
1288
|
+
|
|
1289
|
+
/** @brief Use with \p name = \c \"partitioner_cb\" */
|
|
1290
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1291
|
+
PartitionerCb *partitioner_cb,
|
|
1292
|
+
std::string &errstr) = 0;
|
|
1293
|
+
|
|
1294
|
+
/** @brief Use with \p name = \c \"partitioner_key_pointer_cb\" */
|
|
1295
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1296
|
+
PartitionerKeyPointerCb *partitioner_kp_cb,
|
|
1297
|
+
std::string &errstr) = 0;
|
|
1298
|
+
|
|
1299
|
+
/** @brief Use with \p name = \c \"socket_cb\" */
|
|
1300
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1301
|
+
SocketCb *socket_cb,
|
|
1302
|
+
std::string &errstr) = 0;
|
|
1303
|
+
|
|
1304
|
+
/** @brief Use with \p name = \c \"open_cb\" */
|
|
1305
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1306
|
+
OpenCb *open_cb,
|
|
1307
|
+
std::string &errstr) = 0;
|
|
1308
|
+
|
|
1309
|
+
/** @brief Use with \p name = \c \"rebalance_cb\" */
|
|
1310
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1311
|
+
RebalanceCb *rebalance_cb,
|
|
1312
|
+
std::string &errstr) = 0;
|
|
1313
|
+
|
|
1314
|
+
/** @brief Use with \p name = \c \"offset_commit_cb\" */
|
|
1315
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1316
|
+
OffsetCommitCb *offset_commit_cb,
|
|
1317
|
+
std::string &errstr) = 0;
|
|
1318
|
+
|
|
1319
|
+
/** @brief Use with \p name = \c \"ssl_cert_verify_cb\".
|
|
1320
|
+
* @returns CONF_OK on success or CONF_INVALID if SSL is
|
|
1321
|
+
* not supported in this build.
|
|
1322
|
+
*/
|
|
1323
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1324
|
+
SslCertificateVerifyCb *ssl_cert_verify_cb,
|
|
1325
|
+
std::string &errstr) = 0;
|
|
1326
|
+
|
|
1327
|
+
/**
|
|
1328
|
+
* @brief Set certificate/key \p cert_type from the \p cert_enc encoded
|
|
1329
|
+
* memory at \p buffer of \p size bytes.
|
|
1330
|
+
*
|
|
1331
|
+
* @param cert_type Certificate or key type to configure.
|
|
1332
|
+
* @param cert_enc Buffer \p encoding type.
|
|
1333
|
+
* @param buffer Memory pointer to encoded certificate or key.
|
|
1334
|
+
* The memory is not referenced after this function returns.
|
|
1335
|
+
* @param size Size of memory at \p buffer.
|
|
1336
|
+
* @param errstr A human-readable error string will be written to this string
|
|
1337
|
+
* on failure.
|
|
1338
|
+
*
|
|
1339
|
+
* @returns CONF_OK on success or CONF_INVALID if the memory in
|
|
1340
|
+
* \p buffer is of incorrect encoding, or if librdkafka
|
|
1341
|
+
* was not built with SSL support.
|
|
1342
|
+
*
|
|
1343
|
+
* @remark Calling this method multiple times with the same \p cert_type
|
|
1344
|
+
* will replace the previous value.
|
|
1345
|
+
*
|
|
1346
|
+
* @remark Calling this method with \p buffer set to NULL will clear the
|
|
1347
|
+
* configuration for \p cert_type.
|
|
1348
|
+
*
|
|
1349
|
+
* @remark The private key may require a password, which must be specified
|
|
1350
|
+
* with the `ssl.key.password` configuration property prior to
|
|
1351
|
+
* calling this function.
|
|
1352
|
+
*
|
|
1353
|
+
* @remark Private and public keys in PEM format may also be set with the
|
|
1354
|
+
* `ssl.key.pem` and `ssl.certificate.pem` configuration properties.
|
|
1355
|
+
*
|
|
1356
|
+
* @remark CA certificate in PEM format may also be set with the
|
|
1357
|
+
* `ssl.ca.pem` configuration property.
|
|
1358
|
+
*
|
|
1359
|
+
* @remark When librdkafka is linked to OpenSSL 3.0 and the certificate is
|
|
1360
|
+
* encoded using an obsolete cipher, it might be necessary to set up
|
|
1361
|
+
* an OpenSSL configuration file to load the "legacy" provider and
|
|
1362
|
+
* set the OPENSSL_CONF environment variable.
|
|
1363
|
+
* See
|
|
1364
|
+
* https://github.com/openssl/openssl/blob/master/README-PROVIDERS.md for more
|
|
1365
|
+
* information.
|
|
1366
|
+
*/
|
|
1367
|
+
virtual Conf::ConfResult set_ssl_cert(RdKafka::CertificateType cert_type,
|
|
1368
|
+
RdKafka::CertificateEncoding cert_enc,
|
|
1369
|
+
const void *buffer,
|
|
1370
|
+
size_t size,
|
|
1371
|
+
std::string &errstr) = 0;
|
|
1372
|
+
|
|
1373
|
+
/** @brief Query single configuration value
|
|
1374
|
+
*
|
|
1375
|
+
* Do not use this method to get callbacks registered by the configuration
|
|
1376
|
+
* file. Instead use the specific get() methods with the specific callback
|
|
1377
|
+
* parameter in the signature.
|
|
1378
|
+
*
|
|
1379
|
+
* Fallthrough:
|
|
1380
|
+
* Topic-level configuration properties from the \c default_topic_conf
|
|
1381
|
+
* may be retrieved using this interface.
|
|
1382
|
+
*
|
|
1383
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1384
|
+
* returns the value in \p value. */
|
|
1385
|
+
virtual Conf::ConfResult get(const std::string &name,
|
|
1386
|
+
std::string &value) const = 0;
|
|
1387
|
+
|
|
1388
|
+
/** @brief Query single configuration value
|
|
1389
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1390
|
+
* returns the value in \p dr_cb. */
|
|
1391
|
+
virtual Conf::ConfResult get(DeliveryReportCb *&dr_cb) const = 0;
|
|
1392
|
+
|
|
1393
|
+
/** @brief Query single configuration value
|
|
1394
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1395
|
+
* returns the value in \p oauthbearer_token_refresh_cb. */
|
|
1396
|
+
virtual Conf::ConfResult get(
|
|
1397
|
+
OAuthBearerTokenRefreshCb *&oauthbearer_token_refresh_cb) const = 0;
|
|
1398
|
+
|
|
1399
|
+
/** @brief Query single configuration value
|
|
1400
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1401
|
+
* returns the value in \p event_cb. */
|
|
1402
|
+
virtual Conf::ConfResult get(EventCb *&event_cb) const = 0;
|
|
1403
|
+
|
|
1404
|
+
/** @brief Query single configuration value
|
|
1405
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1406
|
+
* returns the value in \p partitioner_cb. */
|
|
1407
|
+
virtual Conf::ConfResult get(PartitionerCb *&partitioner_cb) const = 0;
|
|
1408
|
+
|
|
1409
|
+
/** @brief Query single configuration value
|
|
1410
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1411
|
+
* returns the value in \p partitioner_kp_cb. */
|
|
1412
|
+
virtual Conf::ConfResult get(
|
|
1413
|
+
PartitionerKeyPointerCb *&partitioner_kp_cb) const = 0;
|
|
1414
|
+
|
|
1415
|
+
/** @brief Query single configuration value
|
|
1416
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1417
|
+
* returns the value in \p socket_cb. */
|
|
1418
|
+
virtual Conf::ConfResult get(SocketCb *&socket_cb) const = 0;
|
|
1419
|
+
|
|
1420
|
+
/** @brief Query single configuration value
|
|
1421
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1422
|
+
* returns the value in \p open_cb. */
|
|
1423
|
+
virtual Conf::ConfResult get(OpenCb *&open_cb) const = 0;
|
|
1424
|
+
|
|
1425
|
+
/** @brief Query single configuration value
|
|
1426
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1427
|
+
* returns the value in \p rebalance_cb. */
|
|
1428
|
+
virtual Conf::ConfResult get(RebalanceCb *&rebalance_cb) const = 0;
|
|
1429
|
+
|
|
1430
|
+
/** @brief Query single configuration value
|
|
1431
|
+
* @returns CONF_OK if the property was set previously set and
|
|
1432
|
+
* returns the value in \p offset_commit_cb. */
|
|
1433
|
+
virtual Conf::ConfResult get(OffsetCommitCb *&offset_commit_cb) const = 0;
|
|
1434
|
+
|
|
1435
|
+
/** @brief Use with \p name = \c \"ssl_cert_verify_cb\" */
|
|
1436
|
+
virtual Conf::ConfResult get(
|
|
1437
|
+
SslCertificateVerifyCb *&ssl_cert_verify_cb) const = 0;
|
|
1438
|
+
|
|
1439
|
+
/** @brief Dump configuration names and values to list containing
|
|
1440
|
+
* name,value tuples */
|
|
1441
|
+
virtual std::list<std::string> *dump() = 0;
|
|
1442
|
+
|
|
1443
|
+
/** @brief Use with \p name = \c \"consume_cb\" */
|
|
1444
|
+
virtual Conf::ConfResult set(const std::string &name,
|
|
1445
|
+
ConsumeCb *consume_cb,
|
|
1446
|
+
std::string &errstr) = 0;
|
|
1447
|
+
|
|
1448
|
+
/**
|
|
1449
|
+
* @brief Returns the underlying librdkafka C rd_kafka_conf_t handle.
|
|
1450
|
+
*
|
|
1451
|
+
* @warning Calling the C API on this handle is not recommended and there
|
|
1452
|
+
* is no official support for it, but for cases where the C++
|
|
1453
|
+
* does not provide the proper functionality this C handle can be
|
|
1454
|
+
* used to interact directly with the core librdkafka API.
|
|
1455
|
+
*
|
|
1456
|
+
* @remark The lifetime of the returned pointer is the same as the Conf
|
|
1457
|
+
* object this method is called on.
|
|
1458
|
+
*
|
|
1459
|
+
* @remark Include <rdkafka/rdkafka.h> prior to including
|
|
1460
|
+
* <rdkafka/rdkafkacpp.h>
|
|
1461
|
+
*
|
|
1462
|
+
* @returns \c rd_kafka_conf_t* if this is a CONF_GLOBAL object, else NULL.
|
|
1463
|
+
*/
|
|
1464
|
+
virtual struct rd_kafka_conf_s *c_ptr_global() = 0;
|
|
1465
|
+
|
|
1466
|
+
/**
|
|
1467
|
+
* @brief Returns the underlying librdkafka C rd_kafka_topic_conf_t handle.
|
|
1468
|
+
*
|
|
1469
|
+
* @warning Calling the C API on this handle is not recommended and there
|
|
1470
|
+
* is no official support for it, but for cases where the C++
|
|
1471
|
+
* does not provide the proper functionality this C handle can be
|
|
1472
|
+
* used to interact directly with the core librdkafka API.
|
|
1473
|
+
*
|
|
1474
|
+
* @remark The lifetime of the returned pointer is the same as the Conf
|
|
1475
|
+
* object this method is called on.
|
|
1476
|
+
*
|
|
1477
|
+
* @remark Include <rdkafka/rdkafka.h> prior to including
|
|
1478
|
+
* <rdkafka/rdkafkacpp.h>
|
|
1479
|
+
*
|
|
1480
|
+
* @returns \c rd_kafka_topic_conf_t* if this is a CONF_TOPIC object,
|
|
1481
|
+
* else NULL.
|
|
1482
|
+
*/
|
|
1483
|
+
virtual struct rd_kafka_topic_conf_s *c_ptr_topic() = 0;
|
|
1484
|
+
|
|
1485
|
+
/**
|
|
1486
|
+
* @brief Set callback_data for ssl engine.
|
|
1487
|
+
*
|
|
1488
|
+
* @remark The \c ssl.engine.location configuration must be set for this
|
|
1489
|
+
* to have affect.
|
|
1490
|
+
*
|
|
1491
|
+
* @remark The memory pointed to by \p value must remain valid for the
|
|
1492
|
+
* lifetime of the configuration object and any Kafka clients that
|
|
1493
|
+
* use it.
|
|
1494
|
+
*
|
|
1495
|
+
* @returns CONF_OK on success, else CONF_INVALID.
|
|
1496
|
+
*/
|
|
1497
|
+
virtual Conf::ConfResult set_engine_callback_data(void *value,
|
|
1498
|
+
std::string &errstr) = 0;
|
|
1499
|
+
|
|
1500
|
+
|
|
1501
|
+
/** @brief Enable/disable creation of a queue specific to SASL events
|
|
1502
|
+
* and callbacks.
|
|
1503
|
+
*
|
|
1504
|
+
* For SASL mechanisms that trigger callbacks (currently OAUTHBEARER) this
|
|
1505
|
+
* configuration API allows an application to get a dedicated
|
|
1506
|
+
* queue for the SASL events/callbacks. After enabling the queue with this API
|
|
1507
|
+
* the application can retrieve the queue by calling
|
|
1508
|
+
* RdKafka::Handle::get_sasl_queue() on the client instance.
|
|
1509
|
+
* This queue may then be served directly by the application
|
|
1510
|
+
* (RdKafka::Queue::poll()) or forwarded to another queue, such as
|
|
1511
|
+
* the background queue.
|
|
1512
|
+
*
|
|
1513
|
+
* A convenience function is available to automatically forward the SASL queue
|
|
1514
|
+
* to librdkafka's background thread, see
|
|
1515
|
+
* RdKafka::Handle::sasl_background_callbacks_enable().
|
|
1516
|
+
*
|
|
1517
|
+
* By default (\p enable = false) the main queue (as served by
|
|
1518
|
+
* RdKafka::Handle::poll(), et.al.) is used for SASL callbacks.
|
|
1519
|
+
*
|
|
1520
|
+
* @remark The SASL queue is currently only used by the SASL OAUTHBEARER "
|
|
1521
|
+
* mechanism's token refresh callback.
|
|
1522
|
+
*/
|
|
1523
|
+
virtual Conf::ConfResult enable_sasl_queue(bool enable,
|
|
1524
|
+
std::string &errstr) = 0;
|
|
1525
|
+
};
|
|
1526
|
+
|
|
1527
|
+
/**@}*/
|
|
1528
|
+
|
|
1529
|
+
|
|
1530
|
+
/**
|
|
1531
|
+
* @name Kafka base client handle
|
|
1532
|
+
* @{
|
|
1533
|
+
*
|
|
1534
|
+
*/
|
|
1535
|
+
|
|
1536
|
+
/**
|
|
1537
|
+
* @brief Base handle, super class for specific clients.
|
|
1538
|
+
*/
|
|
1539
|
+
class RD_EXPORT Handle {
|
|
1540
|
+
public:
|
|
1541
|
+
virtual ~Handle() {
|
|
1542
|
+
}
|
|
1543
|
+
|
|
1544
|
+
/** @returns the name of the handle */
|
|
1545
|
+
virtual std::string name() const = 0;
|
|
1546
|
+
|
|
1547
|
+
/**
|
|
1548
|
+
* @brief Returns the client's broker-assigned group member id
|
|
1549
|
+
*
|
|
1550
|
+
* @remark This currently requires the high-level KafkaConsumer
|
|
1551
|
+
*
|
|
1552
|
+
* @returns Last assigned member id, or empty string if not currently
|
|
1553
|
+
* a group member.
|
|
1554
|
+
*/
|
|
1555
|
+
virtual std::string memberid() const = 0;
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
/**
|
|
1559
|
+
* @brief Polls the provided kafka handle for events.
|
|
1560
|
+
*
|
|
1561
|
+
* Events will trigger application provided callbacks to be called.
|
|
1562
|
+
*
|
|
1563
|
+
* The \p timeout_ms argument specifies the maximum amount of time
|
|
1564
|
+
* (in milliseconds) that the call will block waiting for events.
|
|
1565
|
+
* For non-blocking calls, provide 0 as \p timeout_ms.
|
|
1566
|
+
* To wait indefinately for events, provide -1.
|
|
1567
|
+
*
|
|
1568
|
+
* Events:
|
|
1569
|
+
* - delivery report callbacks (if an RdKafka::DeliveryCb is configured)
|
|
1570
|
+
* [producer]
|
|
1571
|
+
* - event callbacks (if an RdKafka::EventCb is configured) [producer &
|
|
1572
|
+
* consumer]
|
|
1573
|
+
*
|
|
1574
|
+
* @remark An application should make sure to call poll() at regular
|
|
1575
|
+
* intervals to serve any queued callbacks waiting to be called.
|
|
1576
|
+
*
|
|
1577
|
+
* @warning This method MUST NOT be used with the RdKafka::KafkaConsumer,
|
|
1578
|
+
* use its RdKafka::KafkaConsumer::consume() instead.
|
|
1579
|
+
*
|
|
1580
|
+
* @returns the number of events served.
|
|
1581
|
+
*/
|
|
1582
|
+
virtual int poll(int timeout_ms) = 0;
|
|
1583
|
+
|
|
1584
|
+
/**
|
|
1585
|
+
* @brief Returns the current out queue length
|
|
1586
|
+
*
|
|
1587
|
+
* The out queue contains messages and requests waiting to be sent to,
|
|
1588
|
+
* or acknowledged by, the broker.
|
|
1589
|
+
*/
|
|
1590
|
+
virtual int outq_len() = 0;
|
|
1591
|
+
|
|
1592
|
+
/**
|
|
1593
|
+
* @brief Request Metadata from broker.
|
|
1594
|
+
*
|
|
1595
|
+
* Parameters:
|
|
1596
|
+
* \p all_topics - if non-zero: request info about all topics in cluster,
|
|
1597
|
+
* if zero: only request info about locally known topics.
|
|
1598
|
+
* \p only_rkt - only request info about this topic
|
|
1599
|
+
* \p metadatap - pointer to hold metadata result.
|
|
1600
|
+
* The \p *metadatap pointer must be released with \c
|
|
1601
|
+
* delete. \p timeout_ms - maximum response time before failing.
|
|
1602
|
+
*
|
|
1603
|
+
* @returns RdKafka::ERR_NO_ERROR on success (in which case \p *metadatap
|
|
1604
|
+
* will be set), else RdKafka::ERR__TIMED_OUT on timeout or
|
|
1605
|
+
* other error code on error.
|
|
1606
|
+
*/
|
|
1607
|
+
virtual ErrorCode metadata(bool all_topics,
|
|
1608
|
+
const Topic *only_rkt,
|
|
1609
|
+
Metadata **metadatap,
|
|
1610
|
+
int timeout_ms) = 0;
|
|
1611
|
+
|
|
1612
|
+
|
|
1613
|
+
/**
|
|
1614
|
+
* @brief Pause producing or consumption for the provided list of partitions.
|
|
1615
|
+
*
|
|
1616
|
+
* Success or error is returned per-partition in the \p partitions list.
|
|
1617
|
+
*
|
|
1618
|
+
* @returns ErrorCode::NO_ERROR
|
|
1619
|
+
*
|
|
1620
|
+
* @sa resume()
|
|
1621
|
+
*/
|
|
1622
|
+
virtual ErrorCode pause(std::vector<TopicPartition *> &partitions) = 0;
|
|
1623
|
+
|
|
1624
|
+
|
|
1625
|
+
/**
|
|
1626
|
+
* @brief Resume producing or consumption for the provided list of partitions.
|
|
1627
|
+
*
|
|
1628
|
+
* Success or error is returned per-partition in the \p partitions list.
|
|
1629
|
+
*
|
|
1630
|
+
* @returns ErrorCode::NO_ERROR
|
|
1631
|
+
*
|
|
1632
|
+
* @sa pause()
|
|
1633
|
+
*/
|
|
1634
|
+
virtual ErrorCode resume(std::vector<TopicPartition *> &partitions) = 0;
|
|
1635
|
+
|
|
1636
|
+
|
|
1637
|
+
/**
|
|
1638
|
+
* @brief Query broker for low (oldest/beginning)
|
|
1639
|
+
* and high (newest/end) offsets for partition.
|
|
1640
|
+
*
|
|
1641
|
+
* Offsets are returned in \p *low and \p *high respectively.
|
|
1642
|
+
*
|
|
1643
|
+
* @returns RdKafka::ERR_NO_ERROR on success or an error code on failure.
|
|
1644
|
+
*/
|
|
1645
|
+
virtual ErrorCode query_watermark_offsets(const std::string &topic,
|
|
1646
|
+
int32_t partition,
|
|
1647
|
+
int64_t *low,
|
|
1648
|
+
int64_t *high,
|
|
1649
|
+
int timeout_ms) = 0;
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* @brief Get last known low (oldest/beginning)
|
|
1653
|
+
* and high (newest/end) offsets for partition.
|
|
1654
|
+
*
|
|
1655
|
+
* The low offset is updated periodically (if statistics.interval.ms is set)
|
|
1656
|
+
* while the high offset is updated on each fetched message set from the
|
|
1657
|
+
* broker.
|
|
1658
|
+
*
|
|
1659
|
+
* If there is no cached offset (either low or high, or both) then
|
|
1660
|
+
* OFFSET_INVALID will be returned for the respective offset.
|
|
1661
|
+
*
|
|
1662
|
+
* Offsets are returned in \p *low and \p *high respectively.
|
|
1663
|
+
*
|
|
1664
|
+
* @returns RdKafka::ERR_NO_ERROR on success or an error code on failure.
|
|
1665
|
+
*
|
|
1666
|
+
* @remark Shall only be used with an active consumer instance.
|
|
1667
|
+
*/
|
|
1668
|
+
virtual ErrorCode get_watermark_offsets(const std::string &topic,
|
|
1669
|
+
int32_t partition,
|
|
1670
|
+
int64_t *low,
|
|
1671
|
+
int64_t *high) = 0;
|
|
1672
|
+
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* @brief Look up the offsets for the given partitions by timestamp.
|
|
1676
|
+
*
|
|
1677
|
+
* The returned offset for each partition is the earliest offset whose
|
|
1678
|
+
* timestamp is greater than or equal to the given timestamp in the
|
|
1679
|
+
* corresponding partition.
|
|
1680
|
+
*
|
|
1681
|
+
* The timestamps to query are represented as \c offset in \p offsets
|
|
1682
|
+
* on input, and \c offset() will return the closest earlier offset
|
|
1683
|
+
* for the timestamp on output.
|
|
1684
|
+
*
|
|
1685
|
+
* Timestamps are expressed as milliseconds since epoch (UTC).
|
|
1686
|
+
*
|
|
1687
|
+
* The function will block for at most \p timeout_ms milliseconds.
|
|
1688
|
+
*
|
|
1689
|
+
* @remark Duplicate Topic+Partitions are not supported.
|
|
1690
|
+
* @remark Errors are also returned per TopicPartition, see \c err()
|
|
1691
|
+
*
|
|
1692
|
+
* @returns an error code for general errors, else RdKafka::ERR_NO_ERROR
|
|
1693
|
+
* in which case per-partition errors might be set.
|
|
1694
|
+
*/
|
|
1695
|
+
virtual ErrorCode offsetsForTimes(std::vector<TopicPartition *> &offsets,
|
|
1696
|
+
int timeout_ms) = 0;
|
|
1697
|
+
|
|
1698
|
+
|
|
1699
|
+
/**
|
|
1700
|
+
* @brief Retrieve queue for a given partition.
|
|
1701
|
+
*
|
|
1702
|
+
* @returns The fetch queue for the given partition if successful. Else,
|
|
1703
|
+
* NULL is returned.
|
|
1704
|
+
*
|
|
1705
|
+
* @remark This function only works on consumers.
|
|
1706
|
+
*/
|
|
1707
|
+
virtual Queue *get_partition_queue(const TopicPartition *partition) = 0;
|
|
1708
|
+
|
|
1709
|
+
/**
|
|
1710
|
+
* @brief Forward librdkafka logs (and debug) to the specified queue
|
|
1711
|
+
* for serving with one of the ..poll() calls.
|
|
1712
|
+
*
|
|
1713
|
+
* This allows an application to serve log callbacks (\c log_cb)
|
|
1714
|
+
* in its thread of choice.
|
|
1715
|
+
*
|
|
1716
|
+
* @param queue Queue to forward logs to. If the value is NULL the logs
|
|
1717
|
+
* are forwarded to the main queue.
|
|
1718
|
+
*
|
|
1719
|
+
* @remark The configuration property \c log.queue MUST also be set to true.
|
|
1720
|
+
*
|
|
1721
|
+
* @remark librdkafka maintains its own reference to the provided queue.
|
|
1722
|
+
*
|
|
1723
|
+
* @returns ERR_NO_ERROR on success or an error code on error.
|
|
1724
|
+
*/
|
|
1725
|
+
virtual ErrorCode set_log_queue(Queue *queue) = 0;
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* @brief Cancels the current callback dispatcher (Handle::poll(),
|
|
1729
|
+
* KafkaConsumer::consume(), etc).
|
|
1730
|
+
*
|
|
1731
|
+
* A callback may use this to force an immediate return to the calling
|
|
1732
|
+
* code (caller of e.g. Handle::poll()) without processing any further
|
|
1733
|
+
* events.
|
|
1734
|
+
*
|
|
1735
|
+
* @remark This function MUST ONLY be called from within a
|
|
1736
|
+
* librdkafka callback.
|
|
1737
|
+
*/
|
|
1738
|
+
virtual void yield() = 0;
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
* @brief Returns the ClusterId as reported in broker metadata.
|
|
1742
|
+
*
|
|
1743
|
+
* @param timeout_ms If there is no cached value from metadata retrieval
|
|
1744
|
+
* then this specifies the maximum amount of time
|
|
1745
|
+
* (in milliseconds) the call will block waiting
|
|
1746
|
+
* for metadata to be retrieved.
|
|
1747
|
+
* Use 0 for non-blocking calls.
|
|
1748
|
+
*
|
|
1749
|
+
* @remark Requires broker version >=0.10.0 and api.version.request=true.
|
|
1750
|
+
*
|
|
1751
|
+
* @returns Last cached ClusterId, or empty string if no ClusterId could be
|
|
1752
|
+
* retrieved in the allotted timespan.
|
|
1753
|
+
*/
|
|
1754
|
+
virtual std::string clusterid(int timeout_ms) = 0;
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* @brief Returns the underlying librdkafka C rd_kafka_t handle.
|
|
1758
|
+
*
|
|
1759
|
+
* @warning Calling the C API on this handle is not recommended and there
|
|
1760
|
+
* is no official support for it, but for cases where the C++
|
|
1761
|
+
* does not provide the proper functionality this C handle can be
|
|
1762
|
+
* used to interact directly with the core librdkafka API.
|
|
1763
|
+
*
|
|
1764
|
+
* @remark The lifetime of the returned pointer is the same as the Topic
|
|
1765
|
+
* object this method is called on.
|
|
1766
|
+
*
|
|
1767
|
+
* @remark Include <rdkafka/rdkafka.h> prior to including
|
|
1768
|
+
* <rdkafka/rdkafkacpp.h>
|
|
1769
|
+
*
|
|
1770
|
+
* @returns \c rd_kafka_t*
|
|
1771
|
+
*/
|
|
1772
|
+
virtual struct rd_kafka_s *c_ptr() = 0;
|
|
1773
|
+
|
|
1774
|
+
/**
|
|
1775
|
+
* @brief Returns the current ControllerId (controller broker id)
|
|
1776
|
+
* as reported in broker metadata.
|
|
1777
|
+
*
|
|
1778
|
+
* @param timeout_ms If there is no cached value from metadata retrieval
|
|
1779
|
+
* then this specifies the maximum amount of time
|
|
1780
|
+
* (in milliseconds) the call will block waiting
|
|
1781
|
+
* for metadata to be retrieved.
|
|
1782
|
+
* Use 0 for non-blocking calls.
|
|
1783
|
+
*
|
|
1784
|
+
* @remark Requires broker version >=0.10.0 and api.version.request=true.
|
|
1785
|
+
*
|
|
1786
|
+
* @returns Last cached ControllerId, or -1 if no ControllerId could be
|
|
1787
|
+
* retrieved in the allotted timespan.
|
|
1788
|
+
*/
|
|
1789
|
+
virtual int32_t controllerid(int timeout_ms) = 0;
|
|
1790
|
+
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* @brief Returns the first fatal error set on this client instance,
|
|
1794
|
+
* or ERR_NO_ERROR if no fatal error has occurred.
|
|
1795
|
+
*
|
|
1796
|
+
* This function is to be used with the Idempotent Producer and
|
|
1797
|
+
* the Event class for \c EVENT_ERROR events to detect fatal errors.
|
|
1798
|
+
*
|
|
1799
|
+
* Generally all errors raised by the error event are to be considered
|
|
1800
|
+
* informational and temporary, the client will try to recover from all
|
|
1801
|
+
* errors in a graceful fashion (by retrying, etc).
|
|
1802
|
+
*
|
|
1803
|
+
* However, some errors should logically be considered fatal to retain
|
|
1804
|
+
* consistency; in particular a set of errors that may occur when using the
|
|
1805
|
+
* Idempotent Producer and the in-order or exactly-once producer guarantees
|
|
1806
|
+
* can't be satisfied.
|
|
1807
|
+
*
|
|
1808
|
+
* @param errstr A human readable error string if a fatal error was set.
|
|
1809
|
+
*
|
|
1810
|
+
* @returns ERR_NO_ERROR if no fatal error has been raised, else
|
|
1811
|
+
* any other error code.
|
|
1812
|
+
*/
|
|
1813
|
+
virtual ErrorCode fatal_error(std::string &errstr) const = 0;
|
|
1814
|
+
|
|
1815
|
+
/**
|
|
1816
|
+
* @brief Set SASL/OAUTHBEARER token and metadata
|
|
1817
|
+
*
|
|
1818
|
+
* @param token_value the mandatory token value to set, often (but not
|
|
1819
|
+
* necessarily) a JWS compact serialization as per
|
|
1820
|
+
* https://tools.ietf.org/html/rfc7515#section-3.1.
|
|
1821
|
+
* @param md_lifetime_ms when the token expires, in terms of the number of
|
|
1822
|
+
* milliseconds since the epoch.
|
|
1823
|
+
* @param md_principal_name the Kafka principal name associated with the
|
|
1824
|
+
* token.
|
|
1825
|
+
* @param extensions potentially empty SASL extension keys and values where
|
|
1826
|
+
* element [i] is the key and [i+1] is the key's value, to be communicated
|
|
1827
|
+
* to the broker as additional key-value pairs during the initial client
|
|
1828
|
+
* response as per https://tools.ietf.org/html/rfc7628#section-3.1. The
|
|
1829
|
+
* number of SASL extension keys plus values must be a non-negative multiple
|
|
1830
|
+
* of 2. Any provided keys and values are copied.
|
|
1831
|
+
* @param errstr A human readable error string is written here, only if
|
|
1832
|
+
* there is an error.
|
|
1833
|
+
*
|
|
1834
|
+
* The SASL/OAUTHBEARER token refresh callback should invoke
|
|
1835
|
+
* this method upon success. The extension keys must not include the reserved
|
|
1836
|
+
* key "`auth`", and all extension keys and values must conform to the
|
|
1837
|
+
* required format as per https://tools.ietf.org/html/rfc7628#section-3.1:
|
|
1838
|
+
*
|
|
1839
|
+
* key = 1*(ALPHA)
|
|
1840
|
+
* value = *(VCHAR / SP / HTAB / CR / LF )
|
|
1841
|
+
*
|
|
1842
|
+
* @returns \c RdKafka::ERR_NO_ERROR on success, otherwise \p errstr set
|
|
1843
|
+
* and:<br>
|
|
1844
|
+
* \c RdKafka::ERR__INVALID_ARG if any of the arguments are
|
|
1845
|
+
* invalid;<br>
|
|
1846
|
+
* \c RdKafka::ERR__NOT_IMPLEMENTED if SASL/OAUTHBEARER is not
|
|
1847
|
+
* supported by this build;<br>
|
|
1848
|
+
* \c RdKafka::ERR__STATE if SASL/OAUTHBEARER is supported but is
|
|
1849
|
+
* not configured as the client's authentication mechanism.<br>
|
|
1850
|
+
*
|
|
1851
|
+
* @sa RdKafka::oauthbearer_set_token_failure
|
|
1852
|
+
* @sa RdKafka::Conf::set() \c "oauthbearer_token_refresh_cb"
|
|
1853
|
+
*/
|
|
1854
|
+
virtual ErrorCode oauthbearer_set_token(
|
|
1855
|
+
const std::string &token_value,
|
|
1856
|
+
int64_t md_lifetime_ms,
|
|
1857
|
+
const std::string &md_principal_name,
|
|
1858
|
+
const std::list<std::string> &extensions,
|
|
1859
|
+
std::string &errstr) = 0;
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* @brief SASL/OAUTHBEARER token refresh failure indicator.
|
|
1863
|
+
*
|
|
1864
|
+
* @param errstr human readable error reason for failing to acquire a token.
|
|
1865
|
+
*
|
|
1866
|
+
* The SASL/OAUTHBEARER token refresh callback should
|
|
1867
|
+
* invoke this method upon failure to refresh the token.
|
|
1868
|
+
*
|
|
1869
|
+
* @returns \c RdKafka::ERR_NO_ERROR on success, otherwise:<br>
|
|
1870
|
+
* \c RdKafka::ERR__NOT_IMPLEMENTED if SASL/OAUTHBEARER is not
|
|
1871
|
+
* supported by this build;<br>
|
|
1872
|
+
* \c RdKafka::ERR__STATE if SASL/OAUTHBEARER is supported but is
|
|
1873
|
+
* not configured as the client's authentication mechanism.
|
|
1874
|
+
*
|
|
1875
|
+
* @sa RdKafka::oauthbearer_set_token
|
|
1876
|
+
* @sa RdKafka::Conf::set() \c "oauthbearer_token_refresh_cb"
|
|
1877
|
+
*/
|
|
1878
|
+
virtual ErrorCode oauthbearer_set_token_failure(
|
|
1879
|
+
const std::string &errstr) = 0;
|
|
1880
|
+
|
|
1881
|
+
/**
|
|
1882
|
+
* @brief Enable SASL OAUTHBEARER refresh callbacks on the librdkafka
|
|
1883
|
+
* background thread.
|
|
1884
|
+
*
|
|
1885
|
+
* This serves as an alternative for applications that do not
|
|
1886
|
+
* call RdKafka::Handle::poll() (et.al.) at regular intervals.
|
|
1887
|
+
*/
|
|
1888
|
+
virtual Error *sasl_background_callbacks_enable() = 0;
|
|
1889
|
+
|
|
1890
|
+
|
|
1891
|
+
/**
|
|
1892
|
+
* @returns the SASL callback queue, if enabled, else NULL.
|
|
1893
|
+
*
|
|
1894
|
+
* @sa RdKafka::Conf::enable_sasl_queue()
|
|
1895
|
+
*/
|
|
1896
|
+
virtual Queue *get_sasl_queue() = 0;
|
|
1897
|
+
|
|
1898
|
+
/**
|
|
1899
|
+
* @returns the librdkafka background thread queue.
|
|
1900
|
+
*/
|
|
1901
|
+
virtual Queue *get_background_queue() = 0;
|
|
1902
|
+
|
|
1903
|
+
|
|
1904
|
+
|
|
1905
|
+
/**
|
|
1906
|
+
* @brief Allocate memory using the same allocator librdkafka uses.
|
|
1907
|
+
*
|
|
1908
|
+
* This is typically an abstraction for the malloc(3) call and makes sure
|
|
1909
|
+
* the application can use the same memory allocator as librdkafka for
|
|
1910
|
+
* allocating pointers that are used by librdkafka.
|
|
1911
|
+
*
|
|
1912
|
+
* @remark Memory allocated by mem_malloc() must be freed using
|
|
1913
|
+
* mem_free().
|
|
1914
|
+
*/
|
|
1915
|
+
virtual void *mem_malloc(size_t size) = 0;
|
|
1916
|
+
|
|
1917
|
+
/**
|
|
1918
|
+
* @brief Free pointer returned by librdkafka
|
|
1919
|
+
*
|
|
1920
|
+
* This is typically an abstraction for the free(3) call and makes sure
|
|
1921
|
+
* the application can use the same memory allocator as librdkafka for
|
|
1922
|
+
* freeing pointers returned by librdkafka.
|
|
1923
|
+
*
|
|
1924
|
+
* In standard setups it is usually not necessary to use this interface
|
|
1925
|
+
* rather than the free(3) function.
|
|
1926
|
+
*
|
|
1927
|
+
* @remark mem_free() must only be used for pointers returned by APIs
|
|
1928
|
+
* that explicitly mention using this function for freeing.
|
|
1929
|
+
*/
|
|
1930
|
+
virtual void mem_free(void *ptr) = 0;
|
|
1931
|
+
|
|
1932
|
+
/**
|
|
1933
|
+
* @brief Sets SASL credentials used for SASL PLAIN and SCRAM mechanisms by
|
|
1934
|
+
* this Kafka client.
|
|
1935
|
+
*
|
|
1936
|
+
* This function sets or resets the SASL username and password credentials
|
|
1937
|
+
* used by this Kafka client. The new credentials will be used the next time
|
|
1938
|
+
* this client needs to authenticate to a broker.
|
|
1939
|
+
* will not disconnect existing connections that might have been made using
|
|
1940
|
+
* the old credentials.
|
|
1941
|
+
*
|
|
1942
|
+
* @remark This function only applies to the SASL PLAIN and SCRAM mechanisms.
|
|
1943
|
+
*
|
|
1944
|
+
* @returns NULL on success or an error object on error.
|
|
1945
|
+
*/
|
|
1946
|
+
virtual Error *sasl_set_credentials(const std::string &username,
|
|
1947
|
+
const std::string &password) = 0;
|
|
1948
|
+
};
|
|
1949
|
+
|
|
1950
|
+
|
|
1951
|
+
/**@}*/
|
|
1952
|
+
|
|
1953
|
+
|
|
1954
|
+
/**
|
|
1955
|
+
* @name Topic and partition objects
|
|
1956
|
+
* @{
|
|
1957
|
+
*
|
|
1958
|
+
*/
|
|
1959
|
+
|
|
1960
|
+
/**
|
|
1961
|
+
* @brief Topic+Partition
|
|
1962
|
+
*
|
|
1963
|
+
* This is a generic type to hold a single partition and various
|
|
1964
|
+
* information about it.
|
|
1965
|
+
*
|
|
1966
|
+
* Is typically used with std::vector<RdKafka::TopicPartition*> to provide
|
|
1967
|
+
* a list of partitions for different operations.
|
|
1968
|
+
*/
|
|
1969
|
+
class RD_EXPORT TopicPartition {
|
|
1970
|
+
public:
|
|
1971
|
+
/**
|
|
1972
|
+
* @brief Create topic+partition object for \p topic and \p partition.
|
|
1973
|
+
*
|
|
1974
|
+
* Use \c delete to deconstruct.
|
|
1975
|
+
*/
|
|
1976
|
+
static TopicPartition *create(const std::string &topic, int partition);
|
|
1977
|
+
|
|
1978
|
+
/**
|
|
1979
|
+
* @brief Create topic+partition object for \p topic and \p partition
|
|
1980
|
+
* with offset \p offset.
|
|
1981
|
+
*
|
|
1982
|
+
* Use \c delete to deconstruct.
|
|
1983
|
+
*/
|
|
1984
|
+
static TopicPartition *create(const std::string &topic,
|
|
1985
|
+
int partition,
|
|
1986
|
+
int64_t offset);
|
|
1987
|
+
|
|
1988
|
+
virtual ~TopicPartition() = 0;
|
|
1989
|
+
|
|
1990
|
+
/**
|
|
1991
|
+
* @brief Destroy/delete the TopicPartitions in \p partitions
|
|
1992
|
+
* and clear the vector.
|
|
1993
|
+
*/
|
|
1994
|
+
static void destroy(std::vector<TopicPartition *> &partitions);
|
|
1995
|
+
|
|
1996
|
+
/** @returns topic name */
|
|
1997
|
+
virtual const std::string &topic() const = 0;
|
|
1998
|
+
|
|
1999
|
+
/** @returns partition id */
|
|
2000
|
+
virtual int partition() const = 0;
|
|
2001
|
+
|
|
2002
|
+
/** @returns offset (if applicable) */
|
|
2003
|
+
virtual int64_t offset() const = 0;
|
|
2004
|
+
|
|
2005
|
+
/** @brief Set offset */
|
|
2006
|
+
virtual void set_offset(int64_t offset) = 0;
|
|
2007
|
+
|
|
2008
|
+
/** @returns error code (if applicable) */
|
|
2009
|
+
virtual ErrorCode err() const = 0;
|
|
2010
|
+
|
|
2011
|
+
/** @brief Get partition leader epoch, or -1 if not known or relevant. */
|
|
2012
|
+
virtual int32_t get_leader_epoch() = 0;
|
|
2013
|
+
|
|
2014
|
+
/** @brief Set partition leader epoch. */
|
|
2015
|
+
virtual void set_leader_epoch(int32_t leader_epoch) = 0;
|
|
2016
|
+
|
|
2017
|
+
/** @brief Get partition metadata. */
|
|
2018
|
+
virtual std::vector<unsigned char> get_metadata() = 0;
|
|
2019
|
+
|
|
2020
|
+
/** @brief Set partition metadata. */
|
|
2021
|
+
virtual void set_metadata(std::vector<unsigned char> &metadata) = 0;
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2024
|
+
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* @brief Topic handle
|
|
2028
|
+
*
|
|
2029
|
+
*/
|
|
2030
|
+
class RD_EXPORT Topic {
|
|
2031
|
+
public:
|
|
2032
|
+
/**
|
|
2033
|
+
* @brief Unassigned partition.
|
|
2034
|
+
*
|
|
2035
|
+
* The unassigned partition is used by the producer API for messages
|
|
2036
|
+
* that should be partitioned using the configured or default partitioner.
|
|
2037
|
+
*/
|
|
2038
|
+
static const int32_t PARTITION_UA;
|
|
2039
|
+
|
|
2040
|
+
/** @brief Special offsets */
|
|
2041
|
+
static const int64_t OFFSET_BEGINNING; /**< Consume from beginning */
|
|
2042
|
+
static const int64_t OFFSET_END; /**< Consume from end */
|
|
2043
|
+
static const int64_t OFFSET_STORED; /**< Use offset storage */
|
|
2044
|
+
static const int64_t OFFSET_INVALID; /**< Invalid offset */
|
|
2045
|
+
|
|
2046
|
+
|
|
2047
|
+
/**
|
|
2048
|
+
* @brief Creates a new topic handle for topic named \p topic_str
|
|
2049
|
+
*
|
|
2050
|
+
* \p conf is an optional configuration for the topic that will be used
|
|
2051
|
+
* instead of the default topic configuration.
|
|
2052
|
+
* The \p conf object is reusable after this call.
|
|
2053
|
+
*
|
|
2054
|
+
* @returns the new topic handle or NULL on error (see \p errstr).
|
|
2055
|
+
*/
|
|
2056
|
+
static Topic *create(Handle *base,
|
|
2057
|
+
const std::string &topic_str,
|
|
2058
|
+
const Conf *conf,
|
|
2059
|
+
std::string &errstr);
|
|
2060
|
+
|
|
2061
|
+
virtual ~Topic() = 0;
|
|
2062
|
+
|
|
2063
|
+
|
|
2064
|
+
/** @returns the topic name */
|
|
2065
|
+
virtual std::string name() const = 0;
|
|
2066
|
+
|
|
2067
|
+
/**
|
|
2068
|
+
* @returns true if \p partition is available for the topic (has leader).
|
|
2069
|
+
* @warning \b MUST \b ONLY be called from within a
|
|
2070
|
+
* RdKafka::PartitionerCb callback.
|
|
2071
|
+
*/
|
|
2072
|
+
virtual bool partition_available(int32_t partition) const = 0;
|
|
2073
|
+
|
|
2074
|
+
/**
|
|
2075
|
+
* @brief Store offset \p offset + 1 for topic partition \p partition.
|
|
2076
|
+
* The offset will be committed (written) to the broker (or file) according
|
|
2077
|
+
* to \p auto.commit.interval.ms or next manual offset-less commit call.
|
|
2078
|
+
*
|
|
2079
|
+
* @deprecated This API lacks support for partition leader epochs, which makes
|
|
2080
|
+
* it at risk for unclean leader election log truncation issues.
|
|
2081
|
+
* Use KafkaConsumer::offsets_store() or
|
|
2082
|
+
* Message::offset_store() instead.
|
|
2083
|
+
*
|
|
2084
|
+
* @remark \c enable.auto.offset.store must be set to \c false when using
|
|
2085
|
+
* this API.
|
|
2086
|
+
*
|
|
2087
|
+
* @returns RdKafka::ERR_NO_ERROR on success or an error code if none of the
|
|
2088
|
+
* offsets could be stored.
|
|
2089
|
+
*/
|
|
2090
|
+
virtual ErrorCode offset_store(int32_t partition, int64_t offset) = 0;
|
|
2091
|
+
|
|
2092
|
+
/**
|
|
2093
|
+
* @brief Returns the underlying librdkafka C rd_kafka_topic_t handle.
|
|
2094
|
+
*
|
|
2095
|
+
* @warning Calling the C API on this handle is not recommended and there
|
|
2096
|
+
* is no official support for it, but for cases where the C++ API
|
|
2097
|
+
* does not provide the underlying functionality this C handle can be
|
|
2098
|
+
* used to interact directly with the core librdkafka API.
|
|
2099
|
+
*
|
|
2100
|
+
* @remark The lifetime of the returned pointer is the same as the Topic
|
|
2101
|
+
* object this method is called on.
|
|
2102
|
+
*
|
|
2103
|
+
* @remark Include <rdkafka/rdkafka.h> prior to including
|
|
2104
|
+
* <rdkafka/rdkafkacpp.h>
|
|
2105
|
+
*
|
|
2106
|
+
* @returns \c rd_kafka_topic_t*
|
|
2107
|
+
*/
|
|
2108
|
+
virtual struct rd_kafka_topic_s *c_ptr() = 0;
|
|
2109
|
+
};
|
|
2110
|
+
|
|
2111
|
+
|
|
2112
|
+
/**@}*/
|
|
2113
|
+
|
|
2114
|
+
|
|
2115
|
+
/**
|
|
2116
|
+
* @name Message object
|
|
2117
|
+
* @{
|
|
2118
|
+
*
|
|
2119
|
+
*/
|
|
2120
|
+
|
|
2121
|
+
|
|
2122
|
+
/**
|
|
2123
|
+
* @brief Message timestamp object
|
|
2124
|
+
*
|
|
2125
|
+
* Represents the number of milliseconds since the epoch (UTC).
|
|
2126
|
+
*
|
|
2127
|
+
* The MessageTimestampType dictates the timestamp type or origin.
|
|
2128
|
+
*
|
|
2129
|
+
* @remark Requires Apache Kafka broker version >= 0.10.0
|
|
2130
|
+
*
|
|
2131
|
+
*/
|
|
2132
|
+
|
|
2133
|
+
class RD_EXPORT MessageTimestamp {
|
|
2134
|
+
public:
|
|
2135
|
+
/*! Message timestamp type */
|
|
2136
|
+
enum MessageTimestampType {
|
|
2137
|
+
MSG_TIMESTAMP_NOT_AVAILABLE, /**< Timestamp not available */
|
|
2138
|
+
MSG_TIMESTAMP_CREATE_TIME, /**< Message creation time (source) */
|
|
2139
|
+
MSG_TIMESTAMP_LOG_APPEND_TIME /**< Message log append time (broker) */
|
|
2140
|
+
};
|
|
2141
|
+
|
|
2142
|
+
MessageTimestampType type; /**< Timestamp type */
|
|
2143
|
+
int64_t timestamp; /**< Milliseconds since epoch (UTC). */
|
|
2144
|
+
};
|
|
2145
|
+
|
|
2146
|
+
|
|
2147
|
+
/**
|
|
2148
|
+
* @brief Headers object
|
|
2149
|
+
*
|
|
2150
|
+
* Represents message headers.
|
|
2151
|
+
*
|
|
2152
|
+
* https://cwiki.apache.org/confluence/display/KAFKA/KIP-82+-+Add+Record+Headers
|
|
2153
|
+
*
|
|
2154
|
+
* @remark Requires Apache Kafka >= 0.11.0 brokers
|
|
2155
|
+
*/
|
|
2156
|
+
class RD_EXPORT Headers {
|
|
2157
|
+
public:
|
|
2158
|
+
virtual ~Headers() = 0;
|
|
2159
|
+
|
|
2160
|
+
/**
|
|
2161
|
+
* @brief Header object
|
|
2162
|
+
*
|
|
2163
|
+
* This object represents a single Header with a key value pair
|
|
2164
|
+
* and an ErrorCode
|
|
2165
|
+
*
|
|
2166
|
+
* @remark dynamic allocation of this object is not supported.
|
|
2167
|
+
*/
|
|
2168
|
+
class Header {
|
|
2169
|
+
public:
|
|
2170
|
+
/**
|
|
2171
|
+
* @brief Header object to encapsulate a single Header
|
|
2172
|
+
*
|
|
2173
|
+
* @param key the string value for the header key
|
|
2174
|
+
* @param value the bytes of the header value, or NULL
|
|
2175
|
+
* @param value_size the length in bytes of the header value
|
|
2176
|
+
*
|
|
2177
|
+
* @remark key and value are copied.
|
|
2178
|
+
*
|
|
2179
|
+
*/
|
|
2180
|
+
Header(const std::string &key, const void *value, size_t value_size) :
|
|
2181
|
+
key_(key), err_(ERR_NO_ERROR), value_size_(value_size) {
|
|
2182
|
+
value_ = copy_value(value, value_size);
|
|
2183
|
+
}
|
|
2184
|
+
|
|
2185
|
+
/**
|
|
2186
|
+
* @brief Header object to encapsulate a single Header
|
|
2187
|
+
*
|
|
2188
|
+
* @param key the string value for the header key
|
|
2189
|
+
* @param value the bytes of the header value
|
|
2190
|
+
* @param value_size the length in bytes of the header value
|
|
2191
|
+
* @param err the error code if one returned
|
|
2192
|
+
*
|
|
2193
|
+
* @remark The error code is used for when the Header is constructed
|
|
2194
|
+
* internally by using RdKafka::Headers::get_last which constructs
|
|
2195
|
+
* a Header encapsulating the ErrorCode in the process.
|
|
2196
|
+
* If err is set, the value and value_size fields will be undefined.
|
|
2197
|
+
*/
|
|
2198
|
+
Header(const std::string &key,
|
|
2199
|
+
const void *value,
|
|
2200
|
+
size_t value_size,
|
|
2201
|
+
const RdKafka::ErrorCode err) :
|
|
2202
|
+
key_(key), err_(err), value_(NULL), value_size_(value_size) {
|
|
2203
|
+
if (err == ERR_NO_ERROR)
|
|
2204
|
+
value_ = copy_value(value, value_size);
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
/**
|
|
2208
|
+
* @brief Copy constructor
|
|
2209
|
+
*
|
|
2210
|
+
* @param other Header to make a copy of.
|
|
2211
|
+
*/
|
|
2212
|
+
Header(const Header &other) :
|
|
2213
|
+
key_(other.key_), err_(other.err_), value_size_(other.value_size_) {
|
|
2214
|
+
value_ = copy_value(other.value_, value_size_);
|
|
2215
|
+
}
|
|
2216
|
+
|
|
2217
|
+
/**
|
|
2218
|
+
* @brief Assignment operator
|
|
2219
|
+
*
|
|
2220
|
+
* @param other Header to make a copy of.
|
|
2221
|
+
*/
|
|
2222
|
+
Header &operator=(const Header &other) {
|
|
2223
|
+
if (&other == this) {
|
|
2224
|
+
return *this;
|
|
2225
|
+
}
|
|
2226
|
+
|
|
2227
|
+
key_ = other.key_;
|
|
2228
|
+
err_ = other.err_;
|
|
2229
|
+
value_size_ = other.value_size_;
|
|
2230
|
+
|
|
2231
|
+
if (value_ != NULL)
|
|
2232
|
+
mem_free(value_);
|
|
2233
|
+
|
|
2234
|
+
value_ = copy_value(other.value_, value_size_);
|
|
2235
|
+
|
|
2236
|
+
return *this;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
~Header() {
|
|
2240
|
+
if (value_ != NULL)
|
|
2241
|
+
mem_free(value_);
|
|
2242
|
+
}
|
|
2243
|
+
|
|
2244
|
+
/** @returns the key/name associated with this Header */
|
|
2245
|
+
std::string key() const {
|
|
2246
|
+
return key_;
|
|
2247
|
+
}
|
|
2248
|
+
|
|
2249
|
+
/** @returns returns the binary value, or NULL */
|
|
2250
|
+
const void *value() const {
|
|
2251
|
+
return value_;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
/** @returns returns the value casted to a nul-terminated C string,
|
|
2255
|
+
* or NULL. */
|
|
2256
|
+
const char *value_string() const {
|
|
2257
|
+
return static_cast<const char *>(value_);
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/** @returns Value Size the length of the Value in bytes */
|
|
2261
|
+
size_t value_size() const {
|
|
2262
|
+
return value_size_;
|
|
2263
|
+
}
|
|
2264
|
+
|
|
2265
|
+
/** @returns the error code of this Header (usually ERR_NO_ERROR) */
|
|
2266
|
+
RdKafka::ErrorCode err() const {
|
|
2267
|
+
return err_;
|
|
2268
|
+
}
|
|
2269
|
+
|
|
2270
|
+
private:
|
|
2271
|
+
char *copy_value(const void *value, size_t value_size) {
|
|
2272
|
+
if (!value)
|
|
2273
|
+
return NULL;
|
|
2274
|
+
|
|
2275
|
+
char *dest = (char *)mem_malloc(value_size + 1);
|
|
2276
|
+
memcpy(dest, (const char *)value, value_size);
|
|
2277
|
+
dest[value_size] = '\0';
|
|
2278
|
+
|
|
2279
|
+
return dest;
|
|
2280
|
+
}
|
|
2281
|
+
|
|
2282
|
+
std::string key_;
|
|
2283
|
+
RdKafka::ErrorCode err_;
|
|
2284
|
+
char *value_;
|
|
2285
|
+
size_t value_size_;
|
|
2286
|
+
void *operator new(size_t); /* Prevent dynamic allocation */
|
|
2287
|
+
};
|
|
2288
|
+
|
|
2289
|
+
/**
|
|
2290
|
+
* @brief Create a new instance of the Headers object
|
|
2291
|
+
*
|
|
2292
|
+
* @returns an empty Headers list
|
|
2293
|
+
*/
|
|
2294
|
+
static Headers *create();
|
|
2295
|
+
|
|
2296
|
+
/**
|
|
2297
|
+
* @brief Create a new instance of the Headers object from a std::vector
|
|
2298
|
+
*
|
|
2299
|
+
* @param headers std::vector of RdKafka::Headers::Header objects.
|
|
2300
|
+
* The headers are copied, not referenced.
|
|
2301
|
+
*
|
|
2302
|
+
* @returns a Headers list from std::vector set to the size of the std::vector
|
|
2303
|
+
*/
|
|
2304
|
+
static Headers *create(const std::vector<Header> &headers);
|
|
2305
|
+
|
|
2306
|
+
/**
|
|
2307
|
+
* @brief Adds a Header to the end of the list.
|
|
2308
|
+
*
|
|
2309
|
+
* @param key header key/name
|
|
2310
|
+
* @param value binary value, or NULL
|
|
2311
|
+
* @param value_size size of the value
|
|
2312
|
+
*
|
|
2313
|
+
* @returns an ErrorCode signalling success or failure to add the header.
|
|
2314
|
+
*/
|
|
2315
|
+
virtual ErrorCode add(const std::string &key,
|
|
2316
|
+
const void *value,
|
|
2317
|
+
size_t value_size) = 0;
|
|
2318
|
+
|
|
2319
|
+
/**
|
|
2320
|
+
* @brief Adds a Header to the end of the list.
|
|
2321
|
+
*
|
|
2322
|
+
* Convenience method for adding a std::string as a value for the header.
|
|
2323
|
+
*
|
|
2324
|
+
* @param key header key/name
|
|
2325
|
+
* @param value value string
|
|
2326
|
+
*
|
|
2327
|
+
* @returns an ErrorCode signalling success or failure to add the header.
|
|
2328
|
+
*/
|
|
2329
|
+
virtual ErrorCode add(const std::string &key, const std::string &value) = 0;
|
|
2330
|
+
|
|
2331
|
+
/**
|
|
2332
|
+
* @brief Adds a Header to the end of the list.
|
|
2333
|
+
*
|
|
2334
|
+
* This method makes a copy of the passed header.
|
|
2335
|
+
*
|
|
2336
|
+
* @param header Existing header to copy
|
|
2337
|
+
*
|
|
2338
|
+
* @returns an ErrorCode signalling success or failure to add the header.
|
|
2339
|
+
*/
|
|
2340
|
+
virtual ErrorCode add(const Header &header) = 0;
|
|
2341
|
+
|
|
2342
|
+
/**
|
|
2343
|
+
* @brief Removes all the Headers of a given key
|
|
2344
|
+
*
|
|
2345
|
+
* @param key header key/name to remove
|
|
2346
|
+
*
|
|
2347
|
+
* @returns An ErrorCode signalling a success or failure to remove the Header.
|
|
2348
|
+
*/
|
|
2349
|
+
virtual ErrorCode remove(const std::string &key) = 0;
|
|
2350
|
+
|
|
2351
|
+
/**
|
|
2352
|
+
* @brief Gets all of the Headers of a given key
|
|
2353
|
+
*
|
|
2354
|
+
* @param key header key/name
|
|
2355
|
+
*
|
|
2356
|
+
* @remark If duplicate keys exist this will return them all as a std::vector
|
|
2357
|
+
*
|
|
2358
|
+
* @returns a std::vector containing all the Headers of the given key.
|
|
2359
|
+
*/
|
|
2360
|
+
virtual std::vector<Header> get(const std::string &key) const = 0;
|
|
2361
|
+
|
|
2362
|
+
/**
|
|
2363
|
+
* @brief Gets the last occurrence of a Header of a given key
|
|
2364
|
+
*
|
|
2365
|
+
* @param key header key/name
|
|
2366
|
+
*
|
|
2367
|
+
* @remark This will only return the most recently added header
|
|
2368
|
+
*
|
|
2369
|
+
* @returns the Header if found, otherwise a Header with an err set to
|
|
2370
|
+
* ERR__NOENT.
|
|
2371
|
+
*/
|
|
2372
|
+
virtual Header get_last(const std::string &key) const = 0;
|
|
2373
|
+
|
|
2374
|
+
/**
|
|
2375
|
+
* @brief Returns all Headers
|
|
2376
|
+
*
|
|
2377
|
+
* @returns a std::vector containing all of the Headers
|
|
2378
|
+
*/
|
|
2379
|
+
virtual std::vector<Header> get_all() const = 0;
|
|
2380
|
+
|
|
2381
|
+
/**
|
|
2382
|
+
* @returns the number of headers.
|
|
2383
|
+
*/
|
|
2384
|
+
virtual size_t size() const = 0;
|
|
2385
|
+
};
|
|
2386
|
+
|
|
2387
|
+
|
|
2388
|
+
/**
|
|
2389
|
+
* @brief Message object
|
|
2390
|
+
*
|
|
2391
|
+
* This object represents either a single consumed or produced message,
|
|
2392
|
+
* or an event (\p err() is set).
|
|
2393
|
+
*
|
|
2394
|
+
* An application must check RdKafka::Message::err() to see if the
|
|
2395
|
+
* object is a proper message (error is RdKafka::ERR_NO_ERROR) or a
|
|
2396
|
+
* an error event.
|
|
2397
|
+
*
|
|
2398
|
+
*/
|
|
2399
|
+
class RD_EXPORT Message {
|
|
2400
|
+
public:
|
|
2401
|
+
/** @brief Message persistence status can be used by the application to
|
|
2402
|
+
* find out if a produced message was persisted in the topic log. */
|
|
2403
|
+
enum Status {
|
|
2404
|
+
/** Message was never transmitted to the broker, or failed with
|
|
2405
|
+
* an error indicating it was not written to the log.
|
|
2406
|
+
* Application retry risks ordering, but not duplication. */
|
|
2407
|
+
MSG_STATUS_NOT_PERSISTED = 0,
|
|
2408
|
+
|
|
2409
|
+
/** Message was transmitted to broker, but no acknowledgement was
|
|
2410
|
+
* received.
|
|
2411
|
+
* Application retry risks ordering and duplication. */
|
|
2412
|
+
MSG_STATUS_POSSIBLY_PERSISTED = 1,
|
|
2413
|
+
|
|
2414
|
+
/** Message was written to the log and fully acknowledged.
|
|
2415
|
+
* No reason for application to retry.
|
|
2416
|
+
* Note: this value should only be trusted with \c acks=all. */
|
|
2417
|
+
MSG_STATUS_PERSISTED = 2,
|
|
2418
|
+
};
|
|
2419
|
+
|
|
2420
|
+
/**
|
|
2421
|
+
* @brief Accessor functions*
|
|
2422
|
+
* @remark Not all fields are present in all types of callbacks.
|
|
2423
|
+
*/
|
|
2424
|
+
|
|
2425
|
+
/** @returns The error string if object represent an error event,
|
|
2426
|
+
* else an empty string. */
|
|
2427
|
+
virtual std::string errstr() const = 0;
|
|
2428
|
+
|
|
2429
|
+
/** @returns The error code if object represents an error event, else 0. */
|
|
2430
|
+
virtual ErrorCode err() const = 0;
|
|
2431
|
+
|
|
2432
|
+
/** @returns the RdKafka::Topic object for a message (if applicable),
|
|
2433
|
+
* or NULL if a corresponding RdKafka::Topic object has not been
|
|
2434
|
+
* explicitly created with RdKafka::Topic::create().
|
|
2435
|
+
* In this case use topic_name() instead. */
|
|
2436
|
+
virtual Topic *topic() const = 0;
|
|
2437
|
+
|
|
2438
|
+
/** @returns Topic name (if applicable, else empty string) */
|
|
2439
|
+
virtual std::string topic_name() const = 0;
|
|
2440
|
+
|
|
2441
|
+
/** @returns Partition (if applicable) */
|
|
2442
|
+
virtual int32_t partition() const = 0;
|
|
2443
|
+
|
|
2444
|
+
/** @returns Message payload (if applicable) */
|
|
2445
|
+
virtual void *payload() const = 0;
|
|
2446
|
+
|
|
2447
|
+
/** @returns Message payload length (if applicable) */
|
|
2448
|
+
virtual size_t len() const = 0;
|
|
2449
|
+
|
|
2450
|
+
/** @returns Message key as string (if applicable) */
|
|
2451
|
+
virtual const std::string *key() const = 0;
|
|
2452
|
+
|
|
2453
|
+
/** @returns Message key as void pointer (if applicable) */
|
|
2454
|
+
virtual const void *key_pointer() const = 0;
|
|
2455
|
+
|
|
2456
|
+
/** @returns Message key's binary length (if applicable) */
|
|
2457
|
+
virtual size_t key_len() const = 0;
|
|
2458
|
+
|
|
2459
|
+
/** @returns Message or error offset (if applicable) */
|
|
2460
|
+
virtual int64_t offset() const = 0;
|
|
2461
|
+
|
|
2462
|
+
/** @returns Message timestamp (if applicable) */
|
|
2463
|
+
virtual MessageTimestamp timestamp() const = 0;
|
|
2464
|
+
|
|
2465
|
+
/** @returns The \p msg_opaque as provided to RdKafka::Producer::produce() */
|
|
2466
|
+
virtual void *msg_opaque() const = 0;
|
|
2467
|
+
|
|
2468
|
+
virtual ~Message() = 0;
|
|
2469
|
+
|
|
2470
|
+
/** @returns the latency in microseconds for a produced message measured
|
|
2471
|
+
* from the produce() call, or -1 if latency is not available. */
|
|
2472
|
+
virtual int64_t latency() const = 0;
|
|
2473
|
+
|
|
2474
|
+
/**
|
|
2475
|
+
* @brief Returns the underlying librdkafka C rd_kafka_message_t handle.
|
|
2476
|
+
*
|
|
2477
|
+
* @warning Calling the C API on this handle is not recommended and there
|
|
2478
|
+
* is no official support for it, but for cases where the C++ API
|
|
2479
|
+
* does not provide the underlying functionality this C handle can be
|
|
2480
|
+
* used to interact directly with the core librdkafka API.
|
|
2481
|
+
*
|
|
2482
|
+
* @remark The lifetime of the returned pointer is the same as the Message
|
|
2483
|
+
* object this method is called on.
|
|
2484
|
+
*
|
|
2485
|
+
* @remark Include <rdkafka/rdkafka.h> prior to including
|
|
2486
|
+
* <rdkafka/rdkafkacpp.h>
|
|
2487
|
+
*
|
|
2488
|
+
* @returns \c rd_kafka_message_t*
|
|
2489
|
+
*/
|
|
2490
|
+
virtual struct rd_kafka_message_s *c_ptr() = 0;
|
|
2491
|
+
|
|
2492
|
+
/**
|
|
2493
|
+
* @brief Returns the message's persistence status in the topic log.
|
|
2494
|
+
*/
|
|
2495
|
+
virtual Status status() const = 0;
|
|
2496
|
+
|
|
2497
|
+
/** @returns the Headers instance for this Message, or NULL if there
|
|
2498
|
+
* are no headers.
|
|
2499
|
+
*
|
|
2500
|
+
* @remark The lifetime of the Headers are the same as the Message. */
|
|
2501
|
+
virtual RdKafka::Headers *headers() = 0;
|
|
2502
|
+
|
|
2503
|
+
/** @returns the Headers instance for this Message (if applicable).
|
|
2504
|
+
* If NULL is returned the reason is given in \p err, which
|
|
2505
|
+
* is either ERR__NOENT if there were no headers, or another
|
|
2506
|
+
* error code if header parsing failed.
|
|
2507
|
+
*
|
|
2508
|
+
* @remark The lifetime of the Headers are the same as the Message. */
|
|
2509
|
+
virtual RdKafka::Headers *headers(RdKafka::ErrorCode *err) = 0;
|
|
2510
|
+
|
|
2511
|
+
/** @returns the broker id of the broker the message was produced to or
|
|
2512
|
+
* fetched from, or -1 if not known/applicable. */
|
|
2513
|
+
virtual int32_t broker_id() const = 0;
|
|
2514
|
+
|
|
2515
|
+
/** @returns the message's partition leader epoch at the time the message was
|
|
2516
|
+
* fetched and if known, else -1. */
|
|
2517
|
+
virtual int32_t leader_epoch() const = 0;
|
|
2518
|
+
|
|
2519
|
+
/**
|
|
2520
|
+
* @brief Store offset +1 for the consumed message.
|
|
2521
|
+
*
|
|
2522
|
+
* The message offset + 1 will be committed to broker according
|
|
2523
|
+
* to \c `auto.commit.interval.ms` or manual offset-less commit()
|
|
2524
|
+
*
|
|
2525
|
+
* @warning This method may only be called for partitions that are currently
|
|
2526
|
+
* assigned.
|
|
2527
|
+
* Non-assigned partitions will fail with ERR__STATE.
|
|
2528
|
+
*
|
|
2529
|
+
* @warning Avoid storing offsets after calling seek() (et.al) as
|
|
2530
|
+
* this may later interfere with resuming a paused partition, instead
|
|
2531
|
+
* store offsets prior to calling seek.
|
|
2532
|
+
*
|
|
2533
|
+
* @remark \c `enable.auto.offset.store` must be set to "false" when using
|
|
2534
|
+
* this API.
|
|
2535
|
+
*
|
|
2536
|
+
* @returns NULL on success or an error object on failure.
|
|
2537
|
+
*/
|
|
2538
|
+
virtual Error *offset_store() = 0;
|
|
2539
|
+
};
|
|
2540
|
+
|
|
2541
|
+
/**@}*/
|
|
2542
|
+
|
|
2543
|
+
|
|
2544
|
+
/**
|
|
2545
|
+
* @name Queue interface
|
|
2546
|
+
* @{
|
|
2547
|
+
*
|
|
2548
|
+
*/
|
|
2549
|
+
|
|
2550
|
+
|
|
2551
|
+
/**
|
|
2552
|
+
* @brief Queue interface
|
|
2553
|
+
*
|
|
2554
|
+
* Create a new message queue. Message queues allows the application
|
|
2555
|
+
* to re-route consumed messages from multiple topic+partitions into
|
|
2556
|
+
* one single queue point. This queue point, containing messages from
|
|
2557
|
+
* a number of topic+partitions, may then be served by a single
|
|
2558
|
+
* consume() method, rather than one per topic+partition combination.
|
|
2559
|
+
*
|
|
2560
|
+
* See the RdKafka::Consumer::start(), RdKafka::Consumer::consume(), and
|
|
2561
|
+
* RdKafka::Consumer::consume_callback() methods that take a queue as the first
|
|
2562
|
+
* parameter for more information.
|
|
2563
|
+
*/
|
|
2564
|
+
class RD_EXPORT Queue {
|
|
2565
|
+
public:
|
|
2566
|
+
/**
|
|
2567
|
+
* @brief Create Queue object
|
|
2568
|
+
*/
|
|
2569
|
+
static Queue *create(Handle *handle);
|
|
2570
|
+
|
|
2571
|
+
/**
|
|
2572
|
+
* @brief Forward/re-route queue to \p dst.
|
|
2573
|
+
* If \p dst is \c NULL, the forwarding is removed.
|
|
2574
|
+
*
|
|
2575
|
+
* The internal refcounts for both queues are increased.
|
|
2576
|
+
*
|
|
2577
|
+
* @remark Regardless of whether \p dst is NULL or not, after calling this
|
|
2578
|
+
* function, \p src will not forward it's fetch queue to the consumer
|
|
2579
|
+
* queue.
|
|
2580
|
+
*/
|
|
2581
|
+
virtual ErrorCode forward(Queue *dst) = 0;
|
|
2582
|
+
|
|
2583
|
+
|
|
2584
|
+
/**
|
|
2585
|
+
* @brief Consume message or get error event from the queue.
|
|
2586
|
+
*
|
|
2587
|
+
* @remark Use \c delete to free the message.
|
|
2588
|
+
*
|
|
2589
|
+
* @returns One of:
|
|
2590
|
+
* - proper message (RdKafka::Message::err() is ERR_NO_ERROR)
|
|
2591
|
+
* - error event (RdKafka::Message::err() is != ERR_NO_ERROR)
|
|
2592
|
+
* - timeout due to no message or event in \p timeout_ms
|
|
2593
|
+
* (RdKafka::Message::err() is ERR__TIMED_OUT)
|
|
2594
|
+
*/
|
|
2595
|
+
virtual Message *consume(int timeout_ms) = 0;
|
|
2596
|
+
|
|
2597
|
+
/**
|
|
2598
|
+
* @brief Poll queue, serving any enqueued callbacks.
|
|
2599
|
+
*
|
|
2600
|
+
* @remark Must NOT be used for queues containing messages.
|
|
2601
|
+
*
|
|
2602
|
+
* @returns the number of events served or 0 on timeout.
|
|
2603
|
+
*/
|
|
2604
|
+
virtual int poll(int timeout_ms) = 0;
|
|
2605
|
+
|
|
2606
|
+
virtual ~Queue() = 0;
|
|
2607
|
+
|
|
2608
|
+
/**
|
|
2609
|
+
* @brief Enable IO event triggering for queue.
|
|
2610
|
+
*
|
|
2611
|
+
* To ease integration with IO based polling loops this API
|
|
2612
|
+
* allows an application to create a separate file-descriptor
|
|
2613
|
+
* that librdkafka will write \p payload (of size \p size) to
|
|
2614
|
+
* whenever a new element is enqueued on a previously empty queue.
|
|
2615
|
+
*
|
|
2616
|
+
* To remove event triggering call with \p fd = -1.
|
|
2617
|
+
*
|
|
2618
|
+
* librdkafka will maintain a copy of the \p payload.
|
|
2619
|
+
*
|
|
2620
|
+
* @remark When using forwarded queues the IO event must only be enabled
|
|
2621
|
+
* on the final forwarded-to (destination) queue.
|
|
2622
|
+
*/
|
|
2623
|
+
virtual void io_event_enable(int fd, const void *payload, size_t size) = 0;
|
|
2624
|
+
};
|
|
2625
|
+
|
|
2626
|
+
/**@}*/
|
|
2627
|
+
|
|
2628
|
+
/**
|
|
2629
|
+
* @name ConsumerGroupMetadata
|
|
2630
|
+
* @{
|
|
2631
|
+
*
|
|
2632
|
+
*/
|
|
2633
|
+
/**
|
|
2634
|
+
* @brief ConsumerGroupMetadata holds a consumer instance's group
|
|
2635
|
+
* metadata state.
|
|
2636
|
+
*
|
|
2637
|
+
* This class currently does not have any public methods.
|
|
2638
|
+
*/
|
|
2639
|
+
class RD_EXPORT ConsumerGroupMetadata {
|
|
2640
|
+
public:
|
|
2641
|
+
virtual ~ConsumerGroupMetadata() = 0;
|
|
2642
|
+
};
|
|
2643
|
+
|
|
2644
|
+
/**@}*/
|
|
2645
|
+
|
|
2646
|
+
/**
|
|
2647
|
+
* @name KafkaConsumer
|
|
2648
|
+
* @{
|
|
2649
|
+
*
|
|
2650
|
+
*/
|
|
2651
|
+
|
|
2652
|
+
|
|
2653
|
+
/**
|
|
2654
|
+
* @brief High-level KafkaConsumer (for brokers 0.9 and later)
|
|
2655
|
+
*
|
|
2656
|
+
* @remark Requires Apache Kafka >= 0.9.0 brokers
|
|
2657
|
+
*
|
|
2658
|
+
* Currently supports the \c range and \c roundrobin partition assignment
|
|
2659
|
+
* strategies (see \c partition.assignment.strategy)
|
|
2660
|
+
*/
|
|
2661
|
+
class RD_EXPORT KafkaConsumer : public virtual Handle {
|
|
2662
|
+
public:
|
|
2663
|
+
/**
|
|
2664
|
+
* @brief Creates a KafkaConsumer.
|
|
2665
|
+
*
|
|
2666
|
+
* The \p conf object must have \c group.id set to the consumer group to join.
|
|
2667
|
+
*
|
|
2668
|
+
* Use RdKafka::KafkaConsumer::close() to shut down the consumer.
|
|
2669
|
+
*
|
|
2670
|
+
* @sa RdKafka::RebalanceCb
|
|
2671
|
+
* @sa CONFIGURATION.md for \c group.id, \c session.timeout.ms,
|
|
2672
|
+
* \c partition.assignment.strategy, etc.
|
|
2673
|
+
*/
|
|
2674
|
+
static KafkaConsumer *create(const Conf *conf, std::string &errstr);
|
|
2675
|
+
|
|
2676
|
+
virtual ~KafkaConsumer() = 0;
|
|
2677
|
+
|
|
2678
|
+
|
|
2679
|
+
/** @brief Returns the current partition assignment as set by
|
|
2680
|
+
* RdKafka::KafkaConsumer::assign() */
|
|
2681
|
+
virtual ErrorCode assignment(
|
|
2682
|
+
std::vector<RdKafka::TopicPartition *> &partitions) = 0;
|
|
2683
|
+
|
|
2684
|
+
/** @brief Returns the current subscription as set by
|
|
2685
|
+
* RdKafka::KafkaConsumer::subscribe() */
|
|
2686
|
+
virtual ErrorCode subscription(std::vector<std::string> &topics) = 0;
|
|
2687
|
+
|
|
2688
|
+
/**
|
|
2689
|
+
* @brief Update the subscription set to \p topics.
|
|
2690
|
+
*
|
|
2691
|
+
* Any previous subscription will be unassigned and unsubscribed first.
|
|
2692
|
+
*
|
|
2693
|
+
* The subscription set denotes the desired topics to consume and this
|
|
2694
|
+
* set is provided to the partition assignor (one of the elected group
|
|
2695
|
+
* members) for all clients which then uses the configured
|
|
2696
|
+
* \c partition.assignment.strategy to assign the subscription sets's
|
|
2697
|
+
* topics's partitions to the consumers, depending on their subscription.
|
|
2698
|
+
*
|
|
2699
|
+
* The result of such an assignment is a rebalancing which is either
|
|
2700
|
+
* handled automatically in librdkafka or can be overridden by the application
|
|
2701
|
+
* by providing a RdKafka::RebalanceCb.
|
|
2702
|
+
*
|
|
2703
|
+
* The rebalancing passes the assigned partition set to
|
|
2704
|
+
* RdKafka::KafkaConsumer::assign() to update what partitions are actually
|
|
2705
|
+
* being fetched by the KafkaConsumer.
|
|
2706
|
+
*
|
|
2707
|
+
* Regex pattern matching automatically performed for topics prefixed
|
|
2708
|
+
* with \c \"^\" (e.g. \c \"^myPfx[0-9]_.*\"
|
|
2709
|
+
*
|
|
2710
|
+
* @remark A consumer error will be raised for each unavailable topic in the
|
|
2711
|
+
* \p topics. The error will be ERR_UNKNOWN_TOPIC_OR_PART
|
|
2712
|
+
* for non-existent topics, and
|
|
2713
|
+
* ERR_TOPIC_AUTHORIZATION_FAILED for unauthorized topics.
|
|
2714
|
+
* The consumer error will be raised through consume() (et.al.)
|
|
2715
|
+
* with the \c RdKafka::Message::err() returning one of the
|
|
2716
|
+
* error codes mentioned above.
|
|
2717
|
+
* The subscribe function itself is asynchronous and will not return
|
|
2718
|
+
* an error on unavailable topics.
|
|
2719
|
+
*
|
|
2720
|
+
* @returns an error if the provided list of topics is invalid.
|
|
2721
|
+
*/
|
|
2722
|
+
virtual ErrorCode subscribe(const std::vector<std::string> &topics) = 0;
|
|
2723
|
+
|
|
2724
|
+
/** @brief Unsubscribe from the current subscription set. */
|
|
2725
|
+
virtual ErrorCode unsubscribe() = 0;
|
|
2726
|
+
|
|
2727
|
+
/**
|
|
2728
|
+
* @brief Update the assignment set to \p partitions.
|
|
2729
|
+
*
|
|
2730
|
+
* The assignment set is the set of partitions actually being consumed
|
|
2731
|
+
* by the KafkaConsumer.
|
|
2732
|
+
*/
|
|
2733
|
+
virtual ErrorCode assign(const std::vector<TopicPartition *> &partitions) = 0;
|
|
2734
|
+
|
|
2735
|
+
/**
|
|
2736
|
+
* @brief Stop consumption and remove the current assignment.
|
|
2737
|
+
*/
|
|
2738
|
+
virtual ErrorCode unassign() = 0;
|
|
2739
|
+
|
|
2740
|
+
/**
|
|
2741
|
+
* @brief Consume message or get error event, triggers callbacks.
|
|
2742
|
+
*
|
|
2743
|
+
* Will automatically call registered callbacks for any such queued events,
|
|
2744
|
+
* including RdKafka::RebalanceCb, RdKafka::EventCb, RdKafka::OffsetCommitCb,
|
|
2745
|
+
* etc.
|
|
2746
|
+
*
|
|
2747
|
+
* @remark Use \c delete to free the message.
|
|
2748
|
+
*
|
|
2749
|
+
* @remark An application should make sure to call consume() at regular
|
|
2750
|
+
* intervals, even if no messages are expected, to serve any
|
|
2751
|
+
* queued callbacks waiting to be called. This is especially
|
|
2752
|
+
* important when a RebalanceCb has been registered as it needs
|
|
2753
|
+
* to be called and handled properly to synchronize internal
|
|
2754
|
+
* consumer state.
|
|
2755
|
+
*
|
|
2756
|
+
* @remark Application MUST NOT call \p poll() on KafkaConsumer objects.
|
|
2757
|
+
*
|
|
2758
|
+
* @returns One of:
|
|
2759
|
+
* - proper message (RdKafka::Message::err() is ERR_NO_ERROR)
|
|
2760
|
+
* - error event (RdKafka::Message::err() is != ERR_NO_ERROR)
|
|
2761
|
+
* - timeout due to no message or event in \p timeout_ms
|
|
2762
|
+
* (RdKafka::Message::err() is ERR__TIMED_OUT)
|
|
2763
|
+
*/
|
|
2764
|
+
virtual Message *consume(int timeout_ms) = 0;
|
|
2765
|
+
|
|
2766
|
+
/**
|
|
2767
|
+
* @brief Commit offsets for the current assignment.
|
|
2768
|
+
*
|
|
2769
|
+
* @remark This is the synchronous variant that blocks until offsets
|
|
2770
|
+
* are committed or the commit fails (see return value).
|
|
2771
|
+
*
|
|
2772
|
+
* @remark If a RdKafka::OffsetCommitCb callback is registered it will
|
|
2773
|
+
* be called with commit details on a future call to
|
|
2774
|
+
* RdKafka::KafkaConsumer::consume()
|
|
2775
|
+
|
|
2776
|
+
*
|
|
2777
|
+
* @returns ERR_NO_ERROR or error code.
|
|
2778
|
+
*/
|
|
2779
|
+
virtual ErrorCode commitSync() = 0;
|
|
2780
|
+
|
|
2781
|
+
/**
|
|
2782
|
+
* @brief Asynchronous version of RdKafka::KafkaConsumer::CommitSync()
|
|
2783
|
+
*
|
|
2784
|
+
* @sa RdKafka::KafkaConsumer::commitSync()
|
|
2785
|
+
*/
|
|
2786
|
+
virtual ErrorCode commitAsync() = 0;
|
|
2787
|
+
|
|
2788
|
+
/**
|
|
2789
|
+
* @brief Commit offset for a single topic+partition based on \p message
|
|
2790
|
+
*
|
|
2791
|
+
* @remark The offset committed will be the message's offset + 1.
|
|
2792
|
+
*
|
|
2793
|
+
* @remark This is the synchronous variant.
|
|
2794
|
+
*
|
|
2795
|
+
* @sa RdKafka::KafkaConsumer::commitSync()
|
|
2796
|
+
*/
|
|
2797
|
+
virtual ErrorCode commitSync(Message *message) = 0;
|
|
2798
|
+
|
|
2799
|
+
/**
|
|
2800
|
+
* @brief Commit offset for a single topic+partition based on \p message
|
|
2801
|
+
*
|
|
2802
|
+
* @remark The offset committed will be the message's offset + 1.
|
|
2803
|
+
*
|
|
2804
|
+
* @remark This is the asynchronous variant.
|
|
2805
|
+
*
|
|
2806
|
+
* @sa RdKafka::KafkaConsumer::commitSync()
|
|
2807
|
+
*/
|
|
2808
|
+
virtual ErrorCode commitAsync(Message *message) = 0;
|
|
2809
|
+
|
|
2810
|
+
/**
|
|
2811
|
+
* @brief Commit offsets for the provided list of partitions.
|
|
2812
|
+
*
|
|
2813
|
+
* @remark The \c .offset of the partitions in \p offsets should be the
|
|
2814
|
+
* offset where consumption will resume, i.e., the last
|
|
2815
|
+
* processed offset + 1.
|
|
2816
|
+
*
|
|
2817
|
+
* @remark This is the synchronous variant.
|
|
2818
|
+
*/
|
|
2819
|
+
virtual ErrorCode commitSync(std::vector<TopicPartition *> &offsets) = 0;
|
|
2820
|
+
|
|
2821
|
+
/**
|
|
2822
|
+
* @brief Commit offset for the provided list of partitions.
|
|
2823
|
+
*
|
|
2824
|
+
* @remark The \c .offset of the partitions in \p offsets should be the
|
|
2825
|
+
* offset where consumption will resume, i.e., the last
|
|
2826
|
+
* processed offset + 1.
|
|
2827
|
+
*
|
|
2828
|
+
* @remark This is the asynchronous variant.
|
|
2829
|
+
*/
|
|
2830
|
+
virtual ErrorCode commitAsync(
|
|
2831
|
+
const std::vector<TopicPartition *> &offsets) = 0;
|
|
2832
|
+
|
|
2833
|
+
/**
|
|
2834
|
+
* @brief Commit offsets for the current assignment.
|
|
2835
|
+
*
|
|
2836
|
+
* @remark This is the synchronous variant that blocks until offsets
|
|
2837
|
+
* are committed or the commit fails (see return value).
|
|
2838
|
+
*
|
|
2839
|
+
* @remark The provided callback will be called from this function.
|
|
2840
|
+
*
|
|
2841
|
+
* @returns ERR_NO_ERROR or error code.
|
|
2842
|
+
*/
|
|
2843
|
+
virtual ErrorCode commitSync(OffsetCommitCb *offset_commit_cb) = 0;
|
|
2844
|
+
|
|
2845
|
+
/**
|
|
2846
|
+
* @brief Commit offsets for the provided list of partitions.
|
|
2847
|
+
*
|
|
2848
|
+
* @remark This is the synchronous variant that blocks until offsets
|
|
2849
|
+
* are committed or the commit fails (see return value).
|
|
2850
|
+
*
|
|
2851
|
+
* @remark The provided callback will be called from this function.
|
|
2852
|
+
*
|
|
2853
|
+
* @returns ERR_NO_ERROR or error code.
|
|
2854
|
+
*/
|
|
2855
|
+
virtual ErrorCode commitSync(std::vector<TopicPartition *> &offsets,
|
|
2856
|
+
OffsetCommitCb *offset_commit_cb) = 0;
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
|
|
2860
|
+
/**
|
|
2861
|
+
* @brief Retrieve committed offsets for topics+partitions.
|
|
2862
|
+
*
|
|
2863
|
+
* @returns ERR_NO_ERROR on success in which case the
|
|
2864
|
+
* \p offset or \p err field of each \p partitions' element is filled
|
|
2865
|
+
* in with the stored offset, or a partition specific error.
|
|
2866
|
+
* Else returns an error code.
|
|
2867
|
+
*/
|
|
2868
|
+
virtual ErrorCode committed(std::vector<TopicPartition *> &partitions,
|
|
2869
|
+
int timeout_ms) = 0;
|
|
2870
|
+
|
|
2871
|
+
/**
|
|
2872
|
+
* @brief Retrieve current positions (offsets) for topics+partitions.
|
|
2873
|
+
*
|
|
2874
|
+
* @returns ERR_NO_ERROR on success in which case the
|
|
2875
|
+
* \p offset or \p err field of each \p partitions' element is filled
|
|
2876
|
+
* in with the stored offset, or a partition specific error.
|
|
2877
|
+
* Else returns an error code.
|
|
2878
|
+
*/
|
|
2879
|
+
virtual ErrorCode position(std::vector<TopicPartition *> &partitions) = 0;
|
|
2880
|
+
|
|
2881
|
+
|
|
2882
|
+
/**
|
|
2883
|
+
* For pausing and resuming consumption, see
|
|
2884
|
+
* @sa RdKafka::Handle::pause() and RdKafka::Handle::resume()
|
|
2885
|
+
*/
|
|
2886
|
+
|
|
2887
|
+
|
|
2888
|
+
/**
|
|
2889
|
+
* @brief Close and shut down the consumer.
|
|
2890
|
+
*
|
|
2891
|
+
* This call will block until the following operations are finished:
|
|
2892
|
+
* - Trigger a local rebalance to void the current assignment (if any).
|
|
2893
|
+
* - Stop consumption for current assignment (if any).
|
|
2894
|
+
* - Commit offsets (if any).
|
|
2895
|
+
* - Leave group (if applicable).
|
|
2896
|
+
*
|
|
2897
|
+
* The maximum blocking time is roughly limited to session.timeout.ms.
|
|
2898
|
+
*
|
|
2899
|
+
* @remark Callbacks, such as RdKafka::RebalanceCb and
|
|
2900
|
+
* RdKafka::OffsetCommitCb, etc, may be called.
|
|
2901
|
+
*
|
|
2902
|
+
* @remark The consumer object must later be freed with \c delete
|
|
2903
|
+
*/
|
|
2904
|
+
virtual ErrorCode close() = 0;
|
|
2905
|
+
|
|
2906
|
+
|
|
2907
|
+
/**
|
|
2908
|
+
* @brief Seek consumer for topic+partition to offset which is either an
|
|
2909
|
+
* absolute or logical offset.
|
|
2910
|
+
*
|
|
2911
|
+
* If \p timeout_ms is not 0 the call will wait this long for the
|
|
2912
|
+
* seek to be performed. If the timeout is reached the internal state
|
|
2913
|
+
* will be unknown and this function returns `ERR__TIMED_OUT`.
|
|
2914
|
+
* If \p timeout_ms is 0 it will initiate the seek but return
|
|
2915
|
+
* immediately without any error reporting (e.g., async).
|
|
2916
|
+
*
|
|
2917
|
+
* This call triggers a fetch queue barrier flush.
|
|
2918
|
+
*
|
|
2919
|
+
* @remark Consumption for the given partition must have started for the
|
|
2920
|
+
* seek to work. Use assign() to set the starting offset.
|
|
2921
|
+
*
|
|
2922
|
+
* @returns an ErrorCode to indicate success or failure.
|
|
2923
|
+
*/
|
|
2924
|
+
virtual ErrorCode seek(const TopicPartition &partition, int timeout_ms) = 0;
|
|
2925
|
+
|
|
2926
|
+
|
|
2927
|
+
/**
|
|
2928
|
+
* @brief Store offset \p offset for topic partition \p partition.
|
|
2929
|
+
* The offset will be committed (written) to the offset store according
|
|
2930
|
+
* to \p auto.commit.interval.ms or the next manual offset-less commit*()
|
|
2931
|
+
*
|
|
2932
|
+
* Per-partition success/error status propagated through TopicPartition.err()
|
|
2933
|
+
*
|
|
2934
|
+
* @remark The \c .offset field is stored as is, it will NOT be + 1.
|
|
2935
|
+
*
|
|
2936
|
+
* @remark \c enable.auto.offset.store must be set to \c false when using
|
|
2937
|
+
* this API.
|
|
2938
|
+
*
|
|
2939
|
+
* @remark The leader epoch, if set, will be used to fence outdated partition
|
|
2940
|
+
* leaders. See TopicPartition::set_leader_epoch().
|
|
2941
|
+
*
|
|
2942
|
+
* @returns RdKafka::ERR_NO_ERROR on success, or
|
|
2943
|
+
* RdKafka::ERR___UNKNOWN_PARTITION if none of the offsets could
|
|
2944
|
+
* be stored, or
|
|
2945
|
+
* RdKafka::ERR___INVALID_ARG if \c enable.auto.offset.store is true.
|
|
2946
|
+
*/
|
|
2947
|
+
virtual ErrorCode offsets_store(std::vector<TopicPartition *> &offsets) = 0;
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
/**
|
|
2951
|
+
* @returns the current consumer group metadata associated with this consumer,
|
|
2952
|
+
* or NULL if the consumer is configured with a \c group.id.
|
|
2953
|
+
* This metadata object should be passed to the transactional
|
|
2954
|
+
* producer's RdKafka::Producer::send_offsets_to_transaction() API.
|
|
2955
|
+
*
|
|
2956
|
+
* @remark The returned object must be deleted by the application.
|
|
2957
|
+
*
|
|
2958
|
+
* @sa RdKafka::Producer::send_offsets_to_transaction()
|
|
2959
|
+
*/
|
|
2960
|
+
virtual ConsumerGroupMetadata *groupMetadata() = 0;
|
|
2961
|
+
|
|
2962
|
+
|
|
2963
|
+
/** @brief Check whether the consumer considers the current assignment to
|
|
2964
|
+
* have been lost involuntarily. This method is only applicable for
|
|
2965
|
+
* use with a subscribing consumer. Assignments are revoked
|
|
2966
|
+
* immediately when determined to have been lost, so this method is
|
|
2967
|
+
* only useful within a rebalance callback. Partitions that have
|
|
2968
|
+
* been lost may already be owned by other members in the group and
|
|
2969
|
+
* therefore commiting offsets, for example, may fail.
|
|
2970
|
+
*
|
|
2971
|
+
* @remark Calling assign(), incremental_assign() or incremental_unassign()
|
|
2972
|
+
* resets this flag.
|
|
2973
|
+
*
|
|
2974
|
+
* @returns Returns true if the current partition assignment is considered
|
|
2975
|
+
* lost, false otherwise.
|
|
2976
|
+
*/
|
|
2977
|
+
virtual bool assignment_lost() = 0;
|
|
2978
|
+
|
|
2979
|
+
/**
|
|
2980
|
+
* @brief The rebalance protocol currently in use. This will be
|
|
2981
|
+
* "NONE" if the consumer has not (yet) joined a group, else it will
|
|
2982
|
+
* match the rebalance protocol ("EAGER", "COOPERATIVE") of the
|
|
2983
|
+
* configured and selected assignor(s). All configured
|
|
2984
|
+
* assignors must have the same protocol type, meaning
|
|
2985
|
+
* online migration of a consumer group from using one
|
|
2986
|
+
* protocol to another (in particular upgading from EAGER
|
|
2987
|
+
* to COOPERATIVE) without a restart is not currently
|
|
2988
|
+
* supported.
|
|
2989
|
+
*
|
|
2990
|
+
* @returns an empty string on error, or one of
|
|
2991
|
+
* "NONE", "EAGER", "COOPERATIVE" on success.
|
|
2992
|
+
*/
|
|
2993
|
+
|
|
2994
|
+
virtual std::string rebalance_protocol() = 0;
|
|
2995
|
+
|
|
2996
|
+
|
|
2997
|
+
/**
|
|
2998
|
+
* @brief Incrementally add \p partitions to the current assignment.
|
|
2999
|
+
*
|
|
3000
|
+
* If a COOPERATIVE assignor (i.e. incremental rebalancing) is being used,
|
|
3001
|
+
* this method should be used in a rebalance callback to adjust the current
|
|
3002
|
+
* assignment appropriately in the case where the rebalance type is
|
|
3003
|
+
* ERR__ASSIGN_PARTITIONS. The application must pass the partition list
|
|
3004
|
+
* passed to the callback (or a copy of it), even if the list is empty.
|
|
3005
|
+
* This method may also be used outside the context of a rebalance callback.
|
|
3006
|
+
*
|
|
3007
|
+
* @returns NULL on success, or an error object if the operation was
|
|
3008
|
+
* unsuccessful.
|
|
3009
|
+
*
|
|
3010
|
+
* @remark The returned object must be deleted by the application.
|
|
3011
|
+
*/
|
|
3012
|
+
virtual Error *incremental_assign(
|
|
3013
|
+
const std::vector<TopicPartition *> &partitions) = 0;
|
|
3014
|
+
|
|
3015
|
+
|
|
3016
|
+
/**
|
|
3017
|
+
* @brief Incrementally remove \p partitions from the current assignment.
|
|
3018
|
+
*
|
|
3019
|
+
* If a COOPERATIVE assignor (i.e. incremental rebalancing) is being used,
|
|
3020
|
+
* this method should be used in a rebalance callback to adjust the current
|
|
3021
|
+
* assignment appropriately in the case where the rebalance type is
|
|
3022
|
+
* ERR__REVOKE_PARTITIONS. The application must pass the partition list
|
|
3023
|
+
* passed to the callback (or a copy of it), even if the list is empty.
|
|
3024
|
+
* This method may also be used outside the context of a rebalance callback.
|
|
3025
|
+
*
|
|
3026
|
+
* @returns NULL on success, or an error object if the operation was
|
|
3027
|
+
* unsuccessful.
|
|
3028
|
+
*
|
|
3029
|
+
* @remark The returned object must be deleted by the application.
|
|
3030
|
+
*/
|
|
3031
|
+
virtual Error *incremental_unassign(
|
|
3032
|
+
const std::vector<TopicPartition *> &partitions) = 0;
|
|
3033
|
+
|
|
3034
|
+
/**
|
|
3035
|
+
* @brief Close and shut down the consumer.
|
|
3036
|
+
*
|
|
3037
|
+
* Performs the same actions as RdKafka::KafkaConsumer::close() but in a
|
|
3038
|
+
* background thread.
|
|
3039
|
+
*
|
|
3040
|
+
* Rebalance events/callbacks (etc) will be forwarded to the
|
|
3041
|
+
* application-provided \p queue. The application must poll this queue until
|
|
3042
|
+
* RdKafka::KafkaConsumer::closed() returns true.
|
|
3043
|
+
*
|
|
3044
|
+
* @remark Depending on consumer group join state there may or may not be
|
|
3045
|
+
* rebalance events emitted on \p rkqu.
|
|
3046
|
+
*
|
|
3047
|
+
* @returns an error object if the consumer close failed, else NULL.
|
|
3048
|
+
*
|
|
3049
|
+
* @sa RdKafka::KafkaConsumer::closed()
|
|
3050
|
+
*/
|
|
3051
|
+
virtual Error *close(Queue *queue) = 0;
|
|
3052
|
+
|
|
3053
|
+
|
|
3054
|
+
/** @returns true if the consumer is closed, else 0.
|
|
3055
|
+
*
|
|
3056
|
+
* @sa RdKafka::KafkaConsumer::close()
|
|
3057
|
+
*/
|
|
3058
|
+
virtual bool closed() = 0;
|
|
3059
|
+
};
|
|
3060
|
+
|
|
3061
|
+
|
|
3062
|
+
/**@}*/
|
|
3063
|
+
|
|
3064
|
+
|
|
3065
|
+
/**
|
|
3066
|
+
* @name Simple Consumer (legacy)
|
|
3067
|
+
* @{
|
|
3068
|
+
*
|
|
3069
|
+
*/
|
|
3070
|
+
|
|
3071
|
+
/**
|
|
3072
|
+
* @brief Simple Consumer (legacy)
|
|
3073
|
+
*
|
|
3074
|
+
* A simple non-balanced, non-group-aware, consumer.
|
|
3075
|
+
*/
|
|
3076
|
+
class RD_EXPORT Consumer : public virtual Handle {
|
|
3077
|
+
public:
|
|
3078
|
+
/**
|
|
3079
|
+
* @brief Creates a new Kafka consumer handle.
|
|
3080
|
+
*
|
|
3081
|
+
* \p conf is an optional object that will be used instead of the default
|
|
3082
|
+
* configuration.
|
|
3083
|
+
* The \p conf object is reusable after this call.
|
|
3084
|
+
*
|
|
3085
|
+
* @returns the new handle on success or NULL on error in which case
|
|
3086
|
+
* \p errstr is set to a human readable error message.
|
|
3087
|
+
*/
|
|
3088
|
+
static Consumer *create(const Conf *conf, std::string &errstr);
|
|
3089
|
+
|
|
3090
|
+
virtual ~Consumer() = 0;
|
|
3091
|
+
|
|
3092
|
+
|
|
3093
|
+
/**
|
|
3094
|
+
* @brief Start consuming messages for topic and \p partition
|
|
3095
|
+
* at offset \p offset which may either be a proper offset (0..N)
|
|
3096
|
+
* or one of the the special offsets: \p OFFSET_BEGINNING or \p OFFSET_END.
|
|
3097
|
+
*
|
|
3098
|
+
* rdkafka will attempt to keep \p queued.min.messages (config property)
|
|
3099
|
+
* messages in the local queue by repeatedly fetching batches of messages
|
|
3100
|
+
* from the broker until the threshold is reached.
|
|
3101
|
+
*
|
|
3102
|
+
* The application shall use one of the \p ..->consume*() functions
|
|
3103
|
+
* to consume messages from the local queue, each kafka message being
|
|
3104
|
+
* represented as a `RdKafka::Message *` object.
|
|
3105
|
+
*
|
|
3106
|
+
* \p ..->start() must not be called multiple times for the same
|
|
3107
|
+
* topic and partition without stopping consumption first with
|
|
3108
|
+
* \p ..->stop().
|
|
3109
|
+
*
|
|
3110
|
+
* @returns an ErrorCode to indicate success or failure.
|
|
3111
|
+
*/
|
|
3112
|
+
virtual ErrorCode start(Topic *topic, int32_t partition, int64_t offset) = 0;
|
|
3113
|
+
|
|
3114
|
+
/**
|
|
3115
|
+
* @brief Start consuming messages for topic and \p partition on
|
|
3116
|
+
* queue \p queue.
|
|
3117
|
+
*
|
|
3118
|
+
* @sa RdKafka::Consumer::start()
|
|
3119
|
+
*/
|
|
3120
|
+
virtual ErrorCode start(Topic *topic,
|
|
3121
|
+
int32_t partition,
|
|
3122
|
+
int64_t offset,
|
|
3123
|
+
Queue *queue) = 0;
|
|
3124
|
+
|
|
3125
|
+
/**
|
|
3126
|
+
* @brief Stop consuming messages for topic and \p partition, purging
|
|
3127
|
+
* all messages currently in the local queue.
|
|
3128
|
+
*
|
|
3129
|
+
* The application needs to be stop all consumers before destroying
|
|
3130
|
+
* the Consumer handle.
|
|
3131
|
+
*
|
|
3132
|
+
* @returns an ErrorCode to indicate success or failure.
|
|
3133
|
+
*/
|
|
3134
|
+
virtual ErrorCode stop(Topic *topic, int32_t partition) = 0;
|
|
3135
|
+
|
|
3136
|
+
/**
|
|
3137
|
+
* @brief Seek consumer for topic+partition to \p offset which is either an
|
|
3138
|
+
* absolute or logical offset.
|
|
3139
|
+
*
|
|
3140
|
+
* If \p timeout_ms is not 0 the call will wait this long for the
|
|
3141
|
+
* seek to be performed. If the timeout is reached the internal state
|
|
3142
|
+
* will be unknown and this function returns `ERR__TIMED_OUT`.
|
|
3143
|
+
* If \p timeout_ms is 0 it will initiate the seek but return
|
|
3144
|
+
* immediately without any error reporting (e.g., async).
|
|
3145
|
+
*
|
|
3146
|
+
* This call triggers a fetch queue barrier flush.
|
|
3147
|
+
*
|
|
3148
|
+
* @returns an ErrorCode to indicate success or failure.
|
|
3149
|
+
*/
|
|
3150
|
+
virtual ErrorCode seek(Topic *topic,
|
|
3151
|
+
int32_t partition,
|
|
3152
|
+
int64_t offset,
|
|
3153
|
+
int timeout_ms) = 0;
|
|
3154
|
+
|
|
3155
|
+
/**
|
|
3156
|
+
* @brief Consume a single message from \p topic and \p partition.
|
|
3157
|
+
*
|
|
3158
|
+
* \p timeout_ms is maximum amount of time to wait for a message to be
|
|
3159
|
+
* received.
|
|
3160
|
+
* Consumer must have been previously started with \p ..->start().
|
|
3161
|
+
*
|
|
3162
|
+
* @returns a Message object, the application needs to check if message
|
|
3163
|
+
* is an error or a proper message RdKafka::Message::err() and checking for
|
|
3164
|
+
* \p ERR_NO_ERROR.
|
|
3165
|
+
*
|
|
3166
|
+
* The message object must be destroyed when the application is done with it.
|
|
3167
|
+
*
|
|
3168
|
+
* Errors (in RdKafka::Message::err()):
|
|
3169
|
+
* - ERR__TIMED_OUT - \p timeout_ms was reached with no new messages fetched.
|
|
3170
|
+
* - ERR__PARTITION_EOF - End of partition reached, not an error.
|
|
3171
|
+
*/
|
|
3172
|
+
virtual Message *consume(Topic *topic, int32_t partition, int timeout_ms) = 0;
|
|
3173
|
+
|
|
3174
|
+
/**
|
|
3175
|
+
* @brief Consume a single message from the specified queue.
|
|
3176
|
+
*
|
|
3177
|
+
* \p timeout_ms is maximum amount of time to wait for a message to be
|
|
3178
|
+
* received.
|
|
3179
|
+
* Consumer must have been previously started on the queue with
|
|
3180
|
+
* \p ..->start().
|
|
3181
|
+
*
|
|
3182
|
+
* @returns a Message object, the application needs to check if message
|
|
3183
|
+
* is an error or a proper message \p Message->err() and checking for
|
|
3184
|
+
* \p ERR_NO_ERROR.
|
|
3185
|
+
*
|
|
3186
|
+
* The message object must be destroyed when the application is done with it.
|
|
3187
|
+
*
|
|
3188
|
+
* Errors (in RdKafka::Message::err()):
|
|
3189
|
+
* - ERR__TIMED_OUT - \p timeout_ms was reached with no new messages fetched
|
|
3190
|
+
*
|
|
3191
|
+
* Note that Message->topic() may be nullptr after certain kinds of
|
|
3192
|
+
* errors, so applications should check that it isn't null before
|
|
3193
|
+
* dereferencing it.
|
|
3194
|
+
*/
|
|
3195
|
+
virtual Message *consume(Queue *queue, int timeout_ms) = 0;
|
|
3196
|
+
|
|
3197
|
+
/**
|
|
3198
|
+
* @brief Consumes messages from \p topic and \p partition, calling
|
|
3199
|
+
* the provided callback for each consumed messsage.
|
|
3200
|
+
*
|
|
3201
|
+
* \p consume_callback() provides higher throughput performance
|
|
3202
|
+
* than \p consume().
|
|
3203
|
+
*
|
|
3204
|
+
* \p timeout_ms is the maximum amount of time to wait for one or
|
|
3205
|
+
* more messages to arrive.
|
|
3206
|
+
*
|
|
3207
|
+
* The provided \p consume_cb instance has its \p consume_cb function
|
|
3208
|
+
* called for every message received.
|
|
3209
|
+
*
|
|
3210
|
+
* The \p opaque argument is passed to the \p consume_cb as \p opaque.
|
|
3211
|
+
*
|
|
3212
|
+
* @returns the number of messages processed or -1 on error.
|
|
3213
|
+
*
|
|
3214
|
+
* @sa RdKafka::Consumer::consume()
|
|
3215
|
+
*/
|
|
3216
|
+
virtual int consume_callback(Topic *topic,
|
|
3217
|
+
int32_t partition,
|
|
3218
|
+
int timeout_ms,
|
|
3219
|
+
ConsumeCb *consume_cb,
|
|
3220
|
+
void *opaque) = 0;
|
|
3221
|
+
|
|
3222
|
+
/**
|
|
3223
|
+
* @brief Consumes messages from \p queue, calling the provided callback for
|
|
3224
|
+
* each consumed messsage.
|
|
3225
|
+
*
|
|
3226
|
+
* @sa RdKafka::Consumer::consume_callback()
|
|
3227
|
+
*/
|
|
3228
|
+
virtual int consume_callback(Queue *queue,
|
|
3229
|
+
int timeout_ms,
|
|
3230
|
+
RdKafka::ConsumeCb *consume_cb,
|
|
3231
|
+
void *opaque) = 0;
|
|
3232
|
+
|
|
3233
|
+
/**
|
|
3234
|
+
* @brief Converts an offset into the logical offset from the tail of a topic.
|
|
3235
|
+
*
|
|
3236
|
+
* \p offset is the (positive) number of items from the end.
|
|
3237
|
+
*
|
|
3238
|
+
* @returns the logical offset for message \p offset from the tail, this value
|
|
3239
|
+
* may be passed to Consumer::start, et.al.
|
|
3240
|
+
* @remark The returned logical offset is specific to librdkafka.
|
|
3241
|
+
*/
|
|
3242
|
+
static int64_t OffsetTail(int64_t offset);
|
|
3243
|
+
};
|
|
3244
|
+
|
|
3245
|
+
/**@}*/
|
|
3246
|
+
|
|
3247
|
+
|
|
3248
|
+
/**
|
|
3249
|
+
* @name Producer
|
|
3250
|
+
* @{
|
|
3251
|
+
*
|
|
3252
|
+
*/
|
|
3253
|
+
|
|
3254
|
+
|
|
3255
|
+
/**
|
|
3256
|
+
* @brief Producer
|
|
3257
|
+
*/
|
|
3258
|
+
class RD_EXPORT Producer : public virtual Handle {
|
|
3259
|
+
public:
|
|
3260
|
+
/**
|
|
3261
|
+
* @brief Creates a new Kafka producer handle.
|
|
3262
|
+
*
|
|
3263
|
+
* \p conf is an optional object that will be used instead of the default
|
|
3264
|
+
* configuration.
|
|
3265
|
+
* The \p conf object is reusable after this call.
|
|
3266
|
+
*
|
|
3267
|
+
* @returns the new handle on success or NULL on error in which case
|
|
3268
|
+
* \p errstr is set to a human readable error message.
|
|
3269
|
+
*/
|
|
3270
|
+
static Producer *create(const Conf *conf, std::string &errstr);
|
|
3271
|
+
|
|
3272
|
+
|
|
3273
|
+
virtual ~Producer() = 0;
|
|
3274
|
+
|
|
3275
|
+
/**
|
|
3276
|
+
* @brief RdKafka::Producer::produce() \p msgflags
|
|
3277
|
+
*
|
|
3278
|
+
* These flags are optional.
|
|
3279
|
+
*/
|
|
3280
|
+
enum {
|
|
3281
|
+
RK_MSG_FREE = 0x1, /**< rdkafka will free(3) \p payload
|
|
3282
|
+
* when it is done with it.
|
|
3283
|
+
* Mutually exclusive with RK_MSG_COPY. */
|
|
3284
|
+
RK_MSG_COPY = 0x2, /**< the \p payload data will be copied
|
|
3285
|
+
* and the \p payload pointer will not
|
|
3286
|
+
* be used by rdkafka after the
|
|
3287
|
+
* call returns.
|
|
3288
|
+
* Mutually exclusive with RK_MSG_FREE. */
|
|
3289
|
+
RK_MSG_BLOCK = 0x4 /**< Block produce*() on message queue
|
|
3290
|
+
* full.
|
|
3291
|
+
* WARNING:
|
|
3292
|
+
* If a delivery report callback
|
|
3293
|
+
* is used the application MUST
|
|
3294
|
+
* call rd_kafka_poll() (or equiv.)
|
|
3295
|
+
* to make sure delivered messages
|
|
3296
|
+
* are drained from the internal
|
|
3297
|
+
* delivery report queue.
|
|
3298
|
+
* Failure to do so will result
|
|
3299
|
+
* in indefinately blocking on
|
|
3300
|
+
* the produce() call when the
|
|
3301
|
+
* message queue is full.
|
|
3302
|
+
*/
|
|
3303
|
+
|
|
3304
|
+
|
|
3305
|
+
/**@cond NO_DOC*/
|
|
3306
|
+
/* For backwards compatibility: */
|
|
3307
|
+
#ifndef MSG_COPY /* defined in sys/msg.h */
|
|
3308
|
+
, /** this comma must exist betwen
|
|
3309
|
+
* RK_MSG_BLOCK and MSG_FREE
|
|
3310
|
+
*/
|
|
3311
|
+
MSG_FREE = RK_MSG_FREE,
|
|
3312
|
+
MSG_COPY = RK_MSG_COPY
|
|
3313
|
+
#endif
|
|
3314
|
+
/**@endcond*/
|
|
3315
|
+
};
|
|
3316
|
+
|
|
3317
|
+
/**
|
|
3318
|
+
* @brief Produce and send a single message to broker.
|
|
3319
|
+
*
|
|
3320
|
+
* This is an asynch non-blocking API.
|
|
3321
|
+
*
|
|
3322
|
+
* \p partition is the target partition, either:
|
|
3323
|
+
* - RdKafka::Topic::PARTITION_UA (unassigned) for
|
|
3324
|
+
* automatic partitioning using the topic's partitioner function, or
|
|
3325
|
+
* - a fixed partition (0..N)
|
|
3326
|
+
*
|
|
3327
|
+
* \p msgflags is zero or more of the following flags OR:ed together:
|
|
3328
|
+
* RK_MSG_BLOCK - block \p produce*() call if
|
|
3329
|
+
* \p queue.buffering.max.messages or
|
|
3330
|
+
* \p queue.buffering.max.kbytes are exceeded.
|
|
3331
|
+
* Messages are considered in-queue from the point they
|
|
3332
|
+
* are accepted by produce() until their corresponding
|
|
3333
|
+
* delivery report callback/event returns.
|
|
3334
|
+
* It is thus a requirement to call
|
|
3335
|
+
* poll() (or equiv.) from a separate
|
|
3336
|
+
* thread when RK_MSG_BLOCK is used.
|
|
3337
|
+
* See WARNING on \c RK_MSG_BLOCK above.
|
|
3338
|
+
* RK_MSG_FREE - rdkafka will free(3) \p payload when it is done with it.
|
|
3339
|
+
* RK_MSG_COPY - the \p payload data will be copied and the \p payload
|
|
3340
|
+
* pointer will not be used by rdkafka after the
|
|
3341
|
+
* call returns.
|
|
3342
|
+
*
|
|
3343
|
+
* NOTE: RK_MSG_FREE and RK_MSG_COPY are mutually exclusive.
|
|
3344
|
+
*
|
|
3345
|
+
* If the function returns an error code and RK_MSG_FREE was specified, then
|
|
3346
|
+
* the memory associated with the payload is still the caller's
|
|
3347
|
+
* responsibility.
|
|
3348
|
+
*
|
|
3349
|
+
* \p payload is the message payload of size \p len bytes.
|
|
3350
|
+
*
|
|
3351
|
+
* \p key is an optional message key, if non-NULL it
|
|
3352
|
+
* will be passed to the topic partitioner as well as be sent with the
|
|
3353
|
+
* message to the broker and passed on to the consumer.
|
|
3354
|
+
*
|
|
3355
|
+
* \p msg_opaque is an optional application-provided per-message opaque
|
|
3356
|
+
* pointer that will provided in the delivery report callback (\p dr_cb) for
|
|
3357
|
+
* referencing this message.
|
|
3358
|
+
*
|
|
3359
|
+
* @returns an ErrorCode to indicate success or failure:
|
|
3360
|
+
* - ERR_NO_ERROR - message successfully enqueued for transmission.
|
|
3361
|
+
*
|
|
3362
|
+
* - ERR__QUEUE_FULL - maximum number of outstanding messages has been
|
|
3363
|
+
* reached: \c queue.buffering.max.message
|
|
3364
|
+
*
|
|
3365
|
+
* - ERR_MSG_SIZE_TOO_LARGE - message is larger than configured max size:
|
|
3366
|
+
* \c messages.max.bytes
|
|
3367
|
+
*
|
|
3368
|
+
* - ERR__UNKNOWN_PARTITION - requested \p partition is unknown in the
|
|
3369
|
+
* Kafka cluster.
|
|
3370
|
+
*
|
|
3371
|
+
* - ERR__UNKNOWN_TOPIC - topic is unknown in the Kafka cluster.
|
|
3372
|
+
*/
|
|
3373
|
+
virtual ErrorCode produce(Topic *topic,
|
|
3374
|
+
int32_t partition,
|
|
3375
|
+
int msgflags,
|
|
3376
|
+
void *payload,
|
|
3377
|
+
size_t len,
|
|
3378
|
+
const std::string *key,
|
|
3379
|
+
void *msg_opaque) = 0;
|
|
3380
|
+
|
|
3381
|
+
/**
|
|
3382
|
+
* @brief Variant produce() that passes the key as a pointer and length
|
|
3383
|
+
* instead of as a const std::string *.
|
|
3384
|
+
*/
|
|
3385
|
+
virtual ErrorCode produce(Topic *topic,
|
|
3386
|
+
int32_t partition,
|
|
3387
|
+
int msgflags,
|
|
3388
|
+
void *payload,
|
|
3389
|
+
size_t len,
|
|
3390
|
+
const void *key,
|
|
3391
|
+
size_t key_len,
|
|
3392
|
+
void *msg_opaque) = 0;
|
|
3393
|
+
|
|
3394
|
+
/**
|
|
3395
|
+
* @brief produce() variant that takes topic as a string (no need for
|
|
3396
|
+
* creating a Topic object), and also allows providing the
|
|
3397
|
+
* message timestamp (milliseconds since beginning of epoch, UTC).
|
|
3398
|
+
* Otherwise identical to produce() above.
|
|
3399
|
+
*/
|
|
3400
|
+
virtual ErrorCode produce(const std::string topic_name,
|
|
3401
|
+
int32_t partition,
|
|
3402
|
+
int msgflags,
|
|
3403
|
+
void *payload,
|
|
3404
|
+
size_t len,
|
|
3405
|
+
const void *key,
|
|
3406
|
+
size_t key_len,
|
|
3407
|
+
int64_t timestamp,
|
|
3408
|
+
void *msg_opaque) = 0;
|
|
3409
|
+
|
|
3410
|
+
/**
|
|
3411
|
+
* @brief produce() variant that that allows for Header support on produce
|
|
3412
|
+
* Otherwise identical to produce() above.
|
|
3413
|
+
*
|
|
3414
|
+
* @warning The \p headers will be freed/deleted if the produce() call
|
|
3415
|
+
* succeeds, or left untouched if produce() fails.
|
|
3416
|
+
*/
|
|
3417
|
+
virtual ErrorCode produce(const std::string topic_name,
|
|
3418
|
+
int32_t partition,
|
|
3419
|
+
int msgflags,
|
|
3420
|
+
void *payload,
|
|
3421
|
+
size_t len,
|
|
3422
|
+
const void *key,
|
|
3423
|
+
size_t key_len,
|
|
3424
|
+
int64_t timestamp,
|
|
3425
|
+
RdKafka::Headers *headers,
|
|
3426
|
+
void *msg_opaque) = 0;
|
|
3427
|
+
|
|
3428
|
+
|
|
3429
|
+
/**
|
|
3430
|
+
* @brief Variant produce() that accepts vectors for key and payload.
|
|
3431
|
+
* The vector data will be copied.
|
|
3432
|
+
*/
|
|
3433
|
+
virtual ErrorCode produce(Topic *topic,
|
|
3434
|
+
int32_t partition,
|
|
3435
|
+
const std::vector<char> *payload,
|
|
3436
|
+
const std::vector<char> *key,
|
|
3437
|
+
void *msg_opaque) = 0;
|
|
3438
|
+
|
|
3439
|
+
|
|
3440
|
+
/**
|
|
3441
|
+
* @brief Wait until all outstanding produce requests, et.al, are completed.
|
|
3442
|
+
* This should typically be done prior to destroying a producer
|
|
3443
|
+
* instance to make sure all queued and in-flight produce requests are
|
|
3444
|
+
* completed before terminating.
|
|
3445
|
+
*
|
|
3446
|
+
* @remark The \c linger.ms time will be ignored for the duration of the call,
|
|
3447
|
+
* queued messages will be sent to the broker as soon as possible.
|
|
3448
|
+
*
|
|
3449
|
+
* @remark This function will call Producer::poll() and thus
|
|
3450
|
+
* trigger callbacks.
|
|
3451
|
+
*
|
|
3452
|
+
* @returns ERR__TIMED_OUT if \p timeout_ms was reached before all
|
|
3453
|
+
* outstanding requests were completed, else ERR_NO_ERROR
|
|
3454
|
+
*/
|
|
3455
|
+
virtual ErrorCode flush(int timeout_ms) = 0;
|
|
3456
|
+
|
|
3457
|
+
|
|
3458
|
+
/**
|
|
3459
|
+
* @brief Purge messages currently handled by the producer instance.
|
|
3460
|
+
*
|
|
3461
|
+
* @param purge_flags tells which messages should be purged and how.
|
|
3462
|
+
*
|
|
3463
|
+
* The application will need to call Handle::poll() or Producer::flush()
|
|
3464
|
+
* afterwards to serve the delivery report callbacks of the purged messages.
|
|
3465
|
+
*
|
|
3466
|
+
* Messages purged from internal queues fail with the delivery report
|
|
3467
|
+
* error code set to ERR__PURGE_QUEUE, while purged messages that
|
|
3468
|
+
* are in-flight to or from the broker will fail with the error code set to
|
|
3469
|
+
* ERR__PURGE_INFLIGHT.
|
|
3470
|
+
*
|
|
3471
|
+
* @warning Purging messages that are in-flight to or from the broker
|
|
3472
|
+
* will ignore any sub-sequent acknowledgement for these messages
|
|
3473
|
+
* received from the broker, effectively making it impossible
|
|
3474
|
+
* for the application to know if the messages were successfully
|
|
3475
|
+
* produced or not. This may result in duplicate messages if the
|
|
3476
|
+
* application retries these messages at a later time.
|
|
3477
|
+
*
|
|
3478
|
+
* @remark This call may block for a short time while background thread
|
|
3479
|
+
* queues are purged.
|
|
3480
|
+
*
|
|
3481
|
+
* @returns ERR_NO_ERROR on success,
|
|
3482
|
+
* ERR__INVALID_ARG if the \p purge flags are invalid or unknown,
|
|
3483
|
+
* ERR__NOT_IMPLEMENTED if called on a non-producer client instance.
|
|
3484
|
+
*/
|
|
3485
|
+
virtual ErrorCode purge(int purge_flags) = 0;
|
|
3486
|
+
|
|
3487
|
+
/**
|
|
3488
|
+
* @brief RdKafka::Handle::purge() \p purge_flags
|
|
3489
|
+
*/
|
|
3490
|
+
enum {
|
|
3491
|
+
PURGE_QUEUE = 0x1, /**< Purge messages in internal queues */
|
|
3492
|
+
|
|
3493
|
+
PURGE_INFLIGHT = 0x2, /*! Purge messages in-flight to or from the broker.
|
|
3494
|
+
* Purging these messages will void any future
|
|
3495
|
+
* acknowledgements from the broker, making it
|
|
3496
|
+
* impossible for the application to know if these
|
|
3497
|
+
* messages were successfully delivered or not.
|
|
3498
|
+
* Retrying these messages may lead to duplicates. */
|
|
3499
|
+
|
|
3500
|
+
PURGE_NON_BLOCKING = 0x4 /* Don't wait for background queue
|
|
3501
|
+
* purging to finish. */
|
|
3502
|
+
};
|
|
3503
|
+
|
|
3504
|
+
/**
|
|
3505
|
+
* @name Transactional API
|
|
3506
|
+
* @{
|
|
3507
|
+
*
|
|
3508
|
+
* Requires Kafka broker version v0.11.0 or later
|
|
3509
|
+
*
|
|
3510
|
+
* See the Transactional API documentation in rdkafka.h for more information.
|
|
3511
|
+
*/
|
|
3512
|
+
|
|
3513
|
+
/**
|
|
3514
|
+
* @brief Initialize transactions for the producer instance.
|
|
3515
|
+
*
|
|
3516
|
+
* @param timeout_ms The maximum time to block. On timeout the operation
|
|
3517
|
+
* may continue in the background, depending on state,
|
|
3518
|
+
* and it is okay to call init_transactions() again.
|
|
3519
|
+
*
|
|
3520
|
+
* @returns an RdKafka::Error object on error, or NULL on success.
|
|
3521
|
+
* Check whether the returned error object permits retrying
|
|
3522
|
+
* by calling RdKafka::Error::is_retriable(), or whether a fatal
|
|
3523
|
+
* error has been raised by calling RdKafka::Error::is_fatal().
|
|
3524
|
+
*
|
|
3525
|
+
* @remark The returned error object (if not NULL) must be deleted.
|
|
3526
|
+
*
|
|
3527
|
+
* See rd_kafka_init_transactions() in rdkafka.h for more information.
|
|
3528
|
+
*
|
|
3529
|
+
*/
|
|
3530
|
+
virtual Error *init_transactions(int timeout_ms) = 0;
|
|
3531
|
+
|
|
3532
|
+
|
|
3533
|
+
/**
|
|
3534
|
+
* @brief init_transactions() must have been called successfully
|
|
3535
|
+
* (once) before this function is called.
|
|
3536
|
+
*
|
|
3537
|
+
* @returns an RdKafka::Error object on error, or NULL on success.
|
|
3538
|
+
* Check whether a fatal error has been raised by calling
|
|
3539
|
+
* RdKafka::Error::is_fatal_error().
|
|
3540
|
+
*
|
|
3541
|
+
* @remark The returned error object (if not NULL) must be deleted.
|
|
3542
|
+
*
|
|
3543
|
+
* See rd_kafka_begin_transaction() in rdkafka.h for more information.
|
|
3544
|
+
*/
|
|
3545
|
+
virtual Error *begin_transaction() = 0;
|
|
3546
|
+
|
|
3547
|
+
/**
|
|
3548
|
+
* @brief Sends a list of topic partition offsets to the consumer group
|
|
3549
|
+
* coordinator for \p group_metadata, and marks the offsets as part
|
|
3550
|
+
* part of the current transaction.
|
|
3551
|
+
* These offsets will be considered committed only if the transaction
|
|
3552
|
+
* is committed successfully.
|
|
3553
|
+
*
|
|
3554
|
+
* The offsets should be the next message your application will
|
|
3555
|
+
* consume,
|
|
3556
|
+
* i.e., the last processed message's offset + 1 for each partition.
|
|
3557
|
+
* Either track the offsets manually during processing or use
|
|
3558
|
+
* RdKafka::KafkaConsumer::position() (on the consumer) to get the
|
|
3559
|
+
* current offsets for
|
|
3560
|
+
* the partitions assigned to the consumer.
|
|
3561
|
+
*
|
|
3562
|
+
* Use this method at the end of a consume-transform-produce loop prior
|
|
3563
|
+
* to committing the transaction with commit_transaction().
|
|
3564
|
+
*
|
|
3565
|
+
* @param offsets List of offsets to commit to the consumer group upon
|
|
3566
|
+
* successful commit of the transaction. Offsets should be
|
|
3567
|
+
* the next message to consume,
|
|
3568
|
+
* e.g., last processed message + 1.
|
|
3569
|
+
* @param group_metadata The current consumer group metadata as returned by
|
|
3570
|
+
* RdKafka::KafkaConsumer::groupMetadata() on the consumer
|
|
3571
|
+
* instance the provided offsets were consumed from.
|
|
3572
|
+
* @param timeout_ms Maximum time allowed to register the
|
|
3573
|
+
* offsets on the broker.
|
|
3574
|
+
*
|
|
3575
|
+
* @remark This function must be called on the transactional producer
|
|
3576
|
+
* instance, not the consumer.
|
|
3577
|
+
*
|
|
3578
|
+
* @remark The consumer must disable auto commits
|
|
3579
|
+
* (set \c enable.auto.commit to false on the consumer).
|
|
3580
|
+
*
|
|
3581
|
+
* @returns an RdKafka::Error object on error, or NULL on success.
|
|
3582
|
+
* Check whether the returned error object permits retrying
|
|
3583
|
+
* by calling RdKafka::Error::is_retriable(), or whether an abortable
|
|
3584
|
+
* or fatal error has been raised by calling
|
|
3585
|
+
* RdKafka::Error::txn_requires_abort() or RdKafka::Error::is_fatal()
|
|
3586
|
+
* respectively.
|
|
3587
|
+
*
|
|
3588
|
+
* @remark The returned error object (if not NULL) must be deleted.
|
|
3589
|
+
*
|
|
3590
|
+
* See rd_kafka_send_offsets_to_transaction() in rdkafka.h for
|
|
3591
|
+
* more information.
|
|
3592
|
+
*/
|
|
3593
|
+
virtual Error *send_offsets_to_transaction(
|
|
3594
|
+
const std::vector<TopicPartition *> &offsets,
|
|
3595
|
+
const ConsumerGroupMetadata *group_metadata,
|
|
3596
|
+
int timeout_ms) = 0;
|
|
3597
|
+
|
|
3598
|
+
/**
|
|
3599
|
+
* @brief Commit the current transaction as started with begin_transaction().
|
|
3600
|
+
*
|
|
3601
|
+
* Any outstanding messages will be flushed (delivered) before actually
|
|
3602
|
+
* committing the transaction.
|
|
3603
|
+
*
|
|
3604
|
+
* @param timeout_ms The maximum time to block. On timeout the operation
|
|
3605
|
+
* may continue in the background, depending on state,
|
|
3606
|
+
* and it is okay to call this function again.
|
|
3607
|
+
* Pass -1 to use the remaining transaction timeout,
|
|
3608
|
+
* this is the recommended use.
|
|
3609
|
+
*
|
|
3610
|
+
* @remark It is strongly recommended to always pass -1 (remaining transaction
|
|
3611
|
+
* time) as the \p timeout_ms. Using other values risk internal
|
|
3612
|
+
* state desynchronization in case any of the underlying protocol
|
|
3613
|
+
* requests fail.
|
|
3614
|
+
*
|
|
3615
|
+
* @returns an RdKafka::Error object on error, or NULL on success.
|
|
3616
|
+
* Check whether the returned error object permits retrying
|
|
3617
|
+
* by calling RdKafka::Error::is_retriable(), or whether an abortable
|
|
3618
|
+
* or fatal error has been raised by calling
|
|
3619
|
+
* RdKafka::Error::txn_requires_abort() or RdKafka::Error::is_fatal()
|
|
3620
|
+
* respectively.
|
|
3621
|
+
*
|
|
3622
|
+
* @remark The returned error object (if not NULL) must be deleted.
|
|
3623
|
+
*
|
|
3624
|
+
* See rd_kafka_commit_transaction() in rdkafka.h for more information.
|
|
3625
|
+
*/
|
|
3626
|
+
virtual Error *commit_transaction(int timeout_ms) = 0;
|
|
3627
|
+
|
|
3628
|
+
/**
|
|
3629
|
+
* @brief Aborts the ongoing transaction.
|
|
3630
|
+
*
|
|
3631
|
+
* This function should also be used to recover from non-fatal
|
|
3632
|
+
* abortable transaction errors.
|
|
3633
|
+
*
|
|
3634
|
+
* Any outstanding messages will be purged and fail with
|
|
3635
|
+
* RdKafka::ERR__PURGE_INFLIGHT or RdKafka::ERR__PURGE_QUEUE.
|
|
3636
|
+
* See RdKafka::Producer::purge() for details.
|
|
3637
|
+
*
|
|
3638
|
+
* @param timeout_ms The maximum time to block. On timeout the operation
|
|
3639
|
+
* may continue in the background, depending on state,
|
|
3640
|
+
* and it is okay to call this function again.
|
|
3641
|
+
* Pass -1 to use the remaining transaction timeout,
|
|
3642
|
+
* this is the recommended use.
|
|
3643
|
+
*
|
|
3644
|
+
* @remark It is strongly recommended to always pass -1 (remaining transaction
|
|
3645
|
+
* time) as the \p timeout_ms. Using other values risk internal
|
|
3646
|
+
* state desynchronization in case any of the underlying protocol
|
|
3647
|
+
* requests fail.
|
|
3648
|
+
*
|
|
3649
|
+
* @returns an RdKafka::Error object on error, or NULL on success.
|
|
3650
|
+
* Check whether the returned error object permits retrying
|
|
3651
|
+
* by calling RdKafka::Error::is_retriable(), or whether a
|
|
3652
|
+
* fatal error has been raised by calling RdKafka::Error::is_fatal().
|
|
3653
|
+
*
|
|
3654
|
+
* @remark The returned error object (if not NULL) must be deleted.
|
|
3655
|
+
*
|
|
3656
|
+
* See rd_kafka_abort_transaction() in rdkafka.h for more information.
|
|
3657
|
+
*/
|
|
3658
|
+
virtual Error *abort_transaction(int timeout_ms) = 0;
|
|
3659
|
+
|
|
3660
|
+
/**@}*/
|
|
3661
|
+
};
|
|
3662
|
+
|
|
3663
|
+
/**@}*/
|
|
3664
|
+
|
|
3665
|
+
|
|
3666
|
+
/**
|
|
3667
|
+
* @name Metadata interface
|
|
3668
|
+
* @{
|
|
3669
|
+
*
|
|
3670
|
+
*/
|
|
3671
|
+
|
|
3672
|
+
|
|
3673
|
+
/**
|
|
3674
|
+
* @brief Metadata: Broker information
|
|
3675
|
+
*/
|
|
3676
|
+
class BrokerMetadata {
|
|
3677
|
+
public:
|
|
3678
|
+
/** @returns Broker id */
|
|
3679
|
+
virtual int32_t id() const = 0;
|
|
3680
|
+
|
|
3681
|
+
/** @returns Broker hostname */
|
|
3682
|
+
virtual std::string host() const = 0;
|
|
3683
|
+
|
|
3684
|
+
/** @returns Broker listening port */
|
|
3685
|
+
virtual int port() const = 0;
|
|
3686
|
+
|
|
3687
|
+
virtual ~BrokerMetadata() = 0;
|
|
3688
|
+
};
|
|
3689
|
+
|
|
3690
|
+
|
|
3691
|
+
|
|
3692
|
+
/**
|
|
3693
|
+
* @brief Metadata: Partition information
|
|
3694
|
+
*/
|
|
3695
|
+
class PartitionMetadata {
|
|
3696
|
+
public:
|
|
3697
|
+
/** @brief Replicas */
|
|
3698
|
+
typedef std::vector<int32_t> ReplicasVector;
|
|
3699
|
+
/** @brief ISRs (In-Sync-Replicas) */
|
|
3700
|
+
typedef std::vector<int32_t> ISRSVector;
|
|
3701
|
+
|
|
3702
|
+
/** @brief Replicas iterator */
|
|
3703
|
+
typedef ReplicasVector::const_iterator ReplicasIterator;
|
|
3704
|
+
/** @brief ISRs iterator */
|
|
3705
|
+
typedef ISRSVector::const_iterator ISRSIterator;
|
|
3706
|
+
|
|
3707
|
+
|
|
3708
|
+
/** @returns Partition id */
|
|
3709
|
+
virtual int32_t id() const = 0;
|
|
3710
|
+
|
|
3711
|
+
/** @returns Partition error reported by broker */
|
|
3712
|
+
virtual ErrorCode err() const = 0;
|
|
3713
|
+
|
|
3714
|
+
/** @returns Leader broker (id) for partition */
|
|
3715
|
+
virtual int32_t leader() const = 0;
|
|
3716
|
+
|
|
3717
|
+
/** @returns Replica brokers */
|
|
3718
|
+
virtual const std::vector<int32_t> *replicas() const = 0;
|
|
3719
|
+
|
|
3720
|
+
/** @returns In-Sync-Replica brokers
|
|
3721
|
+
* @warning The broker may return a cached/outdated list of ISRs.
|
|
3722
|
+
*/
|
|
3723
|
+
virtual const std::vector<int32_t> *isrs() const = 0;
|
|
3724
|
+
|
|
3725
|
+
virtual ~PartitionMetadata() = 0;
|
|
3726
|
+
};
|
|
3727
|
+
|
|
3728
|
+
|
|
3729
|
+
|
|
3730
|
+
/**
|
|
3731
|
+
* @brief Metadata: Topic information
|
|
3732
|
+
*/
|
|
3733
|
+
class TopicMetadata {
|
|
3734
|
+
public:
|
|
3735
|
+
/** @brief Partitions */
|
|
3736
|
+
typedef std::vector<const PartitionMetadata *> PartitionMetadataVector;
|
|
3737
|
+
/** @brief Partitions iterator */
|
|
3738
|
+
typedef PartitionMetadataVector::const_iterator PartitionMetadataIterator;
|
|
3739
|
+
|
|
3740
|
+
/** @returns Topic name */
|
|
3741
|
+
virtual std::string topic() const = 0;
|
|
3742
|
+
|
|
3743
|
+
/** @returns Partition list */
|
|
3744
|
+
virtual const PartitionMetadataVector *partitions() const = 0;
|
|
3745
|
+
|
|
3746
|
+
/** @returns Topic error reported by broker */
|
|
3747
|
+
virtual ErrorCode err() const = 0;
|
|
3748
|
+
|
|
3749
|
+
virtual ~TopicMetadata() = 0;
|
|
3750
|
+
};
|
|
3751
|
+
|
|
3752
|
+
|
|
3753
|
+
/**
|
|
3754
|
+
* @brief Metadata container
|
|
3755
|
+
*/
|
|
3756
|
+
class Metadata {
|
|
3757
|
+
public:
|
|
3758
|
+
/** @brief Brokers */
|
|
3759
|
+
typedef std::vector<const BrokerMetadata *> BrokerMetadataVector;
|
|
3760
|
+
/** @brief Topics */
|
|
3761
|
+
typedef std::vector<const TopicMetadata *> TopicMetadataVector;
|
|
3762
|
+
|
|
3763
|
+
/** @brief Brokers iterator */
|
|
3764
|
+
typedef BrokerMetadataVector::const_iterator BrokerMetadataIterator;
|
|
3765
|
+
/** @brief Topics iterator */
|
|
3766
|
+
typedef TopicMetadataVector::const_iterator TopicMetadataIterator;
|
|
3767
|
+
|
|
3768
|
+
|
|
3769
|
+
/**
|
|
3770
|
+
* @brief Broker list
|
|
3771
|
+
* @remark Ownership of the returned pointer is retained by the instance of
|
|
3772
|
+
* Metadata that is called.
|
|
3773
|
+
*/
|
|
3774
|
+
virtual const BrokerMetadataVector *brokers() const = 0;
|
|
3775
|
+
|
|
3776
|
+
/**
|
|
3777
|
+
* @brief Topic list
|
|
3778
|
+
* @remark Ownership of the returned pointer is retained by the instance of
|
|
3779
|
+
* Metadata that is called.
|
|
3780
|
+
*/
|
|
3781
|
+
virtual const TopicMetadataVector *topics() const = 0;
|
|
3782
|
+
|
|
3783
|
+
/** @brief Broker (id) originating this metadata */
|
|
3784
|
+
virtual int32_t orig_broker_id() const = 0;
|
|
3785
|
+
|
|
3786
|
+
/** @brief Broker (name) originating this metadata */
|
|
3787
|
+
virtual std::string orig_broker_name() const = 0;
|
|
3788
|
+
|
|
3789
|
+
virtual ~Metadata() = 0;
|
|
3790
|
+
};
|
|
3791
|
+
|
|
3792
|
+
/**@}*/
|
|
3793
|
+
|
|
3794
|
+
} // namespace RdKafka
|
|
3795
|
+
|
|
3796
|
+
|
|
3797
|
+
#endif /* _RDKAFKACPP_H_ */
|