@platformatic/rdkafka 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +5 -0
- package/.jshintignore +1 -0
- package/.jshintrc +23 -0
- package/CONTRIBUTING.md +237 -0
- package/LICENSE.txt +21 -0
- package/Makefile +94 -0
- package/README.md +630 -0
- package/bench/consumer-raw-rdkafka.js +76 -0
- package/bench/consumer-subscribe.js +77 -0
- package/bench/kafka-consumer-stream.js +100 -0
- package/bench/producer-raw-rdkafka.js +125 -0
- package/bench/producer-rdkafka.js +117 -0
- package/bench/seed.sh +38 -0
- package/binding.gyp +155 -0
- package/ci/checks/librdkafka-correct-version.js +67 -0
- package/ci/checks/librdkafka-exists.js +13 -0
- package/ci/librdkafka-defs-generator.js +193 -0
- package/ci/prepublish.js +3 -0
- package/config.d.ts +1132 -0
- package/configure +15 -0
- package/cpplint.py +6325 -0
- package/deploy.enc +0 -0
- package/deps/librdkafka/.clang-format +136 -0
- package/deps/librdkafka/.clang-format-cpp +103 -0
- package/deps/librdkafka/.dir-locals.el +10 -0
- package/deps/librdkafka/.formatignore +33 -0
- package/deps/librdkafka/.gdbmacros +19 -0
- package/deps/librdkafka/.semaphore/project.yml +43 -0
- package/deps/librdkafka/.semaphore/project_public.yml +20 -0
- package/deps/librdkafka/.semaphore/semaphore.yml +355 -0
- package/deps/librdkafka/CHANGELOG.md +1738 -0
- package/deps/librdkafka/CMakeLists.txt +291 -0
- package/deps/librdkafka/CODE_OF_CONDUCT.md +46 -0
- package/deps/librdkafka/CONFIGURATION.md +189 -0
- package/deps/librdkafka/CONTRIBUTING.md +431 -0
- package/deps/librdkafka/Doxyfile +2375 -0
- package/deps/librdkafka/INTRODUCTION.md +2173 -0
- package/deps/librdkafka/LICENSE +26 -0
- package/deps/librdkafka/LICENSE.cjson +22 -0
- package/deps/librdkafka/LICENSE.crc32c +28 -0
- package/deps/librdkafka/LICENSE.fnv1a +18 -0
- package/deps/librdkafka/LICENSE.hdrhistogram +27 -0
- package/deps/librdkafka/LICENSE.lz4 +26 -0
- package/deps/librdkafka/LICENSE.murmur2 +25 -0
- package/deps/librdkafka/LICENSE.nanopb +22 -0
- package/deps/librdkafka/LICENSE.opentelemetry +203 -0
- package/deps/librdkafka/LICENSE.pycrc +23 -0
- package/deps/librdkafka/LICENSE.queue +31 -0
- package/deps/librdkafka/LICENSE.regexp +5 -0
- package/deps/librdkafka/LICENSE.snappy +36 -0
- package/deps/librdkafka/LICENSE.tinycthread +26 -0
- package/deps/librdkafka/LICENSE.wingetopt +49 -0
- package/deps/librdkafka/LICENSES.txt +625 -0
- package/deps/librdkafka/Makefile +124 -0
- package/deps/librdkafka/README.md +199 -0
- package/deps/librdkafka/README.win32 +26 -0
- package/deps/librdkafka/STATISTICS.md +624 -0
- package/deps/librdkafka/configure +214 -0
- package/deps/librdkafka/configure.self +331 -0
- package/deps/librdkafka/debian/changelog +111 -0
- package/deps/librdkafka/debian/compat +1 -0
- package/deps/librdkafka/debian/control +71 -0
- package/deps/librdkafka/debian/copyright +99 -0
- package/deps/librdkafka/debian/gbp.conf +9 -0
- package/deps/librdkafka/debian/librdkafka++1.install +1 -0
- package/deps/librdkafka/debian/librdkafka-dev.examples +2 -0
- package/deps/librdkafka/debian/librdkafka-dev.install +9 -0
- package/deps/librdkafka/debian/librdkafka1.docs +5 -0
- package/deps/librdkafka/debian/librdkafka1.install +1 -0
- package/deps/librdkafka/debian/librdkafka1.symbols +135 -0
- package/deps/librdkafka/debian/rules +19 -0
- package/deps/librdkafka/debian/source/format +1 -0
- package/deps/librdkafka/debian/watch +2 -0
- package/deps/librdkafka/dev-conf.sh +123 -0
- package/deps/librdkafka/examples/CMakeLists.txt +79 -0
- package/deps/librdkafka/examples/Makefile +167 -0
- package/deps/librdkafka/examples/README.md +42 -0
- package/deps/librdkafka/examples/alter_consumer_group_offsets.c +338 -0
- package/deps/librdkafka/examples/consumer.c +261 -0
- package/deps/librdkafka/examples/delete_records.c +233 -0
- package/deps/librdkafka/examples/describe_cluster.c +322 -0
- package/deps/librdkafka/examples/describe_consumer_groups.c +436 -0
- package/deps/librdkafka/examples/describe_topics.c +427 -0
- package/deps/librdkafka/examples/elect_leaders.c +317 -0
- package/deps/librdkafka/examples/globals.json +11 -0
- package/deps/librdkafka/examples/idempotent_producer.c +344 -0
- package/deps/librdkafka/examples/incremental_alter_configs.c +348 -0
- package/deps/librdkafka/examples/kafkatest_verifiable_client.cpp +961 -0
- package/deps/librdkafka/examples/list_consumer_group_offsets.c +359 -0
- package/deps/librdkafka/examples/list_consumer_groups.c +365 -0
- package/deps/librdkafka/examples/list_offsets.c +327 -0
- package/deps/librdkafka/examples/misc.c +287 -0
- package/deps/librdkafka/examples/openssl_engine_example.cpp +249 -0
- package/deps/librdkafka/examples/producer.c +251 -0
- package/deps/librdkafka/examples/producer.cpp +228 -0
- package/deps/librdkafka/examples/rdkafka_complex_consumer_example.c +617 -0
- package/deps/librdkafka/examples/rdkafka_complex_consumer_example.cpp +467 -0
- package/deps/librdkafka/examples/rdkafka_consume_batch.cpp +264 -0
- package/deps/librdkafka/examples/rdkafka_example.c +853 -0
- package/deps/librdkafka/examples/rdkafka_example.cpp +679 -0
- package/deps/librdkafka/examples/rdkafka_performance.c +1781 -0
- package/deps/librdkafka/examples/transactions-older-broker.c +668 -0
- package/deps/librdkafka/examples/transactions.c +665 -0
- package/deps/librdkafka/examples/user_scram.c +492 -0
- package/deps/librdkafka/examples/win_ssl_cert_store.cpp +395 -0
- package/deps/librdkafka/lds-gen.py +73 -0
- package/deps/librdkafka/mainpage.doxy +40 -0
- package/deps/librdkafka/mklove/Makefile.base +329 -0
- package/deps/librdkafka/mklove/modules/configure.atomics +144 -0
- package/deps/librdkafka/mklove/modules/configure.base +2484 -0
- package/deps/librdkafka/mklove/modules/configure.builtin +70 -0
- package/deps/librdkafka/mklove/modules/configure.cc +186 -0
- package/deps/librdkafka/mklove/modules/configure.cxx +8 -0
- package/deps/librdkafka/mklove/modules/configure.fileversion +65 -0
- package/deps/librdkafka/mklove/modules/configure.gitversion +29 -0
- package/deps/librdkafka/mklove/modules/configure.good_cflags +18 -0
- package/deps/librdkafka/mklove/modules/configure.host +132 -0
- package/deps/librdkafka/mklove/modules/configure.lib +49 -0
- package/deps/librdkafka/mklove/modules/configure.libcurl +99 -0
- package/deps/librdkafka/mklove/modules/configure.libsasl2 +36 -0
- package/deps/librdkafka/mklove/modules/configure.libssl +147 -0
- package/deps/librdkafka/mklove/modules/configure.libzstd +58 -0
- package/deps/librdkafka/mklove/modules/configure.parseversion +95 -0
- package/deps/librdkafka/mklove/modules/configure.pic +16 -0
- package/deps/librdkafka/mklove/modules/configure.socket +20 -0
- package/deps/librdkafka/mklove/modules/configure.zlib +61 -0
- package/deps/librdkafka/mklove/modules/patches/README.md +8 -0
- package/deps/librdkafka/mklove/modules/patches/libcurl.0000-no-runtime-linking-check.patch +11 -0
- package/deps/librdkafka/mklove/modules/patches/libssl.0000-osx-rand-include-fix-OpenSSL-PR16409.patch +56 -0
- package/deps/librdkafka/packaging/RELEASE.md +311 -0
- package/deps/librdkafka/packaging/alpine/build-alpine.sh +38 -0
- package/deps/librdkafka/packaging/archlinux/PKGBUILD +30 -0
- package/deps/librdkafka/packaging/cmake/Config.cmake.in +37 -0
- package/deps/librdkafka/packaging/cmake/Modules/FindLZ4.cmake +38 -0
- package/deps/librdkafka/packaging/cmake/Modules/FindZSTD.cmake +27 -0
- package/deps/librdkafka/packaging/cmake/Modules/LICENSE.FindZstd +178 -0
- package/deps/librdkafka/packaging/cmake/README.md +38 -0
- package/deps/librdkafka/packaging/cmake/config.h.in +52 -0
- package/deps/librdkafka/packaging/cmake/parseversion.cmake +60 -0
- package/deps/librdkafka/packaging/cmake/rdkafka.pc.in +12 -0
- package/deps/librdkafka/packaging/cmake/try_compile/atomic_32_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/atomic_64_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/c11threads_test.c +14 -0
- package/deps/librdkafka/packaging/cmake/try_compile/crc32c_hw_test.c +27 -0
- package/deps/librdkafka/packaging/cmake/try_compile/dlopen_test.c +11 -0
- package/deps/librdkafka/packaging/cmake/try_compile/libsasl2_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_darwin_test.c +6 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_freebsd_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/pthread_setname_gnu_test.c +5 -0
- package/deps/librdkafka/packaging/cmake/try_compile/rand_r_test.c +7 -0
- package/deps/librdkafka/packaging/cmake/try_compile/rdkafka_setup.cmake +122 -0
- package/deps/librdkafka/packaging/cmake/try_compile/regex_test.c +10 -0
- package/deps/librdkafka/packaging/cmake/try_compile/strndup_test.c +5 -0
- package/deps/librdkafka/packaging/cmake/try_compile/sync_32_test.c +8 -0
- package/deps/librdkafka/packaging/cmake/try_compile/sync_64_test.c +8 -0
- package/deps/librdkafka/packaging/cp/README.md +13 -0
- package/deps/librdkafka/packaging/cp/check_features.c +64 -0
- package/deps/librdkafka/packaging/cp/verify-deb.sh +33 -0
- package/deps/librdkafka/packaging/cp/verify-packages.sh +48 -0
- package/deps/librdkafka/packaging/cp/verify-rpm.sh +39 -0
- package/deps/librdkafka/packaging/debian/changelog +66 -0
- package/deps/librdkafka/packaging/debian/compat +1 -0
- package/deps/librdkafka/packaging/debian/control +49 -0
- package/deps/librdkafka/packaging/debian/copyright +84 -0
- package/deps/librdkafka/packaging/debian/gbp.conf +9 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.dirs +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.examples +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.install +6 -0
- package/deps/librdkafka/packaging/debian/librdkafka-dev.substvars +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka.dsc +16 -0
- package/deps/librdkafka/packaging/debian/librdkafka1-dbg.substvars +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.dirs +1 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.install +2 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.postinst.debhelper +5 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.postrm.debhelper +5 -0
- package/deps/librdkafka/packaging/debian/librdkafka1.symbols +64 -0
- package/deps/librdkafka/packaging/debian/rules +19 -0
- package/deps/librdkafka/packaging/debian/source/format +1 -0
- package/deps/librdkafka/packaging/debian/watch +2 -0
- package/deps/librdkafka/packaging/get_version.py +21 -0
- package/deps/librdkafka/packaging/homebrew/README.md +15 -0
- package/deps/librdkafka/packaging/homebrew/brew-update-pr.sh +31 -0
- package/deps/librdkafka/packaging/mingw-w64/configure-build-msys2-mingw-static.sh +52 -0
- package/deps/librdkafka/packaging/mingw-w64/configure-build-msys2-mingw.sh +21 -0
- package/deps/librdkafka/packaging/mingw-w64/run-tests.sh +6 -0
- package/deps/librdkafka/packaging/mingw-w64/semaphoreci-build.sh +38 -0
- package/deps/librdkafka/packaging/mingw-w64/travis-before-install.sh +20 -0
- package/deps/librdkafka/packaging/nuget/README.md +84 -0
- package/deps/librdkafka/packaging/nuget/artifact.py +177 -0
- package/deps/librdkafka/packaging/nuget/cleanup-s3.py +143 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-win32__bldtype-Release/msvcr120.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-win32__bldtype-Release/msvcr140.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-x64__bldtype-Release/msvcr120.zip +0 -0
- package/deps/librdkafka/packaging/nuget/common/p-common__plat-windows__arch-x64__bldtype-Release/msvcr140.zip +0 -0
- package/deps/librdkafka/packaging/nuget/nuget.sh +21 -0
- package/deps/librdkafka/packaging/nuget/nugetpackage.py +278 -0
- package/deps/librdkafka/packaging/nuget/packaging.py +448 -0
- package/deps/librdkafka/packaging/nuget/push-to-nuget.sh +21 -0
- package/deps/librdkafka/packaging/nuget/release.py +167 -0
- package/deps/librdkafka/packaging/nuget/requirements.txt +3 -0
- package/deps/librdkafka/packaging/nuget/staticpackage.py +178 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.nuspec +21 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.props +18 -0
- package/deps/librdkafka/packaging/nuget/templates/librdkafka.redist.targets +19 -0
- package/deps/librdkafka/packaging/nuget/zfile/__init__.py +0 -0
- package/deps/librdkafka/packaging/nuget/zfile/zfile.py +98 -0
- package/deps/librdkafka/packaging/rpm/Makefile +92 -0
- package/deps/librdkafka/packaging/rpm/README.md +23 -0
- package/deps/librdkafka/packaging/rpm/el7-x86_64.cfg +40 -0
- package/deps/librdkafka/packaging/rpm/librdkafka.spec +118 -0
- package/deps/librdkafka/packaging/rpm/mock-on-docker.sh +96 -0
- package/deps/librdkafka/packaging/rpm/tests/Makefile +25 -0
- package/deps/librdkafka/packaging/rpm/tests/README.md +8 -0
- package/deps/librdkafka/packaging/rpm/tests/run-test.sh +42 -0
- package/deps/librdkafka/packaging/rpm/tests/test-on-docker.sh +56 -0
- package/deps/librdkafka/packaging/rpm/tests/test.c +77 -0
- package/deps/librdkafka/packaging/rpm/tests/test.cpp +34 -0
- package/deps/librdkafka/packaging/tools/build-configurations-checks.sh +10 -0
- package/deps/librdkafka/packaging/tools/build-deb-package.sh +64 -0
- package/deps/librdkafka/packaging/tools/build-debian.sh +65 -0
- package/deps/librdkafka/packaging/tools/build-manylinux.sh +68 -0
- package/deps/librdkafka/packaging/tools/build-release-artifacts.sh +139 -0
- package/deps/librdkafka/packaging/tools/distro-build.sh +38 -0
- package/deps/librdkafka/packaging/tools/gh-release-checksums.py +39 -0
- package/deps/librdkafka/packaging/tools/rdutcoverage.sh +25 -0
- package/deps/librdkafka/packaging/tools/requirements.txt +2 -0
- package/deps/librdkafka/packaging/tools/style-format.sh +148 -0
- package/deps/librdkafka/service.yml +18 -0
- package/deps/librdkafka/src/CMakeLists.txt +374 -0
- package/deps/librdkafka/src/Makefile +103 -0
- package/deps/librdkafka/src/README.lz4.md +30 -0
- package/deps/librdkafka/src/cJSON.c +2834 -0
- package/deps/librdkafka/src/cJSON.h +398 -0
- package/deps/librdkafka/src/crc32c.c +430 -0
- package/deps/librdkafka/src/crc32c.h +38 -0
- package/deps/librdkafka/src/generate_proto.sh +66 -0
- package/deps/librdkafka/src/librdkafka_cgrp_synch.png +0 -0
- package/deps/librdkafka/src/lz4.c +2727 -0
- package/deps/librdkafka/src/lz4.h +842 -0
- package/deps/librdkafka/src/lz4frame.c +2078 -0
- package/deps/librdkafka/src/lz4frame.h +692 -0
- package/deps/librdkafka/src/lz4frame_static.h +47 -0
- package/deps/librdkafka/src/lz4hc.c +1631 -0
- package/deps/librdkafka/src/lz4hc.h +413 -0
- package/deps/librdkafka/src/nanopb/pb.h +917 -0
- package/deps/librdkafka/src/nanopb/pb_common.c +388 -0
- package/deps/librdkafka/src/nanopb/pb_common.h +49 -0
- package/deps/librdkafka/src/nanopb/pb_decode.c +1727 -0
- package/deps/librdkafka/src/nanopb/pb_decode.h +193 -0
- package/deps/librdkafka/src/nanopb/pb_encode.c +1000 -0
- package/deps/librdkafka/src/nanopb/pb_encode.h +185 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.c +32 -0
- package/deps/librdkafka/src/opentelemetry/common.pb.h +170 -0
- package/deps/librdkafka/src/opentelemetry/metrics.options +2 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.c +67 -0
- package/deps/librdkafka/src/opentelemetry/metrics.pb.h +966 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.c +12 -0
- package/deps/librdkafka/src/opentelemetry/resource.pb.h +58 -0
- package/deps/librdkafka/src/queue.h +850 -0
- package/deps/librdkafka/src/rd.h +441 -0
- package/deps/librdkafka/src/rdaddr.c +255 -0
- package/deps/librdkafka/src/rdaddr.h +203 -0
- package/deps/librdkafka/src/rdatomic.h +226 -0
- package/deps/librdkafka/src/rdavg.h +259 -0
- package/deps/librdkafka/src/rdavl.c +210 -0
- package/deps/librdkafka/src/rdavl.h +250 -0
- package/deps/librdkafka/src/rdbase64.c +169 -0
- package/deps/librdkafka/src/rdbase64.h +41 -0
- package/deps/librdkafka/src/rdbuf.c +1884 -0
- package/deps/librdkafka/src/rdbuf.h +375 -0
- package/deps/librdkafka/src/rdcrc32.c +114 -0
- package/deps/librdkafka/src/rdcrc32.h +170 -0
- package/deps/librdkafka/src/rddl.c +179 -0
- package/deps/librdkafka/src/rddl.h +43 -0
- package/deps/librdkafka/src/rdendian.h +174 -0
- package/deps/librdkafka/src/rdfloat.h +67 -0
- package/deps/librdkafka/src/rdfnv1a.c +113 -0
- package/deps/librdkafka/src/rdfnv1a.h +35 -0
- package/deps/librdkafka/src/rdgz.c +120 -0
- package/deps/librdkafka/src/rdgz.h +46 -0
- package/deps/librdkafka/src/rdhdrhistogram.c +721 -0
- package/deps/librdkafka/src/rdhdrhistogram.h +87 -0
- package/deps/librdkafka/src/rdhttp.c +512 -0
- package/deps/librdkafka/src/rdhttp.h +83 -0
- package/deps/librdkafka/src/rdinterval.h +177 -0
- package/deps/librdkafka/src/rdkafka.c +5351 -0
- package/deps/librdkafka/src/rdkafka.h +10603 -0
- package/deps/librdkafka/src/rdkafka_admin.c +9417 -0
- package/deps/librdkafka/src/rdkafka_admin.h +619 -0
- package/deps/librdkafka/src/rdkafka_assignment.c +1010 -0
- package/deps/librdkafka/src/rdkafka_assignment.h +73 -0
- package/deps/librdkafka/src/rdkafka_assignor.c +1786 -0
- package/deps/librdkafka/src/rdkafka_assignor.h +402 -0
- package/deps/librdkafka/src/rdkafka_aux.c +409 -0
- package/deps/librdkafka/src/rdkafka_aux.h +174 -0
- package/deps/librdkafka/src/rdkafka_background.c +221 -0
- package/deps/librdkafka/src/rdkafka_broker.c +6186 -0
- package/deps/librdkafka/src/rdkafka_broker.h +686 -0
- package/deps/librdkafka/src/rdkafka_buf.c +540 -0
- package/deps/librdkafka/src/rdkafka_buf.h +1524 -0
- package/deps/librdkafka/src/rdkafka_cert.c +552 -0
- package/deps/librdkafka/src/rdkafka_cert.h +61 -0
- package/deps/librdkafka/src/rdkafka_cgrp.c +7262 -0
- package/deps/librdkafka/src/rdkafka_cgrp.h +443 -0
- package/deps/librdkafka/src/rdkafka_conf.c +4456 -0
- package/deps/librdkafka/src/rdkafka_conf.h +668 -0
- package/deps/librdkafka/src/rdkafka_confval.h +97 -0
- package/deps/librdkafka/src/rdkafka_coord.c +623 -0
- package/deps/librdkafka/src/rdkafka_coord.h +132 -0
- package/deps/librdkafka/src/rdkafka_error.c +228 -0
- package/deps/librdkafka/src/rdkafka_error.h +80 -0
- package/deps/librdkafka/src/rdkafka_event.c +502 -0
- package/deps/librdkafka/src/rdkafka_event.h +126 -0
- package/deps/librdkafka/src/rdkafka_feature.c +461 -0
- package/deps/librdkafka/src/rdkafka_feature.h +102 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +1402 -0
- package/deps/librdkafka/src/rdkafka_fetcher.h +44 -0
- package/deps/librdkafka/src/rdkafka_header.c +220 -0
- package/deps/librdkafka/src/rdkafka_header.h +76 -0
- package/deps/librdkafka/src/rdkafka_idempotence.c +807 -0
- package/deps/librdkafka/src/rdkafka_idempotence.h +144 -0
- package/deps/librdkafka/src/rdkafka_int.h +1222 -0
- package/deps/librdkafka/src/rdkafka_interceptor.c +819 -0
- package/deps/librdkafka/src/rdkafka_interceptor.h +104 -0
- package/deps/librdkafka/src/rdkafka_lz4.c +450 -0
- package/deps/librdkafka/src/rdkafka_lz4.h +49 -0
- package/deps/librdkafka/src/rdkafka_metadata.c +2124 -0
- package/deps/librdkafka/src/rdkafka_metadata.h +341 -0
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +977 -0
- package/deps/librdkafka/src/rdkafka_mock.c +2885 -0
- package/deps/librdkafka/src/rdkafka_mock.h +491 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +710 -0
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +2817 -0
- package/deps/librdkafka/src/rdkafka_mock_int.h +591 -0
- package/deps/librdkafka/src/rdkafka_msg.c +2573 -0
- package/deps/librdkafka/src/rdkafka_msg.h +614 -0
- package/deps/librdkafka/src/rdkafka_msgbatch.h +62 -0
- package/deps/librdkafka/src/rdkafka_msgset.h +98 -0
- package/deps/librdkafka/src/rdkafka_msgset_reader.c +1806 -0
- package/deps/librdkafka/src/rdkafka_msgset_writer.c +1470 -0
- package/deps/librdkafka/src/rdkafka_offset.c +1537 -0
- package/deps/librdkafka/src/rdkafka_offset.h +150 -0
- package/deps/librdkafka/src/rdkafka_op.c +997 -0
- package/deps/librdkafka/src/rdkafka_op.h +834 -0
- package/deps/librdkafka/src/rdkafka_partition.c +4801 -0
- package/deps/librdkafka/src/rdkafka_partition.h +1173 -0
- package/deps/librdkafka/src/rdkafka_pattern.c +228 -0
- package/deps/librdkafka/src/rdkafka_pattern.h +70 -0
- package/deps/librdkafka/src/rdkafka_plugin.c +213 -0
- package/deps/librdkafka/src/rdkafka_plugin.h +41 -0
- package/deps/librdkafka/src/rdkafka_proto.h +733 -0
- package/deps/librdkafka/src/rdkafka_protocol.h +127 -0
- package/deps/librdkafka/src/rdkafka_queue.c +1153 -0
- package/deps/librdkafka/src/rdkafka_queue.h +1201 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1748 -0
- package/deps/librdkafka/src/rdkafka_request.c +6817 -0
- package/deps/librdkafka/src/rdkafka_request.h +709 -0
- package/deps/librdkafka/src/rdkafka_roundrobin_assignor.c +123 -0
- package/deps/librdkafka/src/rdkafka_sasl.c +528 -0
- package/deps/librdkafka/src/rdkafka_sasl.h +63 -0
- package/deps/librdkafka/src/rdkafka_sasl_cyrus.c +722 -0
- package/deps/librdkafka/src/rdkafka_sasl_int.h +89 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +1829 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +589 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +37 -0
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +142 -0
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +857 -0
- package/deps/librdkafka/src/rdkafka_sasl_win32.c +550 -0
- package/deps/librdkafka/src/rdkafka_ssl.c +1904 -0
- package/deps/librdkafka/src/rdkafka_ssl.h +64 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4781 -0
- package/deps/librdkafka/src/rdkafka_subscription.c +278 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +703 -0
- package/deps/librdkafka/src/rdkafka_telemetry.h +52 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.c +1053 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.h +59 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.c +993 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.h +301 -0
- package/deps/librdkafka/src/rdkafka_timer.c +402 -0
- package/deps/librdkafka/src/rdkafka_timer.h +117 -0
- package/deps/librdkafka/src/rdkafka_topic.c +2078 -0
- package/deps/librdkafka/src/rdkafka_topic.h +328 -0
- package/deps/librdkafka/src/rdkafka_transport.c +1297 -0
- package/deps/librdkafka/src/rdkafka_transport.h +94 -0
- package/deps/librdkafka/src/rdkafka_transport_int.h +100 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +3251 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.h +171 -0
- package/deps/librdkafka/src/rdkafka_zstd.c +226 -0
- package/deps/librdkafka/src/rdkafka_zstd.h +57 -0
- package/deps/librdkafka/src/rdlist.c +576 -0
- package/deps/librdkafka/src/rdlist.h +434 -0
- package/deps/librdkafka/src/rdlog.c +89 -0
- package/deps/librdkafka/src/rdlog.h +41 -0
- package/deps/librdkafka/src/rdmap.c +503 -0
- package/deps/librdkafka/src/rdmap.h +492 -0
- package/deps/librdkafka/src/rdmurmur2.c +167 -0
- package/deps/librdkafka/src/rdmurmur2.h +35 -0
- package/deps/librdkafka/src/rdports.c +61 -0
- package/deps/librdkafka/src/rdports.h +38 -0
- package/deps/librdkafka/src/rdposix.h +250 -0
- package/deps/librdkafka/src/rdrand.c +70 -0
- package/deps/librdkafka/src/rdrand.h +43 -0
- package/deps/librdkafka/src/rdregex.c +156 -0
- package/deps/librdkafka/src/rdregex.h +43 -0
- package/deps/librdkafka/src/rdsignal.h +57 -0
- package/deps/librdkafka/src/rdstring.c +645 -0
- package/deps/librdkafka/src/rdstring.h +98 -0
- package/deps/librdkafka/src/rdsysqueue.h +404 -0
- package/deps/librdkafka/src/rdtime.h +325 -0
- package/deps/librdkafka/src/rdtypes.h +86 -0
- package/deps/librdkafka/src/rdunittest.c +532 -0
- package/deps/librdkafka/src/rdunittest.h +230 -0
- package/deps/librdkafka/src/rdvarint.c +134 -0
- package/deps/librdkafka/src/rdvarint.h +165 -0
- package/deps/librdkafka/src/rdwin32.h +382 -0
- package/deps/librdkafka/src/rdxxhash.c +1030 -0
- package/deps/librdkafka/src/rdxxhash.h +328 -0
- package/deps/librdkafka/src/regexp.c +1347 -0
- package/deps/librdkafka/src/regexp.h +41 -0
- package/deps/librdkafka/src/snappy.c +1866 -0
- package/deps/librdkafka/src/snappy.h +62 -0
- package/deps/librdkafka/src/snappy_compat.h +138 -0
- package/deps/librdkafka/src/statistics_schema.json +444 -0
- package/deps/librdkafka/src/tinycthread.c +932 -0
- package/deps/librdkafka/src/tinycthread.h +503 -0
- package/deps/librdkafka/src/tinycthread_extra.c +175 -0
- package/deps/librdkafka/src/tinycthread_extra.h +208 -0
- package/deps/librdkafka/src/win32_config.h +58 -0
- package/deps/librdkafka/src-cpp/CMakeLists.txt +90 -0
- package/deps/librdkafka/src-cpp/ConfImpl.cpp +84 -0
- package/deps/librdkafka/src-cpp/ConsumerImpl.cpp +244 -0
- package/deps/librdkafka/src-cpp/HandleImpl.cpp +436 -0
- package/deps/librdkafka/src-cpp/HeadersImpl.cpp +48 -0
- package/deps/librdkafka/src-cpp/KafkaConsumerImpl.cpp +296 -0
- package/deps/librdkafka/src-cpp/Makefile +55 -0
- package/deps/librdkafka/src-cpp/MessageImpl.cpp +38 -0
- package/deps/librdkafka/src-cpp/MetadataImpl.cpp +170 -0
- package/deps/librdkafka/src-cpp/ProducerImpl.cpp +197 -0
- package/deps/librdkafka/src-cpp/QueueImpl.cpp +70 -0
- package/deps/librdkafka/src-cpp/README.md +16 -0
- package/deps/librdkafka/src-cpp/RdKafka.cpp +59 -0
- package/deps/librdkafka/src-cpp/TopicImpl.cpp +124 -0
- package/deps/librdkafka/src-cpp/TopicPartitionImpl.cpp +57 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp.h +3771 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp_int.h +1641 -0
- package/deps/librdkafka/tests/0000-unittests.c +72 -0
- package/deps/librdkafka/tests/0001-multiobj.c +98 -0
- package/deps/librdkafka/tests/0002-unkpart.c +244 -0
- package/deps/librdkafka/tests/0003-msgmaxsize.c +173 -0
- package/deps/librdkafka/tests/0004-conf.c +867 -0
- package/deps/librdkafka/tests/0005-order.c +133 -0
- package/deps/librdkafka/tests/0006-symbols.c +163 -0
- package/deps/librdkafka/tests/0007-autotopic.c +136 -0
- package/deps/librdkafka/tests/0008-reqacks.c +179 -0
- package/deps/librdkafka/tests/0009-mock_cluster.c +96 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +752 -0
- package/deps/librdkafka/tests/0012-produce_consume.c +537 -0
- package/deps/librdkafka/tests/0013-null-msgs.c +473 -0
- package/deps/librdkafka/tests/0014-reconsume-191.c +512 -0
- package/deps/librdkafka/tests/0015-offset_seeks.c +172 -0
- package/deps/librdkafka/tests/0016-client_swname.c +166 -0
- package/deps/librdkafka/tests/0017-compression.c +142 -0
- package/deps/librdkafka/tests/0018-cgrp_term.c +333 -0
- package/deps/librdkafka/tests/0019-list_groups.c +289 -0
- package/deps/librdkafka/tests/0020-destroy_hang.c +162 -0
- package/deps/librdkafka/tests/0021-rkt_destroy.c +71 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +276 -0
- package/deps/librdkafka/tests/0025-timers.c +147 -0
- package/deps/librdkafka/tests/0026-consume_pause.c +549 -0
- package/deps/librdkafka/tests/0028-long_topicnames.c +79 -0
- package/deps/librdkafka/tests/0029-assign_offset.c +204 -0
- package/deps/librdkafka/tests/0030-offset_commit.c +589 -0
- package/deps/librdkafka/tests/0031-get_offsets.c +235 -0
- package/deps/librdkafka/tests/0033-regex_subscribe.c +520 -0
- package/deps/librdkafka/tests/0034-offset_reset.c +377 -0
- package/deps/librdkafka/tests/0035-api_version.c +73 -0
- package/deps/librdkafka/tests/0036-partial_fetch.c +86 -0
- package/deps/librdkafka/tests/0037-destroy_hang_local.c +85 -0
- package/deps/librdkafka/tests/0038-performance.c +120 -0
- package/deps/librdkafka/tests/0039-event.c +284 -0
- package/deps/librdkafka/tests/0040-io_event.c +251 -0
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +96 -0
- package/deps/librdkafka/tests/0042-many_topics.c +252 -0
- package/deps/librdkafka/tests/0043-no_connection.c +77 -0
- package/deps/librdkafka/tests/0044-partition_cnt.c +93 -0
- package/deps/librdkafka/tests/0045-subscribe_update.c +746 -0
- package/deps/librdkafka/tests/0046-rkt_cache.c +65 -0
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +97 -0
- package/deps/librdkafka/tests/0048-partitioner.c +283 -0
- package/deps/librdkafka/tests/0049-consume_conn_close.c +162 -0
- package/deps/librdkafka/tests/0050-subscribe_adds.c +144 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +125 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +220 -0
- package/deps/librdkafka/tests/0053-stats_cb.cpp +535 -0
- package/deps/librdkafka/tests/0054-offset_time.cpp +236 -0
- package/deps/librdkafka/tests/0055-producer_latency.c +366 -0
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +311 -0
- package/deps/librdkafka/tests/0057-invalid_topic.cpp +112 -0
- package/deps/librdkafka/tests/0058-log.cpp +123 -0
- package/deps/librdkafka/tests/0059-bsearch.cpp +237 -0
- package/deps/librdkafka/tests/0060-op_prio.cpp +163 -0
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +275 -0
- package/deps/librdkafka/tests/0062-stats_event.c +126 -0
- package/deps/librdkafka/tests/0063-clusterid.cpp +180 -0
- package/deps/librdkafka/tests/0064-interceptors.c +481 -0
- package/deps/librdkafka/tests/0065-yield.cpp +140 -0
- package/deps/librdkafka/tests/0066-plugins.cpp +129 -0
- package/deps/librdkafka/tests/0067-empty_topic.cpp +148 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +138 -0
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +123 -0
- package/deps/librdkafka/tests/0070-null_empty.cpp +197 -0
- package/deps/librdkafka/tests/0072-headers_ut.c +448 -0
- package/deps/librdkafka/tests/0073-headers.c +381 -0
- package/deps/librdkafka/tests/0074-producev.c +87 -0
- package/deps/librdkafka/tests/0075-retry.c +253 -0
- package/deps/librdkafka/tests/0076-produce_retry.c +450 -0
- package/deps/librdkafka/tests/0077-compaction.c +357 -0
- package/deps/librdkafka/tests/0078-c_from_cpp.cpp +96 -0
- package/deps/librdkafka/tests/0079-fork.c +93 -0
- package/deps/librdkafka/tests/0080-admin_ut.c +3065 -0
- package/deps/librdkafka/tests/0081-admin.c +5333 -0
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +133 -0
- package/deps/librdkafka/tests/0083-cb_event.c +228 -0
- package/deps/librdkafka/tests/0084-destroy_flags.c +212 -0
- package/deps/librdkafka/tests/0085-headers.cpp +388 -0
- package/deps/librdkafka/tests/0086-purge.c +335 -0
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +162 -0
- package/deps/librdkafka/tests/0089-max_poll_interval.c +506 -0
- package/deps/librdkafka/tests/0090-idempotence.c +172 -0
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +297 -0
- package/deps/librdkafka/tests/0092-mixed_msgver.c +97 -0
- package/deps/librdkafka/tests/0093-holb.c +197 -0
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +230 -0
- package/deps/librdkafka/tests/0095-all_brokers_down.cpp +122 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +466 -0
- package/deps/librdkafka/tests/0098-consumer-txn.cpp +1218 -0
- package/deps/librdkafka/tests/0099-commit_metadata.c +194 -0
- package/deps/librdkafka/tests/0100-thread_interceptors.cpp +195 -0
- package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +446 -0
- package/deps/librdkafka/tests/0102-static_group_rebalance.c +535 -0
- package/deps/librdkafka/tests/0103-transactions.c +1383 -0
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +624 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +3923 -0
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +297 -0
- package/deps/librdkafka/tests/0107-topic_recreate.c +259 -0
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +218 -0
- package/deps/librdkafka/tests/0110-batch_size.cpp +183 -0
- package/deps/librdkafka/tests/0111-delay_create_topics.cpp +127 -0
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +98 -0
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +3329 -0
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +176 -0
- package/deps/librdkafka/tests/0115-producer_auth.cpp +179 -0
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +214 -0
- package/deps/librdkafka/tests/0117-mock_errors.c +321 -0
- package/deps/librdkafka/tests/0118-commit_rebalance.c +121 -0
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +148 -0
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +180 -0
- package/deps/librdkafka/tests/0121-clusterid.c +115 -0
- package/deps/librdkafka/tests/0122-buffer_cleaning_after_rebalance.c +227 -0
- package/deps/librdkafka/tests/0123-connections_max_idle.c +98 -0
- package/deps/librdkafka/tests/0124-openssl_invalid_engine.c +69 -0
- package/deps/librdkafka/tests/0125-immediate_flush.c +144 -0
- package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +213 -0
- package/deps/librdkafka/tests/0127-fetch_queue_backoff.cpp +165 -0
- package/deps/librdkafka/tests/0128-sasl_callback_queue.cpp +125 -0
- package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +78 -0
- package/deps/librdkafka/tests/0130-store_offsets.c +178 -0
- package/deps/librdkafka/tests/0131-connect_timeout.c +81 -0
- package/deps/librdkafka/tests/0132-strategy_ordering.c +171 -0
- package/deps/librdkafka/tests/0133-ssl_keys.c +128 -0
- package/deps/librdkafka/tests/0134-ssl_provider.c +92 -0
- package/deps/librdkafka/tests/0135-sasl_credentials.cpp +143 -0
- package/deps/librdkafka/tests/0136-resolve_cb.c +181 -0
- package/deps/librdkafka/tests/0137-barrier_batch_consume.c +609 -0
- package/deps/librdkafka/tests/0138-admin_mock.c +281 -0
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +442 -0
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +108 -0
- package/deps/librdkafka/tests/0142-reauthentication.c +495 -0
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +553 -0
- package/deps/librdkafka/tests/0144-idempotence_mock.c +373 -0
- package/deps/librdkafka/tests/0145-pause_resume_mock.c +119 -0
- package/deps/librdkafka/tests/0146-metadata_mock.c +444 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +648 -0
- package/deps/librdkafka/tests/1000-unktopic.c +164 -0
- package/deps/librdkafka/tests/8000-idle.cpp +60 -0
- package/deps/librdkafka/tests/8001-fetch_from_follower_mock_manual.c +113 -0
- package/deps/librdkafka/tests/CMakeLists.txt +164 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +266 -0
- package/deps/librdkafka/tests/Makefile +182 -0
- package/deps/librdkafka/tests/README.md +509 -0
- package/deps/librdkafka/tests/autotest.sh +33 -0
- package/deps/librdkafka/tests/backtrace.gdb +30 -0
- package/deps/librdkafka/tests/broker_version_tests.py +315 -0
- package/deps/librdkafka/tests/buildbox.sh +17 -0
- package/deps/librdkafka/tests/cleanup-checker-tests.sh +20 -0
- package/deps/librdkafka/tests/cluster_testing.py +191 -0
- package/deps/librdkafka/tests/delete-test-topics.sh +56 -0
- package/deps/librdkafka/tests/fixtures/ssl/Makefile +8 -0
- package/deps/librdkafka/tests/fixtures/ssl/README.md +13 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +109 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +34 -0
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +93 -0
- package/deps/librdkafka/tests/fuzzers/Makefile +12 -0
- package/deps/librdkafka/tests/fuzzers/README.md +31 -0
- package/deps/librdkafka/tests/fuzzers/fuzz_regex.c +74 -0
- package/deps/librdkafka/tests/fuzzers/helpers.h +90 -0
- package/deps/librdkafka/tests/gen-ssl-certs.sh +165 -0
- package/deps/librdkafka/tests/interactive_broker_version.py +170 -0
- package/deps/librdkafka/tests/interceptor_test/CMakeLists.txt +16 -0
- package/deps/librdkafka/tests/interceptor_test/Makefile +22 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.c +314 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.h +54 -0
- package/deps/librdkafka/tests/java/IncrementalRebalanceCli.java +97 -0
- package/deps/librdkafka/tests/java/Makefile +12 -0
- package/deps/librdkafka/tests/java/Murmur2Cli.java +46 -0
- package/deps/librdkafka/tests/java/README.md +14 -0
- package/deps/librdkafka/tests/java/TransactionProducerCli.java +162 -0
- package/deps/librdkafka/tests/java/run-class.sh +11 -0
- package/deps/librdkafka/tests/librdkafka.suppressions +483 -0
- package/deps/librdkafka/tests/lz4_manual_test.sh +59 -0
- package/deps/librdkafka/tests/multi-broker-version-test.sh +50 -0
- package/deps/librdkafka/tests/parse-refcnt.sh +43 -0
- package/deps/librdkafka/tests/performance_plot.py +115 -0
- package/deps/librdkafka/tests/plugin_test/Makefile +19 -0
- package/deps/librdkafka/tests/plugin_test/plugin_test.c +58 -0
- package/deps/librdkafka/tests/requirements.txt +2 -0
- package/deps/librdkafka/tests/run-consumer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-producer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-test.sh +140 -0
- package/deps/librdkafka/tests/rusage.c +249 -0
- package/deps/librdkafka/tests/sasl_test.py +289 -0
- package/deps/librdkafka/tests/scenarios/README.md +6 -0
- package/deps/librdkafka/tests/scenarios/ak23.json +6 -0
- package/deps/librdkafka/tests/scenarios/default.json +5 -0
- package/deps/librdkafka/tests/scenarios/noautocreate.json +5 -0
- package/deps/librdkafka/tests/sockem.c +801 -0
- package/deps/librdkafka/tests/sockem.h +85 -0
- package/deps/librdkafka/tests/sockem_ctrl.c +145 -0
- package/deps/librdkafka/tests/sockem_ctrl.h +61 -0
- package/deps/librdkafka/tests/test.c +7318 -0
- package/deps/librdkafka/tests/test.conf.example +27 -0
- package/deps/librdkafka/tests/test.h +979 -0
- package/deps/librdkafka/tests/testcpp.cpp +126 -0
- package/deps/librdkafka/tests/testcpp.h +360 -0
- package/deps/librdkafka/tests/testshared.h +402 -0
- package/deps/librdkafka/tests/tools/README.md +4 -0
- package/deps/librdkafka/tests/tools/stats/README.md +21 -0
- package/deps/librdkafka/tests/tools/stats/filter.jq +42 -0
- package/deps/librdkafka/tests/tools/stats/graph.py +150 -0
- package/deps/librdkafka/tests/tools/stats/requirements.txt +3 -0
- package/deps/librdkafka/tests/tools/stats/to_csv.py +124 -0
- package/deps/librdkafka/tests/until-fail.sh +87 -0
- package/deps/librdkafka/tests/xxxx-assign_partition.c +122 -0
- package/deps/librdkafka/tests/xxxx-metadata.cpp +159 -0
- package/deps/librdkafka/vcpkg.json +23 -0
- package/deps/librdkafka/win32/README.md +5 -0
- package/deps/librdkafka/win32/build-package.bat +3 -0
- package/deps/librdkafka/win32/build.bat +19 -0
- package/deps/librdkafka/win32/common.vcxproj +84 -0
- package/deps/librdkafka/win32/install-openssl.ps1 +33 -0
- package/deps/librdkafka/win32/interceptor_test/interceptor_test.vcxproj +87 -0
- package/deps/librdkafka/win32/librdkafka.autopkg.template +54 -0
- package/deps/librdkafka/win32/librdkafka.master.testing.targets +13 -0
- package/deps/librdkafka/win32/librdkafka.sln +226 -0
- package/deps/librdkafka/win32/librdkafka.vcxproj +276 -0
- package/deps/librdkafka/win32/librdkafkacpp/librdkafkacpp.vcxproj +104 -0
- package/deps/librdkafka/win32/msbuild.ps1 +15 -0
- package/deps/librdkafka/win32/openssl_engine_example/openssl_engine_example.vcxproj +132 -0
- package/deps/librdkafka/win32/package-zip.ps1 +46 -0
- package/deps/librdkafka/win32/packages/repositories.config +4 -0
- package/deps/librdkafka/win32/push-package.bat +4 -0
- package/deps/librdkafka/win32/rdkafka_complex_consumer_example_cpp/rdkafka_complex_consumer_example_cpp.vcxproj +67 -0
- package/deps/librdkafka/win32/rdkafka_example/rdkafka_example.vcxproj +97 -0
- package/deps/librdkafka/win32/rdkafka_performance/rdkafka_performance.vcxproj +97 -0
- package/deps/librdkafka/win32/setup-msys2.ps1 +31 -0
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +12 -0
- package/deps/librdkafka/win32/tests/test.conf.example +25 -0
- package/deps/librdkafka/win32/tests/tests.vcxproj +247 -0
- package/deps/librdkafka/win32/win_ssl_cert_store/win_ssl_cert_store.vcxproj +132 -0
- package/deps/librdkafka/win32/wingetopt.c +564 -0
- package/deps/librdkafka/win32/wingetopt.h +100 -0
- package/deps/librdkafka/win32/wintime.h +33 -0
- package/deps/librdkafka.gyp +62 -0
- package/deps/windows-install.py +73 -0
- package/docker-compose.yml +23 -0
- package/e2e/admin.spec.js +187 -0
- package/e2e/both.spec.js +726 -0
- package/e2e/consumer.spec.js +386 -0
- package/e2e/groups.spec.js +132 -0
- package/e2e/listener.js +51 -0
- package/e2e/producer-transaction.spec.js +333 -0
- package/e2e/producer.spec.js +283 -0
- package/errors.d.ts +347 -0
- package/examples/consumer-flow.md +76 -0
- package/examples/consumer.md +45 -0
- package/examples/docker-alpine.md +30 -0
- package/examples/high-level-producer.md +32 -0
- package/examples/metadata.md +27 -0
- package/examples/oauthbearer-default-flow.md +80 -0
- package/examples/producer-cluster.md +103 -0
- package/examples/producer.md +73 -0
- package/index.d.ts +357 -0
- package/lib/admin.js +233 -0
- package/lib/client.js +578 -0
- package/lib/error.js +472 -0
- package/lib/index.js +34 -0
- package/lib/kafka-consumer-stream.js +397 -0
- package/lib/kafka-consumer.js +698 -0
- package/lib/producer/high-level-producer.js +323 -0
- package/lib/producer-stream.js +307 -0
- package/lib/producer.js +375 -0
- package/lib/tools/ref-counter.js +52 -0
- package/lib/topic-partition.js +88 -0
- package/lib/topic.js +42 -0
- package/lib/util.js +29 -0
- package/librdkafka.js +12 -0
- package/make_docs.sh +59 -0
- package/package.json +53 -0
- package/renovate.json +30 -0
- package/run_docker.sh +42 -0
- package/src/admin.cc +624 -0
- package/src/admin.h +78 -0
- package/src/binding.cc +73 -0
- package/src/binding.h +25 -0
- package/src/callbacks.cc +614 -0
- package/src/callbacks.h +265 -0
- package/src/common.cc +582 -0
- package/src/common.h +134 -0
- package/src/config.cc +167 -0
- package/src/config.h +45 -0
- package/src/connection.cc +482 -0
- package/src/connection.h +108 -0
- package/src/errors.cc +96 -0
- package/src/errors.h +53 -0
- package/src/kafka-consumer.cc +1457 -0
- package/src/kafka-consumer.h +136 -0
- package/src/per-isolate-data.cc +57 -0
- package/src/per-isolate-data.h +39 -0
- package/src/producer.cc +873 -0
- package/src/producer.h +125 -0
- package/src/topic.cc +180 -0
- package/src/topic.h +56 -0
- package/src/workers.cc +1245 -0
- package/src/workers.h +511 -0
- package/test/binding.spec.js +66 -0
- package/test/consumer.spec.js +91 -0
- package/test/error.spec.js +8 -0
- package/test/index.spec.js +8 -0
- package/test/kafka-consumer-stream.spec.js +298 -0
- package/test/kafka-consumer-worker.js +51 -0
- package/test/kafka-consumer.spec.js +86 -0
- package/test/mocha.opts +1 -0
- package/test/mock.js +55 -0
- package/test/producer/high-level-producer.spec.js +496 -0
- package/test/producer-stream.spec.js +723 -0
- package/test/producer-worker.js +53 -0
- package/test/producer.spec.js +120 -0
- package/test/tools/ref-counter.spec.js +53 -0
- package/test/topic-partition.spec.js +104 -0
- package/test/util.spec.js +46 -0
- package/util/configure.js +30 -0
- package/util/get-env.js +6 -0
- package/util/test-compile.js +11 -0
- package/util/test-producer-delivery.js +100 -0
- package/win_install.ps1 +2 -0
|
@@ -0,0 +1,1457 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* node-rdkafka - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016 Blizzard Entertainment
|
|
5
|
+
*
|
|
6
|
+
* This software may be modified and distributed under the terms
|
|
7
|
+
* of the MIT license. See the LICENSE.txt file for details.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include <string>
|
|
11
|
+
#include <vector>
|
|
12
|
+
|
|
13
|
+
#include "src/kafka-consumer.h"
|
|
14
|
+
#include "src/per-isolate-data.h"
|
|
15
|
+
#include "src/workers.h"
|
|
16
|
+
|
|
17
|
+
using Nan::FunctionCallbackInfo;
|
|
18
|
+
|
|
19
|
+
namespace NodeKafka {
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* @brief KafkaConsumer v8 wrapped object.
|
|
23
|
+
*
|
|
24
|
+
* Specializes the connection to wrap a consumer object through compositional
|
|
25
|
+
* inheritence. Establishes its prototype in node through `Init`
|
|
26
|
+
*
|
|
27
|
+
* @sa RdKafka::Handle
|
|
28
|
+
* @sa NodeKafka::Client
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
KafkaConsumer::KafkaConsumer(Conf* gconfig, Conf* tconfig):
|
|
32
|
+
Connection(gconfig, tconfig) {
|
|
33
|
+
std::string errstr;
|
|
34
|
+
|
|
35
|
+
m_gconfig->set("default_topic_conf", m_tconfig, errstr);
|
|
36
|
+
|
|
37
|
+
m_consume_loop = nullptr;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
void KafkaConsumer::delete_instance(void* arg) {
|
|
41
|
+
delete (static_cast<KafkaConsumer*>(arg));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
KafkaConsumer::~KafkaConsumer() {
|
|
45
|
+
// We only want to run this if it hasn't been run already
|
|
46
|
+
Disconnect();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Baton KafkaConsumer::Connect() {
|
|
50
|
+
if (IsConnected()) {
|
|
51
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
std::string errstr;
|
|
55
|
+
{
|
|
56
|
+
scoped_shared_write_lock lock(m_connection_lock);
|
|
57
|
+
m_client = RdKafka::KafkaConsumer::create(m_gconfig, errstr);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (!m_client || !errstr.empty()) {
|
|
61
|
+
return Baton(RdKafka::ERR__STATE, errstr);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (m_init_oauthToken) {
|
|
65
|
+
scoped_shared_write_lock lock(m_connection_lock);
|
|
66
|
+
if (m_init_oauthToken) {
|
|
67
|
+
std::list<std::string> emptyList;
|
|
68
|
+
std::string token = m_init_oauthToken->token;
|
|
69
|
+
int64_t expiry = m_init_oauthToken->expiry;
|
|
70
|
+
// needed for initial connection only
|
|
71
|
+
m_init_oauthToken.reset();
|
|
72
|
+
|
|
73
|
+
RdKafka::ErrorCode err = m_client->oauthbearer_set_token(token, expiry,
|
|
74
|
+
"", emptyList, errstr);
|
|
75
|
+
|
|
76
|
+
if (err != RdKafka::ERR_NO_ERROR) {
|
|
77
|
+
return Baton(err, errstr);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (m_partitions.size() > 0) {
|
|
83
|
+
m_client->resume(m_partitions);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
void KafkaConsumer::ActivateDispatchers() {
|
|
90
|
+
// Listen to global config
|
|
91
|
+
m_gconfig->listen();
|
|
92
|
+
|
|
93
|
+
// Listen to non global config
|
|
94
|
+
// tconfig->listen();
|
|
95
|
+
|
|
96
|
+
// This should be refactored to config based management
|
|
97
|
+
m_event_cb.dispatcher.Activate();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
Baton KafkaConsumer::Disconnect() {
|
|
101
|
+
// Only close client if it is connected
|
|
102
|
+
RdKafka::ErrorCode err = RdKafka::ERR_NO_ERROR;
|
|
103
|
+
|
|
104
|
+
if (IsConnected()) {
|
|
105
|
+
m_is_closing = true;
|
|
106
|
+
{
|
|
107
|
+
scoped_shared_write_lock lock(m_connection_lock);
|
|
108
|
+
|
|
109
|
+
RdKafka::KafkaConsumer* consumer =
|
|
110
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
111
|
+
err = consumer->close();
|
|
112
|
+
|
|
113
|
+
delete m_client;
|
|
114
|
+
m_client = NULL;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
m_is_closing = false;
|
|
119
|
+
|
|
120
|
+
return Baton(err);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
void KafkaConsumer::DeactivateDispatchers() {
|
|
124
|
+
// Stop listening to the config dispatchers
|
|
125
|
+
m_gconfig->stop();
|
|
126
|
+
|
|
127
|
+
// Also this one
|
|
128
|
+
m_event_cb.dispatcher.Deactivate();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
bool KafkaConsumer::IsSubscribed() {
|
|
132
|
+
if (!IsConnected()) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (!m_is_subscribed) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return true;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
bool KafkaConsumer::HasAssignedPartitions() {
|
|
145
|
+
return !m_partitions.empty();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
int KafkaConsumer::AssignedPartitionCount() {
|
|
149
|
+
return m_partition_cnt;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
Baton KafkaConsumer::GetWatermarkOffsets(
|
|
153
|
+
std::string topic_name, int32_t partition,
|
|
154
|
+
int64_t* low_offset, int64_t* high_offset) {
|
|
155
|
+
// Check if we are connected first
|
|
156
|
+
|
|
157
|
+
RdKafka::ErrorCode err;
|
|
158
|
+
|
|
159
|
+
if (IsConnected()) {
|
|
160
|
+
scoped_shared_read_lock lock(m_connection_lock);
|
|
161
|
+
if (IsConnected()) {
|
|
162
|
+
// Always send true - we
|
|
163
|
+
err = m_client->get_watermark_offsets(topic_name, partition,
|
|
164
|
+
low_offset, high_offset);
|
|
165
|
+
} else {
|
|
166
|
+
err = RdKafka::ERR__STATE;
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
err = RdKafka::ERR__STATE;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
return Baton(err);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
void KafkaConsumer::part_list_print(const std::vector<RdKafka::TopicPartition*> &partitions) { // NOLINT
|
|
176
|
+
for (unsigned int i = 0 ; i < partitions.size() ; i++)
|
|
177
|
+
std::cerr << partitions[i]->topic() <<
|
|
178
|
+
"[" << partitions[i]->partition() << "], ";
|
|
179
|
+
std::cerr << std::endl;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
Baton KafkaConsumer::Assign(std::vector<RdKafka::TopicPartition*> partitions) {
|
|
183
|
+
if (!IsConnected()) {
|
|
184
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is disconnected");
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
RdKafka::KafkaConsumer* consumer =
|
|
188
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
189
|
+
|
|
190
|
+
RdKafka::ErrorCode errcode = consumer->assign(partitions);
|
|
191
|
+
|
|
192
|
+
if (errcode == RdKafka::ERR_NO_ERROR) {
|
|
193
|
+
m_partition_cnt = partitions.size();
|
|
194
|
+
m_partitions.swap(partitions);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Destroy the partitions: Either we're using them (and partitions
|
|
198
|
+
// is now our old vector), or we're not using it as there was an
|
|
199
|
+
// error.
|
|
200
|
+
RdKafka::TopicPartition::destroy(partitions);
|
|
201
|
+
|
|
202
|
+
return Baton(errcode);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
Baton KafkaConsumer::Unassign() {
|
|
206
|
+
if (!IsClosing() && !IsConnected()) {
|
|
207
|
+
return Baton(RdKafka::ERR__STATE);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
RdKafka::KafkaConsumer* consumer =
|
|
211
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
212
|
+
|
|
213
|
+
RdKafka::ErrorCode errcode = consumer->unassign();
|
|
214
|
+
|
|
215
|
+
if (errcode != RdKafka::ERR_NO_ERROR) {
|
|
216
|
+
return Baton(errcode);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Destroy the old list of partitions since we are no longer using it
|
|
220
|
+
RdKafka::TopicPartition::destroy(m_partitions);
|
|
221
|
+
|
|
222
|
+
m_partition_cnt = 0;
|
|
223
|
+
|
|
224
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
Baton KafkaConsumer::IncrementalAssign(std::vector<RdKafka::TopicPartition*> partitions) {
|
|
228
|
+
if (!IsConnected()) {
|
|
229
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is disconnected");
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
RdKafka::KafkaConsumer* consumer =
|
|
233
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
234
|
+
|
|
235
|
+
RdKafka::Error* error = consumer->incremental_assign(partitions);
|
|
236
|
+
|
|
237
|
+
if (error == NULL) {
|
|
238
|
+
m_partition_cnt += partitions.size();
|
|
239
|
+
m_partitions.insert(m_partitions.end(), partitions.begin(), partitions.end());
|
|
240
|
+
} else {
|
|
241
|
+
RdKafka::TopicPartition::destroy(partitions);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
return rdkafkaErrorToBaton(error);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
Baton KafkaConsumer::IncrementalUnassign(std::vector<RdKafka::TopicPartition*> partitions) {
|
|
248
|
+
if (!IsClosing() && !IsConnected()) {
|
|
249
|
+
return Baton(RdKafka::ERR__STATE);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
RdKafka::KafkaConsumer* consumer =
|
|
253
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
254
|
+
|
|
255
|
+
RdKafka::Error* error = consumer->incremental_unassign(partitions);
|
|
256
|
+
|
|
257
|
+
std::vector<RdKafka::TopicPartition*> delete_partitions;
|
|
258
|
+
|
|
259
|
+
if (error == NULL) {
|
|
260
|
+
for (unsigned int i = 0; i < partitions.size(); i++) {
|
|
261
|
+
for (unsigned int j = 0; j < m_partitions.size(); j++) {
|
|
262
|
+
if (partitions[i]->partition() == m_partitions[j]->partition() &&
|
|
263
|
+
partitions[i]->topic() == m_partitions[j]->topic()) {
|
|
264
|
+
delete_partitions.push_back(m_partitions[j]);
|
|
265
|
+
m_partitions.erase(m_partitions.begin() + j);
|
|
266
|
+
m_partition_cnt--;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
RdKafka::TopicPartition::destroy(delete_partitions);
|
|
274
|
+
|
|
275
|
+
RdKafka::TopicPartition::destroy(partitions);
|
|
276
|
+
|
|
277
|
+
return rdkafkaErrorToBaton(error);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
Baton KafkaConsumer::Commit(std::vector<RdKafka::TopicPartition*> toppars) {
|
|
281
|
+
if (!IsConnected()) {
|
|
282
|
+
return Baton(RdKafka::ERR__STATE);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
RdKafka::KafkaConsumer* consumer =
|
|
286
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
287
|
+
|
|
288
|
+
RdKafka::ErrorCode err = consumer->commitAsync(toppars);
|
|
289
|
+
|
|
290
|
+
return Baton(err);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
Baton KafkaConsumer::Commit(RdKafka::TopicPartition * toppar) {
|
|
294
|
+
if (!IsConnected()) {
|
|
295
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
RdKafka::KafkaConsumer* consumer =
|
|
299
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
300
|
+
|
|
301
|
+
// Need to put topic in a vector for it to work
|
|
302
|
+
std::vector<RdKafka::TopicPartition*> offsets = {toppar};
|
|
303
|
+
RdKafka::ErrorCode err = consumer->commitAsync(offsets);
|
|
304
|
+
|
|
305
|
+
return Baton(err);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
Baton KafkaConsumer::Commit() {
|
|
309
|
+
// sets an error message
|
|
310
|
+
if (!IsConnected()) {
|
|
311
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
RdKafka::KafkaConsumer* consumer =
|
|
315
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
316
|
+
|
|
317
|
+
RdKafka::ErrorCode err = consumer->commitAsync();
|
|
318
|
+
|
|
319
|
+
return Baton(err);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Synchronous commit events
|
|
323
|
+
Baton KafkaConsumer::CommitSync(std::vector<RdKafka::TopicPartition*> toppars) {
|
|
324
|
+
if (!IsConnected()) {
|
|
325
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
RdKafka::KafkaConsumer* consumer =
|
|
329
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
330
|
+
|
|
331
|
+
RdKafka::ErrorCode err = consumer->commitSync(toppars);
|
|
332
|
+
// RdKafka::TopicPartition::destroy(toppars);
|
|
333
|
+
|
|
334
|
+
return Baton(err);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
Baton KafkaConsumer::CommitSync(RdKafka::TopicPartition * toppar) {
|
|
338
|
+
if (!IsConnected()) {
|
|
339
|
+
return Baton(RdKafka::ERR__STATE);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
RdKafka::KafkaConsumer* consumer =
|
|
343
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
344
|
+
|
|
345
|
+
// Need to put topic in a vector for it to work
|
|
346
|
+
std::vector<RdKafka::TopicPartition*> offsets = {toppar};
|
|
347
|
+
RdKafka::ErrorCode err = consumer->commitSync(offsets);
|
|
348
|
+
|
|
349
|
+
return Baton(err);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
Baton KafkaConsumer::CommitSync() {
|
|
353
|
+
// sets an error message
|
|
354
|
+
if (!IsConnected()) {
|
|
355
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
RdKafka::KafkaConsumer* consumer =
|
|
359
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
360
|
+
|
|
361
|
+
RdKafka::ErrorCode err = consumer->commitSync();
|
|
362
|
+
|
|
363
|
+
return Baton(err);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
Baton KafkaConsumer::Seek(const RdKafka::TopicPartition &partition, int timeout_ms) { // NOLINT
|
|
367
|
+
if (!IsConnected()) {
|
|
368
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
RdKafka::KafkaConsumer* consumer =
|
|
372
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
373
|
+
|
|
374
|
+
RdKafka::ErrorCode err = consumer->seek(partition, timeout_ms);
|
|
375
|
+
|
|
376
|
+
return Baton(err);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
Baton KafkaConsumer::Committed(std::vector<RdKafka::TopicPartition*> &toppars,
|
|
380
|
+
int timeout_ms) {
|
|
381
|
+
if (!IsConnected()) {
|
|
382
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
RdKafka::KafkaConsumer* consumer =
|
|
386
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
387
|
+
|
|
388
|
+
RdKafka::ErrorCode err = consumer->committed(toppars, timeout_ms);
|
|
389
|
+
|
|
390
|
+
return Baton(err);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
Baton KafkaConsumer::Position(std::vector<RdKafka::TopicPartition*> &toppars) {
|
|
394
|
+
if (!IsConnected()) {
|
|
395
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
RdKafka::KafkaConsumer* consumer =
|
|
399
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
400
|
+
|
|
401
|
+
RdKafka::ErrorCode err = consumer->position(toppars);
|
|
402
|
+
|
|
403
|
+
return Baton(err);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
Baton KafkaConsumer::Subscription() {
|
|
407
|
+
if (!IsConnected()) {
|
|
408
|
+
return Baton(RdKafka::ERR__STATE, "Consumer is not connected");
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
RdKafka::KafkaConsumer* consumer =
|
|
412
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
413
|
+
|
|
414
|
+
// Needs to be a pointer since we're returning it through the baton
|
|
415
|
+
std::vector<std::string> * topics = new std::vector<std::string>;
|
|
416
|
+
|
|
417
|
+
RdKafka::ErrorCode err = consumer->subscription(*topics);
|
|
418
|
+
|
|
419
|
+
if (err == RdKafka::ErrorCode::ERR_NO_ERROR) {
|
|
420
|
+
// Good to go
|
|
421
|
+
return Baton(topics);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return Baton(err);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
Baton KafkaConsumer::Unsubscribe() {
|
|
428
|
+
if (IsConnected() && IsSubscribed()) {
|
|
429
|
+
RdKafka::KafkaConsumer* consumer =
|
|
430
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
431
|
+
consumer->unsubscribe();
|
|
432
|
+
m_is_subscribed = false;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
Baton KafkaConsumer::Pause(std::vector<RdKafka::TopicPartition*> & toppars) {
|
|
439
|
+
if (IsConnected()) {
|
|
440
|
+
RdKafka::KafkaConsumer* consumer =
|
|
441
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
442
|
+
RdKafka::ErrorCode err = consumer->pause(toppars);
|
|
443
|
+
|
|
444
|
+
return Baton(err);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
return Baton(RdKafka::ERR__STATE);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
Baton KafkaConsumer::Resume(std::vector<RdKafka::TopicPartition*> & toppars) {
|
|
451
|
+
if (IsConnected()) {
|
|
452
|
+
RdKafka::KafkaConsumer* consumer =
|
|
453
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
454
|
+
RdKafka::ErrorCode err = consumer->resume(toppars);
|
|
455
|
+
|
|
456
|
+
return Baton(err);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return Baton(RdKafka::ERR__STATE);
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
Baton KafkaConsumer::OffsetsStore(std::vector<RdKafka::TopicPartition*> & toppars) { // NOLINT
|
|
463
|
+
if (IsConnected() && IsSubscribed()) {
|
|
464
|
+
RdKafka::KafkaConsumer* consumer =
|
|
465
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
466
|
+
RdKafka::ErrorCode err = consumer->offsets_store(toppars);
|
|
467
|
+
|
|
468
|
+
return Baton(err);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return Baton(RdKafka::ERR__STATE);
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
Baton KafkaConsumer::Subscribe(std::vector<std::string> topics) {
|
|
475
|
+
if (!IsConnected()) {
|
|
476
|
+
return Baton(RdKafka::ERR__STATE);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
RdKafka::KafkaConsumer* consumer =
|
|
480
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
481
|
+
|
|
482
|
+
RdKafka::ErrorCode errcode = consumer->subscribe(topics);
|
|
483
|
+
if (errcode != RdKafka::ERR_NO_ERROR) {
|
|
484
|
+
return Baton(errcode);
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
m_is_subscribed = true;
|
|
488
|
+
|
|
489
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
Baton KafkaConsumer::Consume(int timeout_ms) {
|
|
493
|
+
if (IsConnected()) {
|
|
494
|
+
scoped_shared_read_lock lock(m_connection_lock);
|
|
495
|
+
if (!IsConnected()) {
|
|
496
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
497
|
+
} else {
|
|
498
|
+
RdKafka::KafkaConsumer* consumer =
|
|
499
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
500
|
+
|
|
501
|
+
RdKafka::Message * message = consumer->consume(timeout_ms);
|
|
502
|
+
RdKafka::ErrorCode response_code = message->err();
|
|
503
|
+
// we want to handle these errors at the call site
|
|
504
|
+
if (response_code != RdKafka::ERR_NO_ERROR &&
|
|
505
|
+
response_code != RdKafka::ERR__PARTITION_EOF &&
|
|
506
|
+
response_code != RdKafka::ERR__TIMED_OUT &&
|
|
507
|
+
response_code != RdKafka::ERR__TIMED_OUT_QUEUE
|
|
508
|
+
) {
|
|
509
|
+
delete message;
|
|
510
|
+
return Baton(response_code);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
return Baton(message);
|
|
514
|
+
}
|
|
515
|
+
} else {
|
|
516
|
+
return Baton(RdKafka::ERR__STATE, "KafkaConsumer is not connected");
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
Baton KafkaConsumer::RefreshAssignments() {
|
|
521
|
+
if (!IsConnected()) {
|
|
522
|
+
return Baton(RdKafka::ERR__STATE);
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
RdKafka::KafkaConsumer* consumer =
|
|
526
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
527
|
+
|
|
528
|
+
std::vector<RdKafka::TopicPartition*> partition_list;
|
|
529
|
+
RdKafka::ErrorCode err = consumer->assignment(partition_list);
|
|
530
|
+
|
|
531
|
+
switch (err) {
|
|
532
|
+
case RdKafka::ERR_NO_ERROR:
|
|
533
|
+
m_partition_cnt = partition_list.size();
|
|
534
|
+
m_partitions.swap(partition_list);
|
|
535
|
+
|
|
536
|
+
// These are pointers so we need to delete them somewhere.
|
|
537
|
+
// Do it here because we're only going to convert when we're ready
|
|
538
|
+
// to return to v8.
|
|
539
|
+
RdKafka::TopicPartition::destroy(partition_list);
|
|
540
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
541
|
+
break;
|
|
542
|
+
default:
|
|
543
|
+
return Baton(err);
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
std::string KafkaConsumer::Name() {
|
|
549
|
+
if (!IsConnected()) {
|
|
550
|
+
return std::string("");
|
|
551
|
+
}
|
|
552
|
+
return std::string(m_client->name());
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
std::string KafkaConsumer::RebalanceProtocol() {
|
|
556
|
+
if (!IsConnected()) {
|
|
557
|
+
return std::string("NONE");
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
RdKafka::KafkaConsumer* consumer =
|
|
561
|
+
dynamic_cast<RdKafka::KafkaConsumer*>(m_client);
|
|
562
|
+
|
|
563
|
+
return consumer->rebalance_protocol();
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
void KafkaConsumer::Init(v8::Local<v8::Object> exports) {
|
|
567
|
+
Nan::HandleScope scope;
|
|
568
|
+
|
|
569
|
+
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
|
570
|
+
tpl->SetClassName(Nan::New("KafkaConsumer").ToLocalChecked());
|
|
571
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
572
|
+
|
|
573
|
+
/*
|
|
574
|
+
* Lifecycle events inherited from NodeKafka::Connection
|
|
575
|
+
*
|
|
576
|
+
* @sa NodeKafka::Connection
|
|
577
|
+
*/
|
|
578
|
+
|
|
579
|
+
Nan::SetPrototypeMethod(tpl, "configureCallbacks", NodeConfigureCallbacks);
|
|
580
|
+
|
|
581
|
+
/*
|
|
582
|
+
* @brief Methods to do with establishing state
|
|
583
|
+
*/
|
|
584
|
+
|
|
585
|
+
Nan::SetPrototypeMethod(tpl, "connect", NodeConnect);
|
|
586
|
+
Nan::SetPrototypeMethod(tpl, "disconnect", NodeDisconnect);
|
|
587
|
+
Nan::SetPrototypeMethod(tpl, "setToken", NodeSetToken);
|
|
588
|
+
Nan::SetPrototypeMethod(tpl, "getMetadata", NodeGetMetadata);
|
|
589
|
+
Nan::SetPrototypeMethod(tpl, "queryWatermarkOffsets", NodeQueryWatermarkOffsets); // NOLINT
|
|
590
|
+
Nan::SetPrototypeMethod(tpl, "offsetsForTimes", NodeOffsetsForTimes);
|
|
591
|
+
Nan::SetPrototypeMethod(tpl, "getWatermarkOffsets", NodeGetWatermarkOffsets);
|
|
592
|
+
|
|
593
|
+
/*
|
|
594
|
+
* @brief Methods exposed to do with message retrieval
|
|
595
|
+
*/
|
|
596
|
+
Nan::SetPrototypeMethod(tpl, "subscription", NodeSubscription);
|
|
597
|
+
Nan::SetPrototypeMethod(tpl, "subscribe", NodeSubscribe);
|
|
598
|
+
Nan::SetPrototypeMethod(tpl, "unsubscribe", NodeUnsubscribe);
|
|
599
|
+
Nan::SetPrototypeMethod(tpl, "consumeLoop", NodeConsumeLoop);
|
|
600
|
+
Nan::SetPrototypeMethod(tpl, "consume", NodeConsume);
|
|
601
|
+
Nan::SetPrototypeMethod(tpl, "seek", NodeSeek);
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* @brief Pausing and resuming
|
|
605
|
+
*/
|
|
606
|
+
Nan::SetPrototypeMethod(tpl, "pause", NodePause);
|
|
607
|
+
Nan::SetPrototypeMethod(tpl, "resume", NodeResume);
|
|
608
|
+
|
|
609
|
+
/*
|
|
610
|
+
* @brief Methods to do with partition assignment / rebalancing
|
|
611
|
+
*/
|
|
612
|
+
|
|
613
|
+
Nan::SetPrototypeMethod(tpl, "committed", NodeCommitted);
|
|
614
|
+
Nan::SetPrototypeMethod(tpl, "position", NodePosition);
|
|
615
|
+
Nan::SetPrototypeMethod(tpl, "assign", NodeAssign);
|
|
616
|
+
Nan::SetPrototypeMethod(tpl, "unassign", NodeUnassign);
|
|
617
|
+
Nan::SetPrototypeMethod(tpl, "incrementalAssign", NodeIncrementalAssign);
|
|
618
|
+
Nan::SetPrototypeMethod(tpl, "incrementalUnassign", NodeIncrementalUnassign);
|
|
619
|
+
Nan::SetPrototypeMethod(tpl, "assignments", NodeAssignments);
|
|
620
|
+
Nan::SetPrototypeMethod(tpl, "rebalanceProtocol", NodeRebalanceProtocol);
|
|
621
|
+
|
|
622
|
+
Nan::SetPrototypeMethod(tpl, "commit", NodeCommit);
|
|
623
|
+
Nan::SetPrototypeMethod(tpl, "commitSync", NodeCommitSync);
|
|
624
|
+
Nan::SetPrototypeMethod(tpl, "offsetsStore", NodeOffsetsStore);
|
|
625
|
+
|
|
626
|
+
PerIsolateData::For(v8::Isolate::GetCurrent())->KafkaConsumerConstructor()
|
|
627
|
+
.Reset((tpl->GetFunction(Nan::GetCurrentContext()))
|
|
628
|
+
.ToLocalChecked());
|
|
629
|
+
Nan::Set(exports, Nan::New("KafkaConsumer").ToLocalChecked(),
|
|
630
|
+
(tpl->GetFunction(Nan::GetCurrentContext())).ToLocalChecked());
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
void KafkaConsumer::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
634
|
+
if (!info.IsConstructCall()) {
|
|
635
|
+
return Nan::ThrowError("non-constructor invocation not supported");
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
if (info.Length() < 2) {
|
|
639
|
+
return Nan::ThrowError("You must supply global and topic configuration");
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
if (!info[0]->IsObject()) {
|
|
643
|
+
return Nan::ThrowError("Global configuration data must be specified");
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
if (!info[1]->IsObject()) {
|
|
647
|
+
return Nan::ThrowError("Topic configuration must be specified");
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
std::string errstr;
|
|
651
|
+
|
|
652
|
+
Conf* gconfig =
|
|
653
|
+
Conf::create(RdKafka::Conf::CONF_GLOBAL,
|
|
654
|
+
(info[0]->ToObject(Nan::GetCurrentContext())).ToLocalChecked(), errstr);
|
|
655
|
+
|
|
656
|
+
if (!gconfig) {
|
|
657
|
+
return Nan::ThrowError(errstr.c_str());
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
Conf* tconfig =
|
|
661
|
+
Conf::create(RdKafka::Conf::CONF_TOPIC,
|
|
662
|
+
(info[1]->ToObject(Nan::GetCurrentContext())).ToLocalChecked(), errstr);
|
|
663
|
+
|
|
664
|
+
if (!tconfig) {
|
|
665
|
+
delete gconfig;
|
|
666
|
+
return Nan::ThrowError(errstr.c_str());
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
KafkaConsumer* consumer = new KafkaConsumer(gconfig, tconfig);
|
|
670
|
+
|
|
671
|
+
// Wrap it
|
|
672
|
+
consumer->Wrap(info.This());
|
|
673
|
+
|
|
674
|
+
// Then there is some weird initialization that happens
|
|
675
|
+
// basically it sets the configuration data
|
|
676
|
+
// we don't need to do that because we lazy load it
|
|
677
|
+
|
|
678
|
+
info.GetReturnValue().Set(info.This());
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
v8::Local<v8::Object> KafkaConsumer::NewInstance(v8::Local<v8::Value> arg) {
|
|
682
|
+
Nan::EscapableHandleScope scope;
|
|
683
|
+
|
|
684
|
+
const unsigned argc = 1;
|
|
685
|
+
|
|
686
|
+
v8::Local<v8::Value> argv[argc] = { arg };
|
|
687
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(
|
|
688
|
+
PerIsolateData::For(v8::Isolate::GetCurrent())->KafkaConsumerConstructor());
|
|
689
|
+
v8::Local<v8::Object> instance =
|
|
690
|
+
Nan::NewInstance(cons, argc, argv).ToLocalChecked();
|
|
691
|
+
|
|
692
|
+
return scope.Escape(instance);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/* Node exposed methods */
|
|
696
|
+
|
|
697
|
+
NAN_METHOD(KafkaConsumer::NodeCommitted) {
|
|
698
|
+
Nan::HandleScope scope;
|
|
699
|
+
|
|
700
|
+
if (info.Length() < 3 || !info[0]->IsArray()) {
|
|
701
|
+
// Just throw an exception
|
|
702
|
+
return Nan::ThrowError("Need to specify an array of topic partitions");
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
706
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
707
|
+
|
|
708
|
+
int timeout_ms;
|
|
709
|
+
Nan::Maybe<uint32_t> maybeTimeout =
|
|
710
|
+
Nan::To<uint32_t>(info[1].As<v8::Number>());
|
|
711
|
+
|
|
712
|
+
if (maybeTimeout.IsNothing()) {
|
|
713
|
+
timeout_ms = 1000;
|
|
714
|
+
} else {
|
|
715
|
+
timeout_ms = static_cast<int>(maybeTimeout.FromJust());
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
v8::Local<v8::Function> cb = info[2].As<v8::Function>();
|
|
719
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
720
|
+
|
|
721
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
722
|
+
|
|
723
|
+
Nan::AsyncQueueWorker(
|
|
724
|
+
new Workers::KafkaConsumerCommitted(callback, consumer,
|
|
725
|
+
toppars, timeout_ms));
|
|
726
|
+
|
|
727
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
NAN_METHOD(KafkaConsumer::NodeSubscription) {
|
|
731
|
+
Nan::HandleScope scope;
|
|
732
|
+
|
|
733
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
734
|
+
|
|
735
|
+
Baton b = consumer->Subscription();
|
|
736
|
+
|
|
737
|
+
if (b.err() != RdKafka::ErrorCode::ERR_NO_ERROR) {
|
|
738
|
+
// Let the JS library throw if we need to so the error can be more rich
|
|
739
|
+
int error_code = static_cast<int>(b.err());
|
|
740
|
+
return info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
std::vector<std::string> * topics = b.data<std::vector<std::string>*>();
|
|
744
|
+
|
|
745
|
+
info.GetReturnValue().Set(Conversion::Topic::ToV8Array(*topics));
|
|
746
|
+
|
|
747
|
+
delete topics;
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
NAN_METHOD(KafkaConsumer::NodePosition) {
|
|
751
|
+
Nan::HandleScope scope;
|
|
752
|
+
|
|
753
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
754
|
+
|
|
755
|
+
if (info.Length() < 1 || !info[0]->IsArray()) {
|
|
756
|
+
// Just throw an exception
|
|
757
|
+
return Nan::ThrowError("Need to specify an array of topic partitions");
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
761
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
762
|
+
|
|
763
|
+
Baton b = consumer->Position(toppars);
|
|
764
|
+
|
|
765
|
+
if (b.err() != RdKafka::ErrorCode::ERR_NO_ERROR) {
|
|
766
|
+
// Let the JS library throw if we need to so the error can be more rich
|
|
767
|
+
int error_code = static_cast<int>(b.err());
|
|
768
|
+
return info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
info.GetReturnValue().Set(
|
|
772
|
+
Conversion::TopicPartition::ToV8Array(toppars));
|
|
773
|
+
|
|
774
|
+
// Delete the underlying topic partitions
|
|
775
|
+
RdKafka::TopicPartition::destroy(toppars);
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
NAN_METHOD(KafkaConsumer::NodeAssignments) {
|
|
779
|
+
Nan::HandleScope scope;
|
|
780
|
+
|
|
781
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
782
|
+
|
|
783
|
+
Baton b = consumer->RefreshAssignments();
|
|
784
|
+
|
|
785
|
+
if (b.err() != RdKafka::ERR_NO_ERROR) {
|
|
786
|
+
// Let the JS library throw if we need to so the error can be more rich
|
|
787
|
+
int error_code = static_cast<int>(b.err());
|
|
788
|
+
return info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
info.GetReturnValue().Set(
|
|
792
|
+
Conversion::TopicPartition::ToV8Array(consumer->m_partitions));
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
NAN_METHOD(KafkaConsumer::NodeRebalanceProtocol) {
|
|
796
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
797
|
+
std::string protocol = consumer->RebalanceProtocol();
|
|
798
|
+
info.GetReturnValue().Set(Nan::New<v8::String>(protocol).ToLocalChecked());
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
NAN_METHOD(KafkaConsumer::NodeAssign) {
|
|
802
|
+
Nan::HandleScope scope;
|
|
803
|
+
|
|
804
|
+
if (info.Length() < 1 || !info[0]->IsArray()) {
|
|
805
|
+
// Just throw an exception
|
|
806
|
+
return Nan::ThrowError("Need to specify an array of partitions");
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
v8::Local<v8::Array> partitions = info[0].As<v8::Array>();
|
|
810
|
+
std::vector<RdKafka::TopicPartition*> topic_partitions;
|
|
811
|
+
|
|
812
|
+
for (unsigned int i = 0; i < partitions->Length(); ++i) {
|
|
813
|
+
v8::Local<v8::Value> partition_obj_value;
|
|
814
|
+
if (!(
|
|
815
|
+
Nan::Get(partitions, i).ToLocal(&partition_obj_value) &&
|
|
816
|
+
partition_obj_value->IsObject())) {
|
|
817
|
+
Nan::ThrowError("Must pass topic-partition objects");
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
v8::Local<v8::Object> partition_obj = partition_obj_value.As<v8::Object>();
|
|
821
|
+
|
|
822
|
+
// Got the object
|
|
823
|
+
int64_t partition = GetParameter<int64_t>(partition_obj, "partition", -1);
|
|
824
|
+
std::string topic = GetParameter<std::string>(partition_obj, "topic", "");
|
|
825
|
+
|
|
826
|
+
if (!topic.empty()) {
|
|
827
|
+
RdKafka::TopicPartition* part;
|
|
828
|
+
|
|
829
|
+
if (partition < 0) {
|
|
830
|
+
part = Connection::GetPartition(topic);
|
|
831
|
+
} else {
|
|
832
|
+
part = Connection::GetPartition(topic, partition);
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// Set the default value to offset invalid. If provided, we will not set
|
|
836
|
+
// the offset.
|
|
837
|
+
int64_t offset = GetParameter<int64_t>(
|
|
838
|
+
partition_obj, "offset", RdKafka::Topic::OFFSET_INVALID);
|
|
839
|
+
if (offset != RdKafka::Topic::OFFSET_INVALID) {
|
|
840
|
+
part->set_offset(offset);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
topic_partitions.push_back(part);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
848
|
+
|
|
849
|
+
// Hand over the partitions to the consumer.
|
|
850
|
+
Baton b = consumer->Assign(topic_partitions);
|
|
851
|
+
|
|
852
|
+
if (b.err() != RdKafka::ERR_NO_ERROR) {
|
|
853
|
+
Nan::ThrowError(RdKafka::err2str(b.err()).c_str());
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
info.GetReturnValue().Set(Nan::True());
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
NAN_METHOD(KafkaConsumer::NodeUnassign) {
|
|
860
|
+
Nan::HandleScope scope;
|
|
861
|
+
|
|
862
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
863
|
+
|
|
864
|
+
|
|
865
|
+
if (!consumer->IsClosing() && !consumer->IsConnected()) {
|
|
866
|
+
Nan::ThrowError("KafkaConsumer is disconnected");
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
Baton b = consumer->Unassign();
|
|
871
|
+
|
|
872
|
+
if (b.err() != RdKafka::ERR_NO_ERROR) {
|
|
873
|
+
Nan::ThrowError(RdKafka::err2str(b.err()).c_str());
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
info.GetReturnValue().Set(Nan::True());
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
NAN_METHOD(KafkaConsumer::NodeIncrementalAssign) {
|
|
880
|
+
Nan::HandleScope scope;
|
|
881
|
+
|
|
882
|
+
if (info.Length() < 1 || !info[0]->IsArray()) {
|
|
883
|
+
return Nan::ThrowError("Need to specify an array of partitions");
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
v8::Local<v8::Array> partitions = info[0].As<v8::Array>();
|
|
887
|
+
std::vector<RdKafka::TopicPartition*> topic_partitions;
|
|
888
|
+
|
|
889
|
+
for (unsigned int i = 0; i < partitions->Length(); ++i) {
|
|
890
|
+
v8::Local<v8::Value> partition_obj_value;
|
|
891
|
+
if (!(
|
|
892
|
+
Nan::Get(partitions, i).ToLocal(&partition_obj_value) &&
|
|
893
|
+
partition_obj_value->IsObject())) {
|
|
894
|
+
Nan::ThrowError("Must pass topic-partition objects");
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
v8::Local<v8::Object> partition_obj = partition_obj_value.As<v8::Object>();
|
|
898
|
+
|
|
899
|
+
int64_t partition = GetParameter<int64_t>(partition_obj, "partition", -1);
|
|
900
|
+
std::string topic = GetParameter<std::string>(partition_obj, "topic", "");
|
|
901
|
+
|
|
902
|
+
if (!topic.empty()) {
|
|
903
|
+
RdKafka::TopicPartition* part;
|
|
904
|
+
|
|
905
|
+
if (partition < 0) {
|
|
906
|
+
part = Connection::GetPartition(topic);
|
|
907
|
+
} else {
|
|
908
|
+
part = Connection::GetPartition(topic, partition);
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
int64_t offset = GetParameter<int64_t>(
|
|
912
|
+
partition_obj, "offset", RdKafka::Topic::OFFSET_INVALID);
|
|
913
|
+
if (offset != RdKafka::Topic::OFFSET_INVALID) {
|
|
914
|
+
part->set_offset(offset);
|
|
915
|
+
}
|
|
916
|
+
|
|
917
|
+
topic_partitions.push_back(part);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
|
|
921
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
922
|
+
|
|
923
|
+
Baton b = consumer->IncrementalAssign(topic_partitions);
|
|
924
|
+
|
|
925
|
+
if (b.err() != RdKafka::ERR_NO_ERROR) {
|
|
926
|
+
v8::Local<v8::Value> errorObject = b.ToObject();
|
|
927
|
+
Nan::ThrowError(errorObject);
|
|
928
|
+
}
|
|
929
|
+
|
|
930
|
+
info.GetReturnValue().Set(Nan::True());
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
NAN_METHOD(KafkaConsumer::NodeIncrementalUnassign) {
|
|
934
|
+
Nan::HandleScope scope;
|
|
935
|
+
|
|
936
|
+
if (info.Length() < 1 || !info[0]->IsArray()) {
|
|
937
|
+
return Nan::ThrowError("Need to specify an array of partitions");
|
|
938
|
+
}
|
|
939
|
+
|
|
940
|
+
v8::Local<v8::Array> partitions = info[0].As<v8::Array>();
|
|
941
|
+
std::vector<RdKafka::TopicPartition*> topic_partitions;
|
|
942
|
+
|
|
943
|
+
for (unsigned int i = 0; i < partitions->Length(); ++i) {
|
|
944
|
+
v8::Local<v8::Value> partition_obj_value;
|
|
945
|
+
if (!(
|
|
946
|
+
Nan::Get(partitions, i).ToLocal(&partition_obj_value) &&
|
|
947
|
+
partition_obj_value->IsObject())) {
|
|
948
|
+
Nan::ThrowError("Must pass topic-partition objects");
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
v8::Local<v8::Object> partition_obj = partition_obj_value.As<v8::Object>();
|
|
952
|
+
|
|
953
|
+
int64_t partition = GetParameter<int64_t>(partition_obj, "partition", -1);
|
|
954
|
+
std::string topic = GetParameter<std::string>(partition_obj, "topic", "");
|
|
955
|
+
|
|
956
|
+
if (!topic.empty()) {
|
|
957
|
+
RdKafka::TopicPartition* part;
|
|
958
|
+
|
|
959
|
+
if (partition < 0) {
|
|
960
|
+
part = Connection::GetPartition(topic);
|
|
961
|
+
} else {
|
|
962
|
+
part = Connection::GetPartition(topic, partition);
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
int64_t offset = GetParameter<int64_t>(
|
|
966
|
+
partition_obj, "offset", RdKafka::Topic::OFFSET_INVALID);
|
|
967
|
+
if (offset != RdKafka::Topic::OFFSET_INVALID) {
|
|
968
|
+
part->set_offset(offset);
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
topic_partitions.push_back(part);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
976
|
+
|
|
977
|
+
Baton b = consumer->IncrementalUnassign(topic_partitions);
|
|
978
|
+
|
|
979
|
+
if (b.err() != RdKafka::ERR_NO_ERROR) {
|
|
980
|
+
v8::Local<v8::Value> errorObject = b.ToObject();
|
|
981
|
+
Nan::ThrowError(errorObject);
|
|
982
|
+
}
|
|
983
|
+
|
|
984
|
+
info.GetReturnValue().Set(Nan::True());
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
NAN_METHOD(KafkaConsumer::NodeUnsubscribe) {
|
|
988
|
+
Nan::HandleScope scope;
|
|
989
|
+
|
|
990
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
991
|
+
|
|
992
|
+
Baton b = consumer->Unsubscribe();
|
|
993
|
+
|
|
994
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(static_cast<int>(b.err())));
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
NAN_METHOD(KafkaConsumer::NodeCommit) {
|
|
998
|
+
Nan::HandleScope scope;
|
|
999
|
+
int error_code;
|
|
1000
|
+
|
|
1001
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1002
|
+
|
|
1003
|
+
if (!consumer->IsConnected()) {
|
|
1004
|
+
Nan::ThrowError("KafkaConsumer is disconnected");
|
|
1005
|
+
return;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
if (info[0]->IsNull() || info[0]->IsUndefined()) {
|
|
1009
|
+
Baton b = consumer->Commit();
|
|
1010
|
+
error_code = static_cast<int>(b.err());
|
|
1011
|
+
} else if (info[0]->IsArray()) {
|
|
1012
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
1013
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
1014
|
+
|
|
1015
|
+
Baton b = consumer->Commit(toppars);
|
|
1016
|
+
error_code = static_cast<int>(b.err());
|
|
1017
|
+
|
|
1018
|
+
RdKafka::TopicPartition::destroy(toppars);
|
|
1019
|
+
} else if (info[0]->IsObject()) {
|
|
1020
|
+
RdKafka::TopicPartition * toppar =
|
|
1021
|
+
Conversion::TopicPartition::FromV8Object(info[0].As<v8::Object>());
|
|
1022
|
+
|
|
1023
|
+
if (toppar == NULL) {
|
|
1024
|
+
Nan::ThrowError("Invalid topic partition provided");
|
|
1025
|
+
return;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
Baton b = consumer->Commit(toppar);
|
|
1029
|
+
error_code = static_cast<int>(b.err());
|
|
1030
|
+
|
|
1031
|
+
delete toppar;
|
|
1032
|
+
} else {
|
|
1033
|
+
Nan::ThrowError("First parameter must be an object or an array");
|
|
1034
|
+
return;
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
NAN_METHOD(KafkaConsumer::NodeCommitSync) {
|
|
1041
|
+
Nan::HandleScope scope;
|
|
1042
|
+
int error_code;
|
|
1043
|
+
|
|
1044
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1045
|
+
|
|
1046
|
+
if (!consumer->IsConnected()) {
|
|
1047
|
+
Nan::ThrowError("KafkaConsumer is disconnected");
|
|
1048
|
+
return;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
if (info[0]->IsNull() || info[0]->IsUndefined()) {
|
|
1052
|
+
Baton b = consumer->CommitSync();
|
|
1053
|
+
error_code = static_cast<int>(b.err());
|
|
1054
|
+
} else if (info[0]->IsArray()) {
|
|
1055
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
1056
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
1057
|
+
|
|
1058
|
+
Baton b = consumer->CommitSync(toppars);
|
|
1059
|
+
error_code = static_cast<int>(b.err());
|
|
1060
|
+
|
|
1061
|
+
RdKafka::TopicPartition::destroy(toppars);
|
|
1062
|
+
} else if (info[0]->IsObject()) {
|
|
1063
|
+
RdKafka::TopicPartition * toppar =
|
|
1064
|
+
Conversion::TopicPartition::FromV8Object(info[0].As<v8::Object>());
|
|
1065
|
+
|
|
1066
|
+
if (toppar == NULL) {
|
|
1067
|
+
Nan::ThrowError("Invalid topic partition provided");
|
|
1068
|
+
return;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
Baton b = consumer->CommitSync(toppar);
|
|
1072
|
+
error_code = static_cast<int>(b.err());
|
|
1073
|
+
|
|
1074
|
+
delete toppar;
|
|
1075
|
+
} else {
|
|
1076
|
+
Nan::ThrowError("First parameter must be an object or an array");
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1081
|
+
}
|
|
1082
|
+
|
|
1083
|
+
NAN_METHOD(KafkaConsumer::NodeSubscribe) {
|
|
1084
|
+
Nan::HandleScope scope;
|
|
1085
|
+
|
|
1086
|
+
if (info.Length() < 1 || !info[0]->IsArray()) {
|
|
1087
|
+
// Just throw an exception
|
|
1088
|
+
return Nan::ThrowError("First parameter must be an array");
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1092
|
+
|
|
1093
|
+
v8::Local<v8::Array> topicsArray = info[0].As<v8::Array>();
|
|
1094
|
+
std::vector<std::string> topics = Conversion::Topic::ToStringVector(topicsArray); // NOLINT
|
|
1095
|
+
|
|
1096
|
+
Baton b = consumer->Subscribe(topics);
|
|
1097
|
+
|
|
1098
|
+
int error_code = static_cast<int>(b.err());
|
|
1099
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
NAN_METHOD(KafkaConsumer::NodeSeek) {
|
|
1103
|
+
Nan::HandleScope scope;
|
|
1104
|
+
|
|
1105
|
+
// If number of parameters is less than 3 (need topic partition, timeout,
|
|
1106
|
+
// and callback), we can't call this thing
|
|
1107
|
+
if (info.Length() < 3) {
|
|
1108
|
+
return Nan::ThrowError("Must provide a topic partition, timeout, and callback"); // NOLINT
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
if (!info[0]->IsObject()) {
|
|
1112
|
+
return Nan::ThrowError("Topic partition must be an object");
|
|
1113
|
+
}
|
|
1114
|
+
|
|
1115
|
+
if (!info[1]->IsNumber() && !info[1]->IsNull()) {
|
|
1116
|
+
return Nan::ThrowError("Timeout must be a number.");
|
|
1117
|
+
}
|
|
1118
|
+
|
|
1119
|
+
if (!info[2]->IsFunction()) {
|
|
1120
|
+
return Nan::ThrowError("Callback must be a function");
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
int timeout_ms;
|
|
1124
|
+
Nan::Maybe<uint32_t> maybeTimeout =
|
|
1125
|
+
Nan::To<uint32_t>(info[1].As<v8::Number>());
|
|
1126
|
+
|
|
1127
|
+
if (maybeTimeout.IsNothing()) {
|
|
1128
|
+
timeout_ms = 1000;
|
|
1129
|
+
} else {
|
|
1130
|
+
timeout_ms = static_cast<int>(maybeTimeout.FromJust());
|
|
1131
|
+
// Do not allow timeouts of less than 10. Providing 0 causes segfaults
|
|
1132
|
+
// because it makes it asynchronous.
|
|
1133
|
+
if (timeout_ms < 10) {
|
|
1134
|
+
timeout_ms = 10;
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1139
|
+
|
|
1140
|
+
const RdKafka::TopicPartition * toppar =
|
|
1141
|
+
Conversion::TopicPartition::FromV8Object(info[0].As<v8::Object>());
|
|
1142
|
+
|
|
1143
|
+
if (!toppar) {
|
|
1144
|
+
return Nan::ThrowError("Invalid topic partition provided");
|
|
1145
|
+
}
|
|
1146
|
+
|
|
1147
|
+
Nan::Callback *callback = new Nan::Callback(info[2].As<v8::Function>());
|
|
1148
|
+
Nan::AsyncQueueWorker(
|
|
1149
|
+
new Workers::KafkaConsumerSeek(callback, consumer, toppar, timeout_ms));
|
|
1150
|
+
|
|
1151
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
1152
|
+
}
|
|
1153
|
+
|
|
1154
|
+
NAN_METHOD(KafkaConsumer::NodeOffsetsStore) {
|
|
1155
|
+
Nan::HandleScope scope;
|
|
1156
|
+
|
|
1157
|
+
// If number of parameters is less than 3 (need topic partition, timeout,
|
|
1158
|
+
// and callback), we can't call this thing
|
|
1159
|
+
if (info.Length() < 1) {
|
|
1160
|
+
return Nan::ThrowError("Must provide a list of topic partitions");
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
if (!info[0]->IsArray()) {
|
|
1164
|
+
return Nan::ThrowError("Topic partition must be an array of objects");
|
|
1165
|
+
}
|
|
1166
|
+
|
|
1167
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1168
|
+
|
|
1169
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
1170
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
1171
|
+
|
|
1172
|
+
Baton b = consumer->OffsetsStore(toppars);
|
|
1173
|
+
RdKafka::TopicPartition::destroy(toppars);
|
|
1174
|
+
|
|
1175
|
+
int error_code = static_cast<int>(b.err());
|
|
1176
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
NAN_METHOD(KafkaConsumer::NodePause) {
|
|
1180
|
+
Nan::HandleScope scope;
|
|
1181
|
+
|
|
1182
|
+
// If number of parameters is less than 3 (need topic partition, timeout,
|
|
1183
|
+
// and callback), we can't call this thing
|
|
1184
|
+
if (info.Length() < 1) {
|
|
1185
|
+
return Nan::ThrowError("Must provide a list of topic partitions");
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
if (!info[0]->IsArray()) {
|
|
1189
|
+
return Nan::ThrowError("Topic partition must be an array of objects");
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1193
|
+
|
|
1194
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
1195
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
1196
|
+
|
|
1197
|
+
Baton b = consumer->Pause(toppars);
|
|
1198
|
+
RdKafka::TopicPartition::destroy(toppars);
|
|
1199
|
+
|
|
1200
|
+
#if 0
|
|
1201
|
+
// Now iterate through and delete these toppars
|
|
1202
|
+
for (std::vector<RdKafka::TopicPartition *>::const_iterator it = toppars.begin(); // NOLINT
|
|
1203
|
+
it != toppars.end(); it++) {
|
|
1204
|
+
RdKafka::TopicPartition* toppar = *it;
|
|
1205
|
+
if (toppar->err() != RdKafka::ERR_NO_ERROR) {
|
|
1206
|
+
// Need to somehow transmit this information.
|
|
1207
|
+
// @TODO(webmakersteve)
|
|
1208
|
+
}
|
|
1209
|
+
delete toppar;
|
|
1210
|
+
}
|
|
1211
|
+
#endif
|
|
1212
|
+
|
|
1213
|
+
int error_code = static_cast<int>(b.err());
|
|
1214
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
NAN_METHOD(KafkaConsumer::NodeResume) {
|
|
1218
|
+
Nan::HandleScope scope;
|
|
1219
|
+
|
|
1220
|
+
// If number of parameters is less than 3 (need topic partition, timeout,
|
|
1221
|
+
// and callback), we can't call this thing
|
|
1222
|
+
if (info.Length() < 1) {
|
|
1223
|
+
return Nan::ThrowError("Must provide a list of topic partitions"); // NOLINT
|
|
1224
|
+
}
|
|
1225
|
+
|
|
1226
|
+
if (!info[0]->IsArray()) {
|
|
1227
|
+
return Nan::ThrowError("Topic partition must be an array of objects");
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1231
|
+
|
|
1232
|
+
std::vector<RdKafka::TopicPartition *> toppars =
|
|
1233
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
1234
|
+
|
|
1235
|
+
Baton b = consumer->Resume(toppars);
|
|
1236
|
+
|
|
1237
|
+
// Now iterate through and delete these toppars
|
|
1238
|
+
for (std::vector<RdKafka::TopicPartition *>::const_iterator it = toppars.begin(); // NOLINT
|
|
1239
|
+
it != toppars.end(); it++) {
|
|
1240
|
+
RdKafka::TopicPartition* toppar = *it;
|
|
1241
|
+
if (toppar->err() != RdKafka::ERR_NO_ERROR) {
|
|
1242
|
+
// Need to somehow transmit this information.
|
|
1243
|
+
// @TODO(webmakersteve)
|
|
1244
|
+
}
|
|
1245
|
+
delete toppar;
|
|
1246
|
+
}
|
|
1247
|
+
|
|
1248
|
+
int error_code = static_cast<int>(b.err());
|
|
1249
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1250
|
+
}
|
|
1251
|
+
|
|
1252
|
+
NAN_METHOD(KafkaConsumer::NodeConsumeLoop) {
|
|
1253
|
+
Nan::HandleScope scope;
|
|
1254
|
+
|
|
1255
|
+
if (info.Length() < 3) {
|
|
1256
|
+
// Just throw an exception
|
|
1257
|
+
return Nan::ThrowError("Invalid number of parameters");
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
if (!info[0]->IsNumber()) {
|
|
1261
|
+
return Nan::ThrowError("Need to specify a timeout");
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
if (!info[1]->IsNumber()) {
|
|
1265
|
+
return Nan::ThrowError("Need to specify a sleep delay");
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
if (!info[2]->IsFunction()) {
|
|
1269
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
1270
|
+
}
|
|
1271
|
+
|
|
1272
|
+
int timeout_ms;
|
|
1273
|
+
Nan::Maybe<uint32_t> maybeTimeout =
|
|
1274
|
+
Nan::To<uint32_t>(info[0].As<v8::Number>());
|
|
1275
|
+
|
|
1276
|
+
if (maybeTimeout.IsNothing()) {
|
|
1277
|
+
timeout_ms = 1000;
|
|
1278
|
+
} else {
|
|
1279
|
+
timeout_ms = static_cast<int>(maybeTimeout.FromJust());
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
int timeout_sleep_delay_ms;
|
|
1283
|
+
Nan::Maybe<uint32_t> maybeSleep =
|
|
1284
|
+
Nan::To<uint32_t>(info[1].As<v8::Number>());
|
|
1285
|
+
|
|
1286
|
+
if (maybeSleep.IsNothing()) {
|
|
1287
|
+
timeout_sleep_delay_ms = 500;
|
|
1288
|
+
} else {
|
|
1289
|
+
timeout_sleep_delay_ms = static_cast<int>(maybeSleep.FromJust());
|
|
1290
|
+
}
|
|
1291
|
+
|
|
1292
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1293
|
+
|
|
1294
|
+
if (consumer->m_consume_loop != nullptr) {
|
|
1295
|
+
return Nan::ThrowError("Consume was already called");
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
if (!consumer->IsConnected()) {
|
|
1299
|
+
return Nan::ThrowError("Connect must be called before consume");
|
|
1300
|
+
}
|
|
1301
|
+
|
|
1302
|
+
v8::Local<v8::Function> cb = info[2].As<v8::Function>();
|
|
1303
|
+
|
|
1304
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
1305
|
+
|
|
1306
|
+
consumer->m_consume_loop = new Workers::KafkaConsumerConsumeLoop(callback, consumer, timeout_ms, timeout_sleep_delay_ms);
|
|
1307
|
+
|
|
1308
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
NAN_METHOD(KafkaConsumer::NodeConsume) {
|
|
1312
|
+
Nan::HandleScope scope;
|
|
1313
|
+
|
|
1314
|
+
if (info.Length() < 2) {
|
|
1315
|
+
// Just throw an exception
|
|
1316
|
+
return Nan::ThrowError("Invalid number of parameters");
|
|
1317
|
+
}
|
|
1318
|
+
|
|
1319
|
+
int timeout_ms;
|
|
1320
|
+
Nan::Maybe<uint32_t> maybeTimeout =
|
|
1321
|
+
Nan::To<uint32_t>(info[0].As<v8::Number>());
|
|
1322
|
+
|
|
1323
|
+
if (maybeTimeout.IsNothing()) {
|
|
1324
|
+
timeout_ms = 1000;
|
|
1325
|
+
} else {
|
|
1326
|
+
timeout_ms = static_cast<int>(maybeTimeout.FromJust());
|
|
1327
|
+
}
|
|
1328
|
+
|
|
1329
|
+
if (info[1]->IsNumber()) {
|
|
1330
|
+
if (!info[2]->IsFunction()) {
|
|
1331
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
v8::Local<v8::Number> numMessagesNumber = info[1].As<v8::Number>();
|
|
1335
|
+
Nan::Maybe<uint32_t> numMessagesMaybe = Nan::To<uint32_t>(numMessagesNumber); // NOLINT
|
|
1336
|
+
|
|
1337
|
+
uint32_t numMessages;
|
|
1338
|
+
if (numMessagesMaybe.IsNothing()) {
|
|
1339
|
+
return Nan::ThrowError("Parameter must be a number over 0");
|
|
1340
|
+
} else {
|
|
1341
|
+
numMessages = numMessagesMaybe.FromJust();
|
|
1342
|
+
}
|
|
1343
|
+
|
|
1344
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1345
|
+
|
|
1346
|
+
v8::Local<v8::Function> cb = info[2].As<v8::Function>();
|
|
1347
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
1348
|
+
Nan::AsyncQueueWorker(
|
|
1349
|
+
new Workers::KafkaConsumerConsumeNum(callback, consumer, numMessages, timeout_ms)); // NOLINT
|
|
1350
|
+
|
|
1351
|
+
} else {
|
|
1352
|
+
if (!info[1]->IsFunction()) {
|
|
1353
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1357
|
+
|
|
1358
|
+
v8::Local<v8::Function> cb = info[1].As<v8::Function>();
|
|
1359
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
1360
|
+
Nan::AsyncQueueWorker(
|
|
1361
|
+
new Workers::KafkaConsumerConsume(callback, consumer, timeout_ms));
|
|
1362
|
+
}
|
|
1363
|
+
|
|
1364
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
NAN_METHOD(KafkaConsumer::NodeConnect) {
|
|
1368
|
+
Nan::HandleScope scope;
|
|
1369
|
+
|
|
1370
|
+
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
|
1371
|
+
// Just throw an exception
|
|
1372
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1376
|
+
|
|
1377
|
+
Nan::Callback *callback = new Nan::Callback(info[0].As<v8::Function>());
|
|
1378
|
+
Nan::AsyncQueueWorker(new Workers::KafkaConsumerConnect(callback, consumer));
|
|
1379
|
+
|
|
1380
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
NAN_METHOD(KafkaConsumer::NodeDisconnect) {
|
|
1384
|
+
Nan::HandleScope scope;
|
|
1385
|
+
|
|
1386
|
+
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
|
1387
|
+
// Just throw an exception
|
|
1388
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
|
|
1392
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
1393
|
+
KafkaConsumer* consumer = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1394
|
+
|
|
1395
|
+
Workers::KafkaConsumerConsumeLoop* consumeLoop = (Workers::KafkaConsumerConsumeLoop*)consumer->m_consume_loop;
|
|
1396
|
+
if (consumeLoop != nullptr) {
|
|
1397
|
+
// stop the consume loop
|
|
1398
|
+
consumeLoop->Close();
|
|
1399
|
+
|
|
1400
|
+
// cleanup the async worker
|
|
1401
|
+
consumeLoop->WorkComplete();
|
|
1402
|
+
consumeLoop->Destroy();
|
|
1403
|
+
|
|
1404
|
+
consumer->m_consume_loop = nullptr;
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
Nan::AsyncQueueWorker(
|
|
1408
|
+
new Workers::KafkaConsumerDisconnect(callback, consumer));
|
|
1409
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
NAN_METHOD(KafkaConsumer::NodeGetWatermarkOffsets) {
|
|
1413
|
+
Nan::HandleScope scope;
|
|
1414
|
+
|
|
1415
|
+
KafkaConsumer* obj = ObjectWrap::Unwrap<KafkaConsumer>(info.This());
|
|
1416
|
+
|
|
1417
|
+
if (!info[0]->IsString()) {
|
|
1418
|
+
Nan::ThrowError("1st parameter must be a topic string");;
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
|
|
1422
|
+
if (!info[1]->IsNumber()) {
|
|
1423
|
+
Nan::ThrowError("2nd parameter must be a partition number");
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
|
|
1427
|
+
// Get string pointer for the topic name
|
|
1428
|
+
Nan::Utf8String topicUTF8(Nan::To<v8::String>(info[0]).ToLocalChecked());
|
|
1429
|
+
// The first parameter is the topic
|
|
1430
|
+
std::string topic_name(*topicUTF8);
|
|
1431
|
+
|
|
1432
|
+
// Second parameter is the partition
|
|
1433
|
+
int32_t partition = Nan::To<int32_t>(info[1]).FromJust();
|
|
1434
|
+
|
|
1435
|
+
// Set these ints which will store the return data
|
|
1436
|
+
int64_t low_offset;
|
|
1437
|
+
int64_t high_offset;
|
|
1438
|
+
|
|
1439
|
+
Baton b = obj->GetWatermarkOffsets(
|
|
1440
|
+
topic_name, partition, &low_offset, &high_offset);
|
|
1441
|
+
|
|
1442
|
+
if (b.err() != RdKafka::ERR_NO_ERROR) {
|
|
1443
|
+
// Let the JS library throw if we need to so the error can be more rich
|
|
1444
|
+
int error_code = static_cast<int>(b.err());
|
|
1445
|
+
return info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
1446
|
+
} else {
|
|
1447
|
+
v8::Local<v8::Object> offsetsObj = Nan::New<v8::Object>();
|
|
1448
|
+
Nan::Set(offsetsObj, Nan::New<v8::String>("lowOffset").ToLocalChecked(),
|
|
1449
|
+
Nan::New<v8::Number>(low_offset));
|
|
1450
|
+
Nan::Set(offsetsObj, Nan::New<v8::String>("highOffset").ToLocalChecked(),
|
|
1451
|
+
Nan::New<v8::Number>(high_offset));
|
|
1452
|
+
|
|
1453
|
+
return info.GetReturnValue().Set(offsetsObj);
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
} // namespace NodeKafka
|