@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
package/src/producer.cc
ADDED
|
@@ -0,0 +1,873 @@
|
|
|
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/per-isolate-data.h"
|
|
14
|
+
#include "src/producer.h"
|
|
15
|
+
#include "src/kafka-consumer.h"
|
|
16
|
+
#include "src/workers.h"
|
|
17
|
+
|
|
18
|
+
namespace NodeKafka {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @brief Producer v8 wrapped object.
|
|
22
|
+
*
|
|
23
|
+
* Wraps the RdKafka::Producer object with compositional inheritence and
|
|
24
|
+
* provides methods for interacting with it exposed to node.
|
|
25
|
+
*
|
|
26
|
+
* The base wrappable RdKafka::Handle deals with most of the wrapping but
|
|
27
|
+
* we still need to declare its prototype.
|
|
28
|
+
*
|
|
29
|
+
* @sa RdKafka::Producer
|
|
30
|
+
* @sa NodeKafka::Connection
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
Producer::Producer(Conf* gconfig, Conf* tconfig):
|
|
34
|
+
Connection(gconfig, tconfig),
|
|
35
|
+
m_dr_cb(),
|
|
36
|
+
m_partitioner_cb() {
|
|
37
|
+
std::string errstr;
|
|
38
|
+
|
|
39
|
+
m_gconfig->set("default_topic_conf", m_tconfig, errstr);
|
|
40
|
+
m_gconfig->set("dr_cb", &m_dr_cb, errstr);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
void Producer::delete_instance(void* arg) {
|
|
44
|
+
delete (static_cast<Producer*>(arg));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
Producer::~Producer() {
|
|
48
|
+
Disconnect();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
void Producer::Init(v8::Local<v8::Object> exports) {
|
|
52
|
+
Nan::HandleScope scope;
|
|
53
|
+
|
|
54
|
+
v8::Local<v8::FunctionTemplate> tpl = Nan::New<v8::FunctionTemplate>(New);
|
|
55
|
+
tpl->SetClassName(Nan::New("Producer").ToLocalChecked());
|
|
56
|
+
tpl->InstanceTemplate()->SetInternalFieldCount(1);
|
|
57
|
+
|
|
58
|
+
/*
|
|
59
|
+
* Lifecycle events inherited from NodeKafka::Connection
|
|
60
|
+
*
|
|
61
|
+
* @sa NodeKafka::Connection
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
Nan::SetPrototypeMethod(tpl, "configureCallbacks", NodeConfigureCallbacks);
|
|
65
|
+
|
|
66
|
+
/*
|
|
67
|
+
* @brief Methods to do with establishing state
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
Nan::SetPrototypeMethod(tpl, "connect", NodeConnect);
|
|
71
|
+
Nan::SetPrototypeMethod(tpl, "disconnect", NodeDisconnect);
|
|
72
|
+
Nan::SetPrototypeMethod(tpl, "setToken", NodeSetToken);
|
|
73
|
+
Nan::SetPrototypeMethod(tpl, "getMetadata", NodeGetMetadata);
|
|
74
|
+
Nan::SetPrototypeMethod(tpl, "queryWatermarkOffsets", NodeQueryWatermarkOffsets); // NOLINT
|
|
75
|
+
Nan::SetPrototypeMethod(tpl, "poll", NodePoll);
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* @brief Methods exposed to do with message production
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
Nan::SetPrototypeMethod(tpl, "setPartitioner", NodeSetPartitioner);
|
|
82
|
+
Nan::SetPrototypeMethod(tpl, "produce", NodeProduce);
|
|
83
|
+
|
|
84
|
+
Nan::SetPrototypeMethod(tpl, "flush", NodeFlush);
|
|
85
|
+
|
|
86
|
+
/*
|
|
87
|
+
* @brief Methods exposed to do with transactions
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
Nan::SetPrototypeMethod(tpl, "initTransactions", NodeInitTransactions);
|
|
91
|
+
Nan::SetPrototypeMethod(tpl, "beginTransaction", NodeBeginTransaction);
|
|
92
|
+
Nan::SetPrototypeMethod(tpl, "commitTransaction", NodeCommitTransaction);
|
|
93
|
+
Nan::SetPrototypeMethod(tpl, "abortTransaction", NodeAbortTransaction);
|
|
94
|
+
Nan::SetPrototypeMethod(tpl, "sendOffsetsToTransaction", NodeSendOffsetsToTransaction);
|
|
95
|
+
|
|
96
|
+
// connect. disconnect. resume. pause. get meta data
|
|
97
|
+
PerIsolateData::For(v8::Isolate::GetCurrent())->KafkaProducerConstructor()
|
|
98
|
+
.Reset((tpl->GetFunction(Nan::GetCurrentContext()))
|
|
99
|
+
.ToLocalChecked());
|
|
100
|
+
|
|
101
|
+
Nan::Set(exports, Nan::New("Producer").ToLocalChecked(),
|
|
102
|
+
tpl->GetFunction(Nan::GetCurrentContext()).ToLocalChecked());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void Producer::New(const Nan::FunctionCallbackInfo<v8::Value>& info) {
|
|
106
|
+
if (!info.IsConstructCall()) {
|
|
107
|
+
return Nan::ThrowError("non-constructor invocation not supported");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (info.Length() < 2) {
|
|
111
|
+
return Nan::ThrowError("You must supply global and topic configuration");
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
if (!info[0]->IsObject()) {
|
|
115
|
+
return Nan::ThrowError("Global configuration data must be specified");
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (!info[1]->IsObject()) {
|
|
119
|
+
return Nan::ThrowError("Topic configuration must be specified");
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
std::string errstr;
|
|
123
|
+
|
|
124
|
+
Conf* gconfig =
|
|
125
|
+
Conf::create(RdKafka::Conf::CONF_GLOBAL,
|
|
126
|
+
(info[0]->ToObject(Nan::GetCurrentContext())).ToLocalChecked(), errstr);
|
|
127
|
+
|
|
128
|
+
if (!gconfig) {
|
|
129
|
+
return Nan::ThrowError(errstr.c_str());
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
Conf* tconfig =
|
|
133
|
+
Conf::create(RdKafka::Conf::CONF_TOPIC,
|
|
134
|
+
(info[1]->ToObject(Nan::GetCurrentContext())).ToLocalChecked(), errstr);
|
|
135
|
+
|
|
136
|
+
if (!tconfig) {
|
|
137
|
+
// No longer need this since we aren't instantiating anything
|
|
138
|
+
delete gconfig;
|
|
139
|
+
return Nan::ThrowError(errstr.c_str());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
Producer* producer = new Producer(gconfig, tconfig);
|
|
143
|
+
|
|
144
|
+
// Wrap it
|
|
145
|
+
producer->Wrap(info.This());
|
|
146
|
+
|
|
147
|
+
// Then there is some weird initialization that happens
|
|
148
|
+
// basically it sets the configuration data
|
|
149
|
+
// we don't need to do that because we lazy load it
|
|
150
|
+
|
|
151
|
+
info.GetReturnValue().Set(info.This());
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
v8::Local<v8::Object> Producer::NewInstance(v8::Local<v8::Value> arg) {
|
|
155
|
+
Nan::EscapableHandleScope scope;
|
|
156
|
+
|
|
157
|
+
const unsigned argc = 1;
|
|
158
|
+
|
|
159
|
+
v8::Local<v8::Value> argv[argc] = { arg };
|
|
160
|
+
v8::Local<v8::Function> cons = Nan::New<v8::Function>(
|
|
161
|
+
PerIsolateData::For(v8::Isolate::GetCurrent())->KafkaProducerConstructor());
|
|
162
|
+
v8::Local<v8::Object> instance =
|
|
163
|
+
Nan::NewInstance(cons, argc, argv).ToLocalChecked();
|
|
164
|
+
|
|
165
|
+
return scope.Escape(instance);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
std::string Producer::Name() {
|
|
170
|
+
if (!IsConnected()) {
|
|
171
|
+
return std::string("");
|
|
172
|
+
}
|
|
173
|
+
return std::string(m_client->name());
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
Baton Producer::Connect() {
|
|
177
|
+
if (IsConnected()) {
|
|
178
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
std::string errstr;
|
|
182
|
+
{
|
|
183
|
+
scoped_shared_read_lock lock(m_connection_lock);
|
|
184
|
+
m_client = RdKafka::Producer::create(m_gconfig, errstr);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (!m_client) {
|
|
188
|
+
// @todo implement errstr into this somehow
|
|
189
|
+
return Baton(RdKafka::ERR__STATE, errstr);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (m_init_oauthToken) {
|
|
193
|
+
scoped_shared_write_lock lock(m_connection_lock);
|
|
194
|
+
if (m_init_oauthToken) {
|
|
195
|
+
std::list<std::string> emptyList;
|
|
196
|
+
std::string token = m_init_oauthToken->token;
|
|
197
|
+
int64_t expiry = m_init_oauthToken->expiry;
|
|
198
|
+
// needed for initial connection only
|
|
199
|
+
m_init_oauthToken.reset();
|
|
200
|
+
|
|
201
|
+
RdKafka::ErrorCode err = m_client->oauthbearer_set_token(token, expiry,
|
|
202
|
+
"", emptyList, errstr);
|
|
203
|
+
|
|
204
|
+
if (err != RdKafka::ERR_NO_ERROR) {
|
|
205
|
+
return Baton(err, errstr);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
void Producer::ActivateDispatchers() {
|
|
215
|
+
m_event_cb.dispatcher.Activate(); // From connection
|
|
216
|
+
m_dr_cb.dispatcher.Activate();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
void Producer::DeactivateDispatchers() {
|
|
220
|
+
m_event_cb.dispatcher.Deactivate(); // From connection
|
|
221
|
+
m_dr_cb.dispatcher.Deactivate();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
void Producer::Disconnect() {
|
|
225
|
+
if (IsConnected()) {
|
|
226
|
+
scoped_shared_write_lock lock(m_connection_lock);
|
|
227
|
+
delete m_client;
|
|
228
|
+
m_client = NULL;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* [Producer::Produce description]
|
|
234
|
+
* @param message - pointer to the message we are sending. This method will
|
|
235
|
+
* create a copy of it, so you are still required to free it when done.
|
|
236
|
+
* @param size - size of the message. We are copying the memory so we need
|
|
237
|
+
* the size
|
|
238
|
+
* @param topic - RdKafka::Topic* object to send the message to. Generally
|
|
239
|
+
* created by NodeKafka::Topic::toRDKafkaTopic
|
|
240
|
+
* @param partition - partition to send it to. Send in
|
|
241
|
+
* RdKafka::Topic::PARTITION_UA to send to an unassigned topic
|
|
242
|
+
* @param key - a string pointer for the key, or null if there is none.
|
|
243
|
+
* @return - A baton object with error code set if it failed.
|
|
244
|
+
*/
|
|
245
|
+
Baton Producer::Produce(void* message, size_t size, RdKafka::Topic* topic,
|
|
246
|
+
int32_t partition, const void *key, size_t key_len, void* opaque) {
|
|
247
|
+
RdKafka::ErrorCode response_code;
|
|
248
|
+
|
|
249
|
+
if (IsConnected()) {
|
|
250
|
+
scoped_shared_read_lock lock(m_connection_lock);
|
|
251
|
+
if (IsConnected()) {
|
|
252
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
253
|
+
response_code = producer->produce(topic, partition,
|
|
254
|
+
RdKafka::Producer::RK_MSG_COPY,
|
|
255
|
+
message, size, key, key_len, opaque);
|
|
256
|
+
} else {
|
|
257
|
+
response_code = RdKafka::ERR__STATE;
|
|
258
|
+
}
|
|
259
|
+
} else {
|
|
260
|
+
response_code = RdKafka::ERR__STATE;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
// These topics actually link to the configuration
|
|
264
|
+
// they are made from. It's so we can reuse topic configurations
|
|
265
|
+
// That means if we delete it here and librd thinks its still linked,
|
|
266
|
+
// producing to the same topic will try to reuse it and it will die.
|
|
267
|
+
//
|
|
268
|
+
// Honestly, we may need to make configuration a first class object
|
|
269
|
+
// @todo(Conf needs to be a first class object that is passed around)
|
|
270
|
+
// delete topic;
|
|
271
|
+
|
|
272
|
+
if (response_code != RdKafka::ERR_NO_ERROR) {
|
|
273
|
+
return Baton(response_code);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* [Producer::Produce description]
|
|
281
|
+
* @param message - pointer to the message we are sending. This method will
|
|
282
|
+
* create a copy of it, so you are still required to free it when done.
|
|
283
|
+
* @param size - size of the message. We are copying the memory so we need
|
|
284
|
+
* the size
|
|
285
|
+
* @param topic - String topic to use so we do not need to create
|
|
286
|
+
* an RdKafka::Topic*
|
|
287
|
+
* @param partition - partition to send it to. Send in
|
|
288
|
+
* RdKafka::Topic::PARTITION_UA to send to an unassigned topic
|
|
289
|
+
* @param key - a string pointer for the key, or null if there is none.
|
|
290
|
+
* @return - A baton object with error code set if it failed.
|
|
291
|
+
*/
|
|
292
|
+
Baton Producer::Produce(void* message, size_t size, std::string topic,
|
|
293
|
+
int32_t partition, std::string *key, int64_t timestamp, void* opaque,
|
|
294
|
+
RdKafka::Headers* headers) {
|
|
295
|
+
return Produce(message, size, topic, partition,
|
|
296
|
+
key ? key->data() : NULL, key ? key->size() : 0,
|
|
297
|
+
timestamp, opaque, headers);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* [Producer::Produce description]
|
|
302
|
+
* @param message - pointer to the message we are sending. This method will
|
|
303
|
+
* create a copy of it, so you are still required to free it when done.
|
|
304
|
+
* @param size - size of the message. We are copying the memory so we need
|
|
305
|
+
* the size
|
|
306
|
+
* @param topic - String topic to use so we do not need to create
|
|
307
|
+
* an RdKafka::Topic*
|
|
308
|
+
* @param partition - partition to send it to. Send in
|
|
309
|
+
* RdKafka::Topic::PARTITION_UA to send to an unassigned topic
|
|
310
|
+
* @param key - a string pointer for the key, or null if there is none.
|
|
311
|
+
* @return - A baton object with error code set if it failed.
|
|
312
|
+
*/
|
|
313
|
+
Baton Producer::Produce(void* message, size_t size, std::string topic,
|
|
314
|
+
int32_t partition, const void *key, size_t key_len,
|
|
315
|
+
int64_t timestamp, void* opaque, RdKafka::Headers* headers) {
|
|
316
|
+
RdKafka::ErrorCode response_code;
|
|
317
|
+
|
|
318
|
+
if (IsConnected()) {
|
|
319
|
+
scoped_shared_read_lock lock(m_connection_lock);
|
|
320
|
+
if (IsConnected()) {
|
|
321
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
322
|
+
// This one is a bit different
|
|
323
|
+
response_code = producer->produce(topic, partition,
|
|
324
|
+
RdKafka::Producer::RK_MSG_COPY,
|
|
325
|
+
message, size,
|
|
326
|
+
key, key_len,
|
|
327
|
+
timestamp, headers, opaque);
|
|
328
|
+
} else {
|
|
329
|
+
response_code = RdKafka::ERR__STATE;
|
|
330
|
+
}
|
|
331
|
+
} else {
|
|
332
|
+
response_code = RdKafka::ERR__STATE;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// These topics actually link to the configuration
|
|
336
|
+
// they are made from. It's so we can reuse topic configurations
|
|
337
|
+
// That means if we delete it here and librd thinks its still linked,
|
|
338
|
+
// producing to the same topic will try to reuse it and it will die.
|
|
339
|
+
//
|
|
340
|
+
// Honestly, we may need to make configuration a first class object
|
|
341
|
+
// @todo(Conf needs to be a first class object that is passed around)
|
|
342
|
+
// delete topic;
|
|
343
|
+
|
|
344
|
+
if (response_code != RdKafka::ERR_NO_ERROR) {
|
|
345
|
+
return Baton(response_code);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
return Baton(RdKafka::ERR_NO_ERROR);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
void Producer::Poll() {
|
|
352
|
+
m_client->poll(0);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
void Producer::ConfigureCallback(const std::string &string_key, const v8::Local<v8::Function> &cb, bool add) {
|
|
356
|
+
if (string_key.compare("delivery_cb") == 0) {
|
|
357
|
+
if (add) {
|
|
358
|
+
bool dr_msg_cb = false;
|
|
359
|
+
v8::Local<v8::String> dr_msg_cb_key = Nan::New("dr_msg_cb").ToLocalChecked();
|
|
360
|
+
if (Nan::Has(cb, dr_msg_cb_key).FromMaybe(false)) {
|
|
361
|
+
v8::Local<v8::Value> v = Nan::Get(cb, dr_msg_cb_key).ToLocalChecked();
|
|
362
|
+
if (v->IsBoolean()) {
|
|
363
|
+
dr_msg_cb = Nan::To<bool>(v).ToChecked();
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
if (dr_msg_cb) {
|
|
367
|
+
this->m_dr_cb.SendMessageBuffer(true);
|
|
368
|
+
}
|
|
369
|
+
this->m_dr_cb.dispatcher.AddCallback(cb);
|
|
370
|
+
} else {
|
|
371
|
+
this->m_dr_cb.dispatcher.RemoveCallback(cb);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
Connection::ConfigureCallback(string_key, cb, add);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
Baton Producer::InitTransactions(int32_t timeout_ms) {
|
|
379
|
+
if (!IsConnected()) {
|
|
380
|
+
return Baton(RdKafka::ERR__STATE);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
384
|
+
RdKafka::Error* error = producer->init_transactions(timeout_ms);
|
|
385
|
+
|
|
386
|
+
return rdkafkaErrorToBaton( error);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
Baton Producer::BeginTransaction() {
|
|
390
|
+
if (!IsConnected()) {
|
|
391
|
+
return Baton(RdKafka::ERR__STATE);
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
395
|
+
RdKafka::Error* error = producer->begin_transaction();
|
|
396
|
+
|
|
397
|
+
return rdkafkaErrorToBaton( error);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
Baton Producer::CommitTransaction(int32_t timeout_ms) {
|
|
401
|
+
if (!IsConnected()) {
|
|
402
|
+
return Baton(RdKafka::ERR__STATE);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
406
|
+
RdKafka::Error* error = producer->commit_transaction(timeout_ms);
|
|
407
|
+
|
|
408
|
+
return rdkafkaErrorToBaton( error);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
Baton Producer::AbortTransaction(int32_t timeout_ms) {
|
|
412
|
+
if (!IsConnected()) {
|
|
413
|
+
return Baton(RdKafka::ERR__STATE);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
417
|
+
RdKafka::Error* error = producer->abort_transaction(timeout_ms);
|
|
418
|
+
|
|
419
|
+
return rdkafkaErrorToBaton( error);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
Baton Producer::SendOffsetsToTransaction(
|
|
423
|
+
std::vector<RdKafka::TopicPartition*> &offsets,
|
|
424
|
+
NodeKafka::KafkaConsumer* consumer,
|
|
425
|
+
int timeout_ms) {
|
|
426
|
+
if (!IsConnected()) {
|
|
427
|
+
return Baton(RdKafka::ERR__STATE);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
RdKafka::ConsumerGroupMetadata* group_metadata = dynamic_cast<RdKafka::KafkaConsumer*>(consumer->m_client)->groupMetadata();
|
|
431
|
+
|
|
432
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
433
|
+
RdKafka::Error* error = producer->send_offsets_to_transaction(offsets, group_metadata, timeout_ms);
|
|
434
|
+
delete group_metadata;
|
|
435
|
+
|
|
436
|
+
return rdkafkaErrorToBaton( error);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/* Node exposed methods */
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* @brief Producer::NodeProduce - produce a message through a producer
|
|
443
|
+
*
|
|
444
|
+
* This is a synchronous method. You may ask, "why?". The answer is because
|
|
445
|
+
* there is no true value doing this asynchronously. All it does is degrade
|
|
446
|
+
* performance. This method does not block - all it does is add a message
|
|
447
|
+
* to a queue. In the case where the queue is full, it will return an error
|
|
448
|
+
* immediately. The only way this method blocks is when you provide it a
|
|
449
|
+
* flag to do so, which we never do.
|
|
450
|
+
*
|
|
451
|
+
* Doing it asynchronously eats up the libuv threadpool for no reason and
|
|
452
|
+
* increases execution time by a very small amount. It will take two ticks of
|
|
453
|
+
* the event loop to execute at minimum - 1 for executing it and another for
|
|
454
|
+
* calling back the callback.
|
|
455
|
+
*
|
|
456
|
+
* @sa RdKafka::Producer::produce
|
|
457
|
+
*/
|
|
458
|
+
NAN_METHOD(Producer::NodeProduce) {
|
|
459
|
+
Nan::HandleScope scope;
|
|
460
|
+
|
|
461
|
+
// Need to extract the message data here.
|
|
462
|
+
if (info.Length() < 3) {
|
|
463
|
+
// Just throw an exception
|
|
464
|
+
return Nan::ThrowError("Need to specify a topic, partition, and message");
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Second parameter is the partition
|
|
468
|
+
int32_t partition;
|
|
469
|
+
|
|
470
|
+
if (info[1]->IsNull() || info[1]->IsUndefined()) {
|
|
471
|
+
partition = RdKafka::Topic::PARTITION_UA;
|
|
472
|
+
} else {
|
|
473
|
+
partition = Nan::To<int32_t>(info[1]).FromJust();
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (partition < 0) {
|
|
477
|
+
partition = RdKafka::Topic::PARTITION_UA;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
size_t message_buffer_length;
|
|
481
|
+
void* message_buffer_data;
|
|
482
|
+
|
|
483
|
+
if (info[2]->IsNull()) {
|
|
484
|
+
// This is okay for whatever reason
|
|
485
|
+
message_buffer_length = 0;
|
|
486
|
+
message_buffer_data = NULL;
|
|
487
|
+
} else if (!node::Buffer::HasInstance(info[2])) {
|
|
488
|
+
return Nan::ThrowError("Message must be a buffer or null");
|
|
489
|
+
} else {
|
|
490
|
+
v8::Local<v8::Object> message_buffer_object =
|
|
491
|
+
(info[2]->ToObject(Nan::GetCurrentContext())).ToLocalChecked();
|
|
492
|
+
|
|
493
|
+
// v8 handles the garbage collection here so we need to make a copy of
|
|
494
|
+
// the buffer or assign the buffer to a persistent handle.
|
|
495
|
+
|
|
496
|
+
// I'm not sure which would be the more performant option. I assume
|
|
497
|
+
// the persistent handle would be but for now we'll try this one
|
|
498
|
+
// which should be more memory-efficient and allow v8 to dispose of the
|
|
499
|
+
// buffer sooner
|
|
500
|
+
|
|
501
|
+
message_buffer_length = node::Buffer::Length(message_buffer_object);
|
|
502
|
+
message_buffer_data = node::Buffer::Data(message_buffer_object);
|
|
503
|
+
if (message_buffer_data == NULL) {
|
|
504
|
+
// empty string message buffer should not end up as null message
|
|
505
|
+
v8::Local<v8::Object> message_buffer_object_emptystring = Nan::NewBuffer(new char[0], 0).ToLocalChecked();
|
|
506
|
+
message_buffer_length = node::Buffer::Length(message_buffer_object_emptystring);
|
|
507
|
+
message_buffer_data = node::Buffer::Data(message_buffer_object_emptystring);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
size_t key_buffer_length;
|
|
512
|
+
const void* key_buffer_data;
|
|
513
|
+
std::string * key = NULL;
|
|
514
|
+
|
|
515
|
+
if (info[3]->IsNull() || info[3]->IsUndefined()) {
|
|
516
|
+
// This is okay for whatever reason
|
|
517
|
+
key_buffer_length = 0;
|
|
518
|
+
key_buffer_data = NULL;
|
|
519
|
+
} else if (node::Buffer::HasInstance(info[3])) {
|
|
520
|
+
v8::Local<v8::Object> key_buffer_object =
|
|
521
|
+
(info[3]->ToObject(Nan::GetCurrentContext())).ToLocalChecked();
|
|
522
|
+
|
|
523
|
+
// v8 handles the garbage collection here so we need to make a copy of
|
|
524
|
+
// the buffer or assign the buffer to a persistent handle.
|
|
525
|
+
|
|
526
|
+
// I'm not sure which would be the more performant option. I assume
|
|
527
|
+
// the persistent handle would be but for now we'll try this one
|
|
528
|
+
// which should be more memory-efficient and allow v8 to dispose of the
|
|
529
|
+
// buffer sooner
|
|
530
|
+
|
|
531
|
+
key_buffer_length = node::Buffer::Length(key_buffer_object);
|
|
532
|
+
key_buffer_data = node::Buffer::Data(key_buffer_object);
|
|
533
|
+
if (key_buffer_data == NULL) {
|
|
534
|
+
// empty string key buffer should not end up as null key
|
|
535
|
+
v8::Local<v8::Object> key_buffer_object_emptystring = Nan::NewBuffer(new char[0], 0).ToLocalChecked();
|
|
536
|
+
key_buffer_length = node::Buffer::Length(key_buffer_object_emptystring);
|
|
537
|
+
key_buffer_data = node::Buffer::Data(key_buffer_object_emptystring);
|
|
538
|
+
}
|
|
539
|
+
} else {
|
|
540
|
+
// If it was a string just use the utf8 value.
|
|
541
|
+
v8::Local<v8::String> val = Nan::To<v8::String>(info[3]).ToLocalChecked();
|
|
542
|
+
// Get string pointer for this thing
|
|
543
|
+
Nan::Utf8String keyUTF8(val);
|
|
544
|
+
key = new std::string(*keyUTF8);
|
|
545
|
+
|
|
546
|
+
key_buffer_data = key->data();
|
|
547
|
+
key_buffer_length = key->length();
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
int64_t timestamp;
|
|
551
|
+
|
|
552
|
+
if (info.Length() > 4 && !info[4]->IsUndefined() && !info[4]->IsNull()) {
|
|
553
|
+
if (!info[4]->IsNumber()) {
|
|
554
|
+
return Nan::ThrowError("Timestamp must be a number");
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
timestamp = Nan::To<int64_t>(info[4]).FromJust();
|
|
558
|
+
} else {
|
|
559
|
+
timestamp = 0;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
void* opaque = NULL;
|
|
563
|
+
// Opaque handling
|
|
564
|
+
if (info.Length() > 5 && !info[5]->IsUndefined()) {
|
|
565
|
+
// We need to create a persistent handle
|
|
566
|
+
opaque = new Nan::Persistent<v8::Value>(info[5]);
|
|
567
|
+
// To get the local from this later,
|
|
568
|
+
// v8::Local<v8::Object> object = Nan::New(persistent);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
std::vector<RdKafka::Headers::Header> headers;
|
|
572
|
+
if (info.Length() > 6 && !info[6]->IsUndefined()) {
|
|
573
|
+
v8::Local<v8::Array> v8Headers = v8::Local<v8::Array>::Cast(info[6]);
|
|
574
|
+
|
|
575
|
+
if (v8Headers->Length() >= 1) {
|
|
576
|
+
for (unsigned int i = 0; i < v8Headers->Length(); i++) {
|
|
577
|
+
v8::Local<v8::Object> header = Nan::Get(v8Headers, i).ToLocalChecked()
|
|
578
|
+
->ToObject(Nan::GetCurrentContext()).ToLocalChecked();
|
|
579
|
+
if (header.IsEmpty()) {
|
|
580
|
+
continue;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
v8::Local<v8::Array> props = header->GetOwnPropertyNames(
|
|
584
|
+
Nan::GetCurrentContext()).ToLocalChecked();
|
|
585
|
+
Nan::MaybeLocal<v8::String> v8Key = Nan::To<v8::String>(
|
|
586
|
+
Nan::Get(props, 0).ToLocalChecked());
|
|
587
|
+
Nan::MaybeLocal<v8::String> v8Value = Nan::To<v8::String>(
|
|
588
|
+
Nan::Get(header, v8Key.ToLocalChecked()).ToLocalChecked());
|
|
589
|
+
|
|
590
|
+
Nan::Utf8String uKey(v8Key.ToLocalChecked());
|
|
591
|
+
std::string key(*uKey);
|
|
592
|
+
|
|
593
|
+
Nan::Utf8String uValue(v8Value.ToLocalChecked());
|
|
594
|
+
std::string value(*uValue);
|
|
595
|
+
headers.push_back(
|
|
596
|
+
RdKafka::Headers::Header(key, value.c_str(), value.size()));
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
602
|
+
|
|
603
|
+
// Let the JS library throw if we need to so the error can be more rich
|
|
604
|
+
int error_code;
|
|
605
|
+
|
|
606
|
+
if (info[0]->IsString()) {
|
|
607
|
+
// Get string pointer for this thing
|
|
608
|
+
Nan::Utf8String topicUTF8(Nan::To<v8::String>(info[0]).ToLocalChecked());
|
|
609
|
+
std::string topic_name(*topicUTF8);
|
|
610
|
+
RdKafka::Headers *rd_headers = RdKafka::Headers::create(headers);
|
|
611
|
+
|
|
612
|
+
Baton b = producer->Produce(message_buffer_data, message_buffer_length,
|
|
613
|
+
topic_name, partition, key_buffer_data, key_buffer_length,
|
|
614
|
+
timestamp, opaque, rd_headers);
|
|
615
|
+
|
|
616
|
+
error_code = static_cast<int>(b.err());
|
|
617
|
+
if (error_code != 0 && rd_headers) {
|
|
618
|
+
delete rd_headers;
|
|
619
|
+
}
|
|
620
|
+
} else {
|
|
621
|
+
// First parameter is a topic OBJECT
|
|
622
|
+
Topic* topic = ObjectWrap::Unwrap<Topic>(info[0].As<v8::Object>());
|
|
623
|
+
|
|
624
|
+
// Unwrap it and turn it into an RdKafka::Topic*
|
|
625
|
+
Baton topic_baton = topic->toRDKafkaTopic(producer);
|
|
626
|
+
|
|
627
|
+
if (topic_baton.err() != RdKafka::ERR_NO_ERROR) {
|
|
628
|
+
// Let the JS library throw if we need to so the error can be more rich
|
|
629
|
+
error_code = static_cast<int>(topic_baton.err());
|
|
630
|
+
|
|
631
|
+
return info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
RdKafka::Topic* rd_topic = topic_baton.data<RdKafka::Topic*>();
|
|
635
|
+
|
|
636
|
+
Baton b = producer->Produce(message_buffer_data, message_buffer_length,
|
|
637
|
+
rd_topic, partition, key_buffer_data, key_buffer_length, opaque);
|
|
638
|
+
|
|
639
|
+
// Delete the topic when we are done.
|
|
640
|
+
delete rd_topic;
|
|
641
|
+
|
|
642
|
+
error_code = static_cast<int>(b.err());
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (error_code != 0 && opaque) {
|
|
646
|
+
// If there was an error enqueing this message, there will never
|
|
647
|
+
// be a delivery report for it, so we have to clean up the opaque
|
|
648
|
+
// data now, if there was any.
|
|
649
|
+
|
|
650
|
+
Nan::Persistent<v8::Value> *persistent =
|
|
651
|
+
static_cast<Nan::Persistent<v8::Value> *>(opaque);
|
|
652
|
+
persistent->Reset();
|
|
653
|
+
delete persistent;
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
if (key != NULL) {
|
|
657
|
+
delete key;
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
info.GetReturnValue().Set(Nan::New<v8::Number>(error_code));
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
NAN_METHOD(Producer::NodeSetPartitioner) {
|
|
664
|
+
Nan::HandleScope scope;
|
|
665
|
+
|
|
666
|
+
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
|
667
|
+
// Just throw an exception
|
|
668
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
672
|
+
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
|
|
673
|
+
producer->m_partitioner_cb.SetCallback(cb);
|
|
674
|
+
info.GetReturnValue().Set(Nan::True());
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
NAN_METHOD(Producer::NodeConnect) {
|
|
678
|
+
Nan::HandleScope scope;
|
|
679
|
+
|
|
680
|
+
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
|
681
|
+
// Just throw an exception
|
|
682
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// This needs to be offloaded to libuv
|
|
686
|
+
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
|
|
687
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
688
|
+
|
|
689
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
690
|
+
Nan::AsyncQueueWorker(new Workers::ProducerConnect(callback, producer));
|
|
691
|
+
|
|
692
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
NAN_METHOD(Producer::NodePoll) {
|
|
696
|
+
Nan::HandleScope scope;
|
|
697
|
+
|
|
698
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
699
|
+
|
|
700
|
+
if (!producer->IsConnected()) {
|
|
701
|
+
Nan::ThrowError("Producer is disconnected");
|
|
702
|
+
} else {
|
|
703
|
+
producer->Poll();
|
|
704
|
+
info.GetReturnValue().Set(Nan::True());
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
Baton Producer::Flush(int timeout_ms) {
|
|
709
|
+
RdKafka::ErrorCode response_code;
|
|
710
|
+
if (IsConnected()) {
|
|
711
|
+
scoped_shared_read_lock lock(m_connection_lock);
|
|
712
|
+
if (IsConnected()) {
|
|
713
|
+
RdKafka::Producer* producer = dynamic_cast<RdKafka::Producer*>(m_client);
|
|
714
|
+
response_code = producer->flush(timeout_ms);
|
|
715
|
+
} else {
|
|
716
|
+
response_code = RdKafka::ERR__STATE;
|
|
717
|
+
}
|
|
718
|
+
} else {
|
|
719
|
+
response_code = RdKafka::ERR__STATE;
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
return Baton(response_code);
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
NAN_METHOD(Producer::NodeFlush) {
|
|
726
|
+
Nan::HandleScope scope;
|
|
727
|
+
|
|
728
|
+
if (info.Length() < 2 || !info[1]->IsFunction() || !info[0]->IsNumber()) {
|
|
729
|
+
// Just throw an exception
|
|
730
|
+
return Nan::ThrowError("Need to specify a timeout and a callback");
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
int timeout_ms = Nan::To<int>(info[0]).FromJust();
|
|
734
|
+
|
|
735
|
+
v8::Local<v8::Function> cb = info[1].As<v8::Function>();
|
|
736
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
737
|
+
|
|
738
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
739
|
+
|
|
740
|
+
Nan::AsyncQueueWorker(
|
|
741
|
+
new Workers::ProducerFlush(callback, producer, timeout_ms));
|
|
742
|
+
|
|
743
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
NAN_METHOD(Producer::NodeDisconnect) {
|
|
747
|
+
Nan::HandleScope scope;
|
|
748
|
+
|
|
749
|
+
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
|
750
|
+
// Just throw an exception
|
|
751
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
|
|
755
|
+
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
|
|
756
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
757
|
+
|
|
758
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
759
|
+
Nan::AsyncQueueWorker(new Workers::ProducerDisconnect(callback, producer));
|
|
760
|
+
|
|
761
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
NAN_METHOD(Producer::NodeInitTransactions) {
|
|
765
|
+
Nan::HandleScope scope;
|
|
766
|
+
|
|
767
|
+
if (info.Length() < 2 || !info[1]->IsFunction() || !info[0]->IsNumber()) {
|
|
768
|
+
return Nan::ThrowError("Need to specify a timeout and a callback");
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
int timeout_ms = Nan::To<int>(info[0]).FromJust();
|
|
772
|
+
|
|
773
|
+
v8::Local<v8::Function> cb = info[1].As<v8::Function>();
|
|
774
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
775
|
+
|
|
776
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
777
|
+
Nan::AsyncQueueWorker(new Workers::ProducerInitTransactions(callback, producer, timeout_ms));
|
|
778
|
+
|
|
779
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
780
|
+
}
|
|
781
|
+
|
|
782
|
+
NAN_METHOD(Producer::NodeBeginTransaction) {
|
|
783
|
+
Nan::HandleScope scope;
|
|
784
|
+
|
|
785
|
+
if (info.Length() < 1 || !info[0]->IsFunction()) {
|
|
786
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
|
|
790
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
791
|
+
|
|
792
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
793
|
+
Nan::AsyncQueueWorker(new Workers::ProducerBeginTransaction(callback, producer));
|
|
794
|
+
|
|
795
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
NAN_METHOD(Producer::NodeCommitTransaction) {
|
|
799
|
+
Nan::HandleScope scope;
|
|
800
|
+
|
|
801
|
+
if (info.Length() < 2 || !info[1]->IsFunction() || !info[0]->IsNumber()) {
|
|
802
|
+
return Nan::ThrowError("Need to specify a timeout and a callback");
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
int timeout_ms = Nan::To<int>(info[0]).FromJust();
|
|
806
|
+
|
|
807
|
+
v8::Local<v8::Function> cb = info[1].As<v8::Function>();
|
|
808
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
809
|
+
|
|
810
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
811
|
+
Nan::AsyncQueueWorker(new Workers::ProducerCommitTransaction(callback, producer, timeout_ms));
|
|
812
|
+
|
|
813
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
NAN_METHOD(Producer::NodeAbortTransaction) {
|
|
817
|
+
Nan::HandleScope scope;
|
|
818
|
+
|
|
819
|
+
if (info.Length() < 2 || !info[1]->IsFunction() || !info[0]->IsNumber()) {
|
|
820
|
+
return Nan::ThrowError("Need to specify a timeout and a callback");
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
int timeout_ms = Nan::To<int>(info[0]).FromJust();
|
|
824
|
+
|
|
825
|
+
v8::Local<v8::Function> cb = info[1].As<v8::Function>();
|
|
826
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
827
|
+
|
|
828
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
829
|
+
Nan::AsyncQueueWorker(new Workers::ProducerAbortTransaction(callback, producer, timeout_ms));
|
|
830
|
+
|
|
831
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
NAN_METHOD(Producer::NodeSendOffsetsToTransaction) {
|
|
835
|
+
Nan::HandleScope scope;
|
|
836
|
+
|
|
837
|
+
if (info.Length() < 4) {
|
|
838
|
+
return Nan::ThrowError("Need to specify offsets, consumer, timeout for 'send offsets to transaction', and callback");
|
|
839
|
+
}
|
|
840
|
+
if (!info[0]->IsArray()) {
|
|
841
|
+
return Nan::ThrowError("First argument to 'send offsets to transaction' has to be a consumer object");
|
|
842
|
+
}
|
|
843
|
+
if (!info[1]->IsObject()) {
|
|
844
|
+
Nan::ThrowError("Kafka consumer must be provided");
|
|
845
|
+
}
|
|
846
|
+
if (!info[2]->IsNumber()) {
|
|
847
|
+
Nan::ThrowError("Timeout must be provided");
|
|
848
|
+
}
|
|
849
|
+
if (!info[3]->IsFunction()) {
|
|
850
|
+
return Nan::ThrowError("Need to specify a callback");
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
std::vector<RdKafka::TopicPartition*> toppars =
|
|
854
|
+
Conversion::TopicPartition::FromV8Array(info[0].As<v8::Array>());
|
|
855
|
+
NodeKafka::KafkaConsumer* consumer =
|
|
856
|
+
ObjectWrap::Unwrap<KafkaConsumer>(info[1].As<v8::Object>());
|
|
857
|
+
int timeout_ms = Nan::To<int>(info[2]).FromJust();
|
|
858
|
+
v8::Local<v8::Function> cb = info[3].As<v8::Function>();
|
|
859
|
+
Nan::Callback *callback = new Nan::Callback(cb);
|
|
860
|
+
|
|
861
|
+
Producer* producer = ObjectWrap::Unwrap<Producer>(info.This());
|
|
862
|
+
Nan::AsyncQueueWorker(new Workers::ProducerSendOffsetsToTransaction(
|
|
863
|
+
callback,
|
|
864
|
+
producer,
|
|
865
|
+
toppars,
|
|
866
|
+
consumer,
|
|
867
|
+
timeout_ms
|
|
868
|
+
));
|
|
869
|
+
|
|
870
|
+
info.GetReturnValue().Set(Nan::Null());
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
} // namespace NodeKafka
|