@ohos-ports/confluentinc-kafka-javascript 1.10.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +457 -0
- package/LICENSE.kafkajs +31 -0
- package/LICENSE.node-rdkafka +25 -0
- package/LICENSE.txt +20 -0
- package/README.md +133 -0
- package/binding.gyp +184 -0
- package/build/Release/confluent-kafka-javascript.node +0 -0
- package/build/deps/librdkafka++.so.1 +0 -0
- package/build/deps/librdkafka.Makefile +6 -0
- package/build/deps/librdkafka.so.1 +0 -0
- package/build/deps/librdkafka.target.mk +55 -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 +35 -0
- package/deps/librdkafka/.gdbmacros +19 -0
- package/deps/librdkafka/CHANGELOG.md +2477 -0
- package/deps/librdkafka/CMakeLists.txt +291 -0
- package/deps/librdkafka/CODE_OF_CONDUCT.md +46 -0
- package/deps/librdkafka/CONFIGURATION.md +212 -0
- package/deps/librdkafka/CONTRIBUTING.md +431 -0
- package/deps/librdkafka/Doxyfile +2375 -0
- package/deps/librdkafka/INTRODUCTION.md +2752 -0
- package/deps/librdkafka/LICENSE +26 -0
- package/deps/librdkafka/LICENSE.cjson +22 -0
- package/deps/librdkafka/LICENSE.crc32c +28 -0
- package/deps/librdkafka/LICENSE.fnv1a +18 -0
- package/deps/librdkafka/LICENSE.hdrhistogram +27 -0
- package/deps/librdkafka/LICENSE.lz4 +26 -0
- package/deps/librdkafka/LICENSE.murmur2 +25 -0
- package/deps/librdkafka/LICENSE.nanopb +22 -0
- package/deps/librdkafka/LICENSE.opentelemetry +203 -0
- package/deps/librdkafka/LICENSE.pycrc +23 -0
- package/deps/librdkafka/LICENSE.queue +31 -0
- package/deps/librdkafka/LICENSE.regexp +5 -0
- package/deps/librdkafka/LICENSE.snappy +36 -0
- package/deps/librdkafka/LICENSE.tinycthread +26 -0
- package/deps/librdkafka/LICENSE.wingetopt +49 -0
- package/deps/librdkafka/LICENSES.txt +625 -0
- package/deps/librdkafka/Makefile +125 -0
- package/deps/librdkafka/README.md +201 -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 +341 -0
- package/deps/librdkafka/dev-conf.sh +123 -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/service.yml +182 -0
- package/deps/librdkafka/src/CMakeLists.txt +379 -0
- package/deps/librdkafka/src/Makefile +105 -0
- package/deps/librdkafka/src/README.lz4.md +30 -0
- package/deps/librdkafka/src/cJSON.c +3191 -0
- package/deps/librdkafka/src/cJSON.h +306 -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 +592 -0
- package/deps/librdkafka/src/rdaddr.c +255 -0
- package/deps/librdkafka/src/rdaddr.h +202 -0
- package/deps/librdkafka/src/rdatomic.h +262 -0
- package/deps/librdkafka/src/rdavg.h +260 -0
- package/deps/librdkafka/src/rdavl.c +210 -0
- package/deps/librdkafka/src/rdavl.h +250 -0
- package/deps/librdkafka/src/rdbase64.c +200 -0
- package/deps/librdkafka/src/rdbase64.h +43 -0
- package/deps/librdkafka/src/rdbuf.c +1884 -0
- package/deps/librdkafka/src/rdbuf.h +375 -0
- package/deps/librdkafka/src/rdcrc32.c +114 -0
- package/deps/librdkafka/src/rdcrc32.h +170 -0
- package/deps/librdkafka/src/rddl.c +179 -0
- package/deps/librdkafka/src/rddl.h +43 -0
- package/deps/librdkafka/src/rdendian.h +175 -0
- package/deps/librdkafka/src/rdfloat.h +67 -0
- package/deps/librdkafka/src/rdfnv1a.c +113 -0
- package/deps/librdkafka/src/rdfnv1a.h +35 -0
- package/deps/librdkafka/src/rdgz.c +120 -0
- package/deps/librdkafka/src/rdgz.h +46 -0
- package/deps/librdkafka/src/rdhdrhistogram.c +721 -0
- package/deps/librdkafka/src/rdhdrhistogram.h +87 -0
- package/deps/librdkafka/src/rdhttp.c +831 -0
- package/deps/librdkafka/src/rdhttp.h +101 -0
- package/deps/librdkafka/src/rdinterval.h +177 -0
- package/deps/librdkafka/src/rdkafka.c +7287 -0
- package/deps/librdkafka/src/rdkafka.h +11795 -0
- package/deps/librdkafka/src/rdkafka_admin.c +10165 -0
- package/deps/librdkafka/src/rdkafka_admin.h +658 -0
- package/deps/librdkafka/src/rdkafka_assignment.c +1282 -0
- package/deps/librdkafka/src/rdkafka_assignment.h +73 -0
- package/deps/librdkafka/src/rdkafka_assignor.c +1800 -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 +222 -0
- package/deps/librdkafka/src/rdkafka_broker.c +6736 -0
- package/deps/librdkafka/src/rdkafka_broker.h +851 -0
- package/deps/librdkafka/src/rdkafka_buf.c +543 -0
- package/deps/librdkafka/src/rdkafka_buf.h +1525 -0
- package/deps/librdkafka/src/rdkafka_cert.c +576 -0
- package/deps/librdkafka/src/rdkafka_cert.h +62 -0
- package/deps/librdkafka/src/rdkafka_cgrp.c +8310 -0
- package/deps/librdkafka/src/rdkafka_cgrp.h +589 -0
- package/deps/librdkafka/src/rdkafka_conf.c +5177 -0
- package/deps/librdkafka/src/rdkafka_conf.h +746 -0
- package/deps/librdkafka/src/rdkafka_confval.h +97 -0
- package/deps/librdkafka/src/rdkafka_coord.c +623 -0
- package/deps/librdkafka/src/rdkafka_coord.h +132 -0
- package/deps/librdkafka/src/rdkafka_error.c +228 -0
- package/deps/librdkafka/src/rdkafka_error.h +80 -0
- package/deps/librdkafka/src/rdkafka_event.c +502 -0
- package/deps/librdkafka/src/rdkafka_event.h +126 -0
- package/deps/librdkafka/src/rdkafka_feature.c +898 -0
- package/deps/librdkafka/src/rdkafka_feature.h +104 -0
- package/deps/librdkafka/src/rdkafka_fetcher.c +3820 -0
- package/deps/librdkafka/src/rdkafka_fetcher.h +62 -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 +1505 -0
- package/deps/librdkafka/src/rdkafka_interceptor.c +842 -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 +2347 -0
- package/deps/librdkafka/src/rdkafka_metadata.h +350 -0
- package/deps/librdkafka/src/rdkafka_metadata_cache.c +1183 -0
- package/deps/librdkafka/src/rdkafka_mock.c +4514 -0
- package/deps/librdkafka/src/rdkafka_mock.h +867 -0
- package/deps/librdkafka/src/rdkafka_mock_cgrp.c +1877 -0
- package/deps/librdkafka/src/rdkafka_mock_handlers.c +5255 -0
- package/deps/librdkafka/src/rdkafka_mock_int.h +1005 -0
- package/deps/librdkafka/src/rdkafka_mock_sharegrp.c +1207 -0
- package/deps/librdkafka/src/rdkafka_msg.c +2619 -0
- package/deps/librdkafka/src/rdkafka_msg.h +629 -0
- package/deps/librdkafka/src/rdkafka_msgbatch.h +62 -0
- package/deps/librdkafka/src/rdkafka_msgset.h +105 -0
- package/deps/librdkafka/src/rdkafka_msgset_reader.c +2099 -0
- package/deps/librdkafka/src/rdkafka_msgset_writer.c +1474 -0
- package/deps/librdkafka/src/rdkafka_offset.c +1565 -0
- package/deps/librdkafka/src/rdkafka_offset.h +150 -0
- package/deps/librdkafka/src/rdkafka_op.c +1219 -0
- package/deps/librdkafka/src/rdkafka_op.h +1065 -0
- package/deps/librdkafka/src/rdkafka_partition.c +5109 -0
- package/deps/librdkafka/src/rdkafka_partition.h +1215 -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 +739 -0
- package/deps/librdkafka/src/rdkafka_protocol.h +131 -0
- package/deps/librdkafka/src/rdkafka_queue.c +1351 -0
- package/deps/librdkafka/src/rdkafka_queue.h +1235 -0
- package/deps/librdkafka/src/rdkafka_range_assignor.c +1748 -0
- package/deps/librdkafka/src/rdkafka_request.c +7298 -0
- package/deps/librdkafka/src/rdkafka_request.h +761 -0
- package/deps/librdkafka/src/rdkafka_roundrobin_assignor.c +123 -0
- package/deps/librdkafka/src/rdkafka_sasl.c +589 -0
- package/deps/librdkafka/src/rdkafka_sasl.h +63 -0
- package/deps/librdkafka/src/rdkafka_sasl_cyrus.c +722 -0
- package/deps/librdkafka/src/rdkafka_sasl_int.h +89 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.c +1833 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.c +1827 -0
- package/deps/librdkafka/src/rdkafka_sasl_oauthbearer_oidc.h +52 -0
- package/deps/librdkafka/src/rdkafka_sasl_plain.c +142 -0
- package/deps/librdkafka/src/rdkafka_sasl_scram.c +858 -0
- package/deps/librdkafka/src/rdkafka_sasl_win32.c +550 -0
- package/deps/librdkafka/src/rdkafka_share_acknowledgement.c +1445 -0
- package/deps/librdkafka/src/rdkafka_share_acknowledgement.h +373 -0
- package/deps/librdkafka/src/rdkafka_ssl.c +2235 -0
- package/deps/librdkafka/src/rdkafka_ssl.h +86 -0
- package/deps/librdkafka/src/rdkafka_sticky_assignor.c +4785 -0
- package/deps/librdkafka/src/rdkafka_subscription.c +411 -0
- package/deps/librdkafka/src/rdkafka_telemetry.c +761 -0
- package/deps/librdkafka/src/rdkafka_telemetry.h +52 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.c +1307 -0
- package/deps/librdkafka/src/rdkafka_telemetry_decode.h +59 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.c +1309 -0
- package/deps/librdkafka/src/rdkafka_telemetry_encode.h +459 -0
- package/deps/librdkafka/src/rdkafka_timer.c +407 -0
- package/deps/librdkafka/src/rdkafka_timer.h +117 -0
- package/deps/librdkafka/src/rdkafka_topic.c +2382 -0
- package/deps/librdkafka/src/rdkafka_topic.h +369 -0
- package/deps/librdkafka/src/rdkafka_transport.c +1309 -0
- package/deps/librdkafka/src/rdkafka_transport.h +99 -0
- package/deps/librdkafka/src/rdkafka_transport_int.h +100 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.c +3256 -0
- package/deps/librdkafka/src/rdkafka_txnmgr.h +171 -0
- package/deps/librdkafka/src/rdkafka_zstd.c +226 -0
- package/deps/librdkafka/src/rdkafka_zstd.h +57 -0
- package/deps/librdkafka/src/rdlist.c +593 -0
- package/deps/librdkafka/src/rdlist.h +444 -0
- package/deps/librdkafka/src/rdlog.c +89 -0
- package/deps/librdkafka/src/rdlog.h +41 -0
- package/deps/librdkafka/src/rdmap.c +508 -0
- package/deps/librdkafka/src/rdmap.h +492 -0
- package/deps/librdkafka/src/rdmurmur2.c +167 -0
- package/deps/librdkafka/src/rdmurmur2.h +35 -0
- package/deps/librdkafka/src/rdports.c +61 -0
- package/deps/librdkafka/src/rdports.h +38 -0
- package/deps/librdkafka/src/rdposix.h +250 -0
- package/deps/librdkafka/src/rdrand.c +151 -0
- package/deps/librdkafka/src/rdrand.h +72 -0
- package/deps/librdkafka/src/rdregex.c +156 -0
- package/deps/librdkafka/src/rdregex.h +43 -0
- package/deps/librdkafka/src/rdsignal.h +57 -0
- package/deps/librdkafka/src/rdstring.c +645 -0
- package/deps/librdkafka/src/rdstring.h +98 -0
- package/deps/librdkafka/src/rdsysqueue.h +404 -0
- package/deps/librdkafka/src/rdtime.h +356 -0
- package/deps/librdkafka/src/rdtypes.h +86 -0
- package/deps/librdkafka/src/rdunittest.c +564 -0
- package/deps/librdkafka/src/rdunittest.h +232 -0
- package/deps/librdkafka/src/rdunittest_acknowledge.c +1177 -0
- package/deps/librdkafka/src/rdunittest_fetcher.c +1211 -0
- package/deps/librdkafka/src/rdunittest_msgset_errors.c +1521 -0
- package/deps/librdkafka/src/rdvarint.c +134 -0
- package/deps/librdkafka/src/rdvarint.h +165 -0
- package/deps/librdkafka/src/rdwin32.h +382 -0
- package/deps/librdkafka/src/rdxxhash.c +1030 -0
- package/deps/librdkafka/src/rdxxhash.h +328 -0
- package/deps/librdkafka/src/regexp.c +1352 -0
- package/deps/librdkafka/src/regexp.h +41 -0
- package/deps/librdkafka/src/snappy.c +1866 -0
- package/deps/librdkafka/src/snappy.h +62 -0
- package/deps/librdkafka/src/snappy_compat.h +138 -0
- package/deps/librdkafka/src/statistics_schema.json +444 -0
- package/deps/librdkafka/src/tinycthread.c +932 -0
- package/deps/librdkafka/src/tinycthread.h +503 -0
- package/deps/librdkafka/src/tinycthread_extra.c +210 -0
- package/deps/librdkafka/src/tinycthread_extra.h +218 -0
- package/deps/librdkafka/src/win32_config.h +58 -0
- package/deps/librdkafka/src-cpp/CMakeLists.txt +90 -0
- package/deps/librdkafka/src-cpp/ConfImpl.cpp +84 -0
- package/deps/librdkafka/src-cpp/ConsumerImpl.cpp +244 -0
- package/deps/librdkafka/src-cpp/HandleImpl.cpp +436 -0
- package/deps/librdkafka/src-cpp/HeadersImpl.cpp +48 -0
- package/deps/librdkafka/src-cpp/KafkaConsumerImpl.cpp +296 -0
- package/deps/librdkafka/src-cpp/Makefile +55 -0
- package/deps/librdkafka/src-cpp/MessageImpl.cpp +38 -0
- package/deps/librdkafka/src-cpp/MetadataImpl.cpp +170 -0
- package/deps/librdkafka/src-cpp/ProducerImpl.cpp +197 -0
- package/deps/librdkafka/src-cpp/QueueImpl.cpp +70 -0
- package/deps/librdkafka/src-cpp/README.md +16 -0
- package/deps/librdkafka/src-cpp/RdKafka.cpp +59 -0
- package/deps/librdkafka/src-cpp/TopicImpl.cpp +124 -0
- package/deps/librdkafka/src-cpp/TopicPartitionImpl.cpp +57 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp.h +3797 -0
- package/deps/librdkafka/src-cpp/rdkafkacpp_int.h +1641 -0
- package/deps/librdkafka/tests/0000-unittests.c +72 -0
- package/deps/librdkafka/tests/0001-multiobj.c +102 -0
- package/deps/librdkafka/tests/0002-unkpart.c +244 -0
- package/deps/librdkafka/tests/0003-msgmaxsize.c +173 -0
- package/deps/librdkafka/tests/0004-conf.c +934 -0
- package/deps/librdkafka/tests/0005-order.c +133 -0
- package/deps/librdkafka/tests/0006-symbols.c +163 -0
- package/deps/librdkafka/tests/0007-autotopic.c +136 -0
- package/deps/librdkafka/tests/0008-reqacks.c +179 -0
- package/deps/librdkafka/tests/0009-mock_cluster.c +272 -0
- package/deps/librdkafka/tests/0011-produce_batch.c +753 -0
- package/deps/librdkafka/tests/0012-produce_consume.c +537 -0
- package/deps/librdkafka/tests/0013-null-msgs.c +473 -0
- package/deps/librdkafka/tests/0014-reconsume-191.c +512 -0
- package/deps/librdkafka/tests/0015-offset_seeks.c +172 -0
- package/deps/librdkafka/tests/0016-client_swname.c +181 -0
- package/deps/librdkafka/tests/0017-compression.c +140 -0
- package/deps/librdkafka/tests/0018-cgrp_term.c +444 -0
- package/deps/librdkafka/tests/0019-list_groups.c +289 -0
- package/deps/librdkafka/tests/0020-destroy_hang.c +162 -0
- package/deps/librdkafka/tests/0021-rkt_destroy.c +72 -0
- package/deps/librdkafka/tests/0022-consume_batch.c +331 -0
- package/deps/librdkafka/tests/0025-timers.c +147 -0
- package/deps/librdkafka/tests/0026-consume_pause.c +547 -0
- package/deps/librdkafka/tests/0028-long_topicnames.c +79 -0
- package/deps/librdkafka/tests/0029-assign_offset.c +202 -0
- package/deps/librdkafka/tests/0030-offset_commit.c +589 -0
- package/deps/librdkafka/tests/0031-get_offsets.c +235 -0
- package/deps/librdkafka/tests/0033-regex_subscribe.c +536 -0
- package/deps/librdkafka/tests/0034-offset_reset.c +398 -0
- package/deps/librdkafka/tests/0035-api_version.c +73 -0
- package/deps/librdkafka/tests/0036-partial_fetch.c +87 -0
- package/deps/librdkafka/tests/0037-destroy_hang_local.c +85 -0
- package/deps/librdkafka/tests/0038-performance.c +121 -0
- package/deps/librdkafka/tests/0039-event.c +284 -0
- package/deps/librdkafka/tests/0040-io_event.c +257 -0
- package/deps/librdkafka/tests/0041-fetch_max_bytes.c +97 -0
- package/deps/librdkafka/tests/0042-many_topics.c +252 -0
- package/deps/librdkafka/tests/0043-no_connection.c +77 -0
- package/deps/librdkafka/tests/0044-partition_cnt.c +94 -0
- package/deps/librdkafka/tests/0045-subscribe_update.c +1010 -0
- package/deps/librdkafka/tests/0046-rkt_cache.c +65 -0
- package/deps/librdkafka/tests/0047-partial_buf_tmout.c +98 -0
- package/deps/librdkafka/tests/0048-partitioner.c +283 -0
- package/deps/librdkafka/tests/0049-consume_conn_close.c +162 -0
- package/deps/librdkafka/tests/0050-subscribe_adds.c +145 -0
- package/deps/librdkafka/tests/0051-assign_adds.c +126 -0
- package/deps/librdkafka/tests/0052-msg_timestamps.c +238 -0
- package/deps/librdkafka/tests/0053-stats_cb.cpp +527 -0
- package/deps/librdkafka/tests/0054-offset_time.cpp +236 -0
- package/deps/librdkafka/tests/0055-producer_latency.c +539 -0
- package/deps/librdkafka/tests/0056-balanced_group_mt.c +315 -0
- package/deps/librdkafka/tests/0057-invalid_topic.cpp +112 -0
- package/deps/librdkafka/tests/0058-log.cpp +123 -0
- package/deps/librdkafka/tests/0059-bsearch.cpp +241 -0
- package/deps/librdkafka/tests/0060-op_prio.cpp +163 -0
- package/deps/librdkafka/tests/0061-consumer_lag.cpp +295 -0
- package/deps/librdkafka/tests/0062-stats_event.c +126 -0
- package/deps/librdkafka/tests/0063-clusterid.cpp +180 -0
- package/deps/librdkafka/tests/0064-interceptors.c +529 -0
- package/deps/librdkafka/tests/0065-yield.cpp +140 -0
- package/deps/librdkafka/tests/0066-plugins.cpp +143 -0
- package/deps/librdkafka/tests/0067-empty_topic.cpp +151 -0
- package/deps/librdkafka/tests/0068-produce_timeout.c +136 -0
- package/deps/librdkafka/tests/0069-consumer_add_parts.c +119 -0
- package/deps/librdkafka/tests/0070-null_empty.cpp +197 -0
- package/deps/librdkafka/tests/0072-headers_ut.c +448 -0
- package/deps/librdkafka/tests/0073-headers.c +381 -0
- package/deps/librdkafka/tests/0074-producev.c +87 -0
- package/deps/librdkafka/tests/0075-retry.c +290 -0
- package/deps/librdkafka/tests/0076-produce_retry.c +452 -0
- package/deps/librdkafka/tests/0077-compaction.c +366 -0
- package/deps/librdkafka/tests/0078-c_from_cpp.cpp +96 -0
- package/deps/librdkafka/tests/0079-fork.c +93 -0
- package/deps/librdkafka/tests/0080-admin_ut.c +3095 -0
- package/deps/librdkafka/tests/0081-admin.c +5633 -0
- package/deps/librdkafka/tests/0082-fetch_max_bytes.cpp +137 -0
- package/deps/librdkafka/tests/0083-cb_event.c +233 -0
- package/deps/librdkafka/tests/0084-destroy_flags.c +208 -0
- package/deps/librdkafka/tests/0085-headers.cpp +392 -0
- package/deps/librdkafka/tests/0086-purge.c +368 -0
- package/deps/librdkafka/tests/0088-produce_metadata_timeout.c +162 -0
- package/deps/librdkafka/tests/0089-max_poll_interval.c +511 -0
- package/deps/librdkafka/tests/0090-idempotence.c +171 -0
- package/deps/librdkafka/tests/0091-max_poll_interval_timeout.c +295 -0
- package/deps/librdkafka/tests/0092-mixed_msgver.c +103 -0
- package/deps/librdkafka/tests/0093-holb.c +200 -0
- package/deps/librdkafka/tests/0094-idempotence_msg_timeout.c +231 -0
- package/deps/librdkafka/tests/0095-all_brokers_down.cpp +122 -0
- package/deps/librdkafka/tests/0097-ssl_verify.cpp +674 -0
- package/deps/librdkafka/tests/0098-consumer-txn.cpp +1218 -0
- package/deps/librdkafka/tests/0099-commit_metadata.c +194 -0
- package/deps/librdkafka/tests/0100-thread_interceptors.cpp +195 -0
- package/deps/librdkafka/tests/0101-fetch-from-follower.cpp +446 -0
- package/deps/librdkafka/tests/0102-static_group_rebalance.c +836 -0
- package/deps/librdkafka/tests/0103-transactions.c +1383 -0
- package/deps/librdkafka/tests/0104-fetch_from_follower_mock.c +625 -0
- package/deps/librdkafka/tests/0105-transactions_mock.c +3930 -0
- package/deps/librdkafka/tests/0106-cgrp_sess_timeout.c +318 -0
- package/deps/librdkafka/tests/0107-topic_recreate.c +259 -0
- package/deps/librdkafka/tests/0109-auto_create_topics.cpp +278 -0
- package/deps/librdkafka/tests/0110-batch_size.cpp +182 -0
- package/deps/librdkafka/tests/0111-delay_create_topics.cpp +127 -0
- package/deps/librdkafka/tests/0112-assign_unknown_part.c +87 -0
- package/deps/librdkafka/tests/0113-cooperative_rebalance.cpp +3473 -0
- package/deps/librdkafka/tests/0114-sticky_partitioning.cpp +176 -0
- package/deps/librdkafka/tests/0115-producer_auth.cpp +182 -0
- package/deps/librdkafka/tests/0116-kafkaconsumer_close.cpp +216 -0
- package/deps/librdkafka/tests/0117-mock_errors.c +331 -0
- package/deps/librdkafka/tests/0118-commit_rebalance.c +154 -0
- package/deps/librdkafka/tests/0119-consumer_auth.cpp +167 -0
- package/deps/librdkafka/tests/0120-asymmetric_subscription.c +185 -0
- package/deps/librdkafka/tests/0121-clusterid.c +115 -0
- package/deps/librdkafka/tests/0122-buffer_cleaning_after_rebalance.c +227 -0
- package/deps/librdkafka/tests/0123-connections_max_idle.c +98 -0
- package/deps/librdkafka/tests/0124-openssl_invalid_engine.c +69 -0
- package/deps/librdkafka/tests/0125-immediate_flush.c +144 -0
- package/deps/librdkafka/tests/0126-oauthbearer_oidc.c +1164 -0
- package/deps/librdkafka/tests/0127-fetch_queue_backoff.cpp +165 -0
- package/deps/librdkafka/tests/0128-sasl_callback_queue.cpp +217 -0
- package/deps/librdkafka/tests/0129-fetch_aborted_msgs.c +79 -0
- package/deps/librdkafka/tests/0130-store_offsets.c +178 -0
- package/deps/librdkafka/tests/0131-connect_timeout.c +81 -0
- package/deps/librdkafka/tests/0132-strategy_ordering.c +179 -0
- package/deps/librdkafka/tests/0133-ssl_keys.c +150 -0
- package/deps/librdkafka/tests/0134-ssl_provider.c +92 -0
- package/deps/librdkafka/tests/0135-sasl_credentials.cpp +279 -0
- package/deps/librdkafka/tests/0136-resolve_cb.c +181 -0
- package/deps/librdkafka/tests/0137-barrier_batch_consume.c +752 -0
- package/deps/librdkafka/tests/0138-admin_mock.c +281 -0
- package/deps/librdkafka/tests/0139-offset_validation_mock.c +950 -0
- package/deps/librdkafka/tests/0140-commit_metadata.cpp +108 -0
- package/deps/librdkafka/tests/0142-reauthentication.c +931 -0
- package/deps/librdkafka/tests/0143-exponential_backoff_mock.c +552 -0
- package/deps/librdkafka/tests/0144-idempotence_mock.c +373 -0
- package/deps/librdkafka/tests/0145-pause_resume_mock.c +119 -0
- package/deps/librdkafka/tests/0146-metadata_mock.c +505 -0
- package/deps/librdkafka/tests/0147-consumer_group_consumer_mock.c +1210 -0
- package/deps/librdkafka/tests/0148-offset_fetch_commit_error_mock.c +569 -0
- package/deps/librdkafka/tests/0149-broker-same-host-port.c +140 -0
- package/deps/librdkafka/tests/0150-telemetry_mock.c +651 -0
- package/deps/librdkafka/tests/0151-purge-brokers.c +566 -0
- package/deps/librdkafka/tests/0152-rebootstrap.c +59 -0
- package/deps/librdkafka/tests/0153-memberid.c +128 -0
- package/deps/librdkafka/tests/0155-share_group_heartbeat_mock.c +2695 -0
- package/deps/librdkafka/tests/0156-share_consumer_fetch_mock.c +1551 -0
- package/deps/librdkafka/tests/0157-share_consumer_ack_mock.c +1788 -0
- package/deps/librdkafka/tests/0158-share_consumer_transactions_mock.c +467 -0
- package/deps/librdkafka/tests/0170-share_consumer_subscription.c +2192 -0
- package/deps/librdkafka/tests/0171-share_consumer_consume.c +2150 -0
- package/deps/librdkafka/tests/0172-share_consumer_acknowledge.c +1919 -0
- package/deps/librdkafka/tests/0173-share_consumer_commit_async.c +2735 -0
- package/deps/librdkafka/tests/0174-share_consumer_concurrency.c +1434 -0
- package/deps/librdkafka/tests/0175-share_consumer_groups.c +574 -0
- package/deps/librdkafka/tests/0176-share_consumer_commit_sync.c +2986 -0
- package/deps/librdkafka/tests/0177-share_consumer_transactions.c +1815 -0
- package/deps/librdkafka/tests/0178-share_consumer_close.c +2102 -0
- package/deps/librdkafka/tests/0179-share_consumer_destroy.c +2482 -0
- package/deps/librdkafka/tests/0180-share_consumer_config.c +1677 -0
- package/deps/librdkafka/tests/0181-share_consumer_topic_delete.c +354 -0
- package/deps/librdkafka/tests/0182-share_consumer_error_handling_mock.c +3358 -0
- package/deps/librdkafka/tests/0183-share_consumer_leader_change_mock.c +1234 -0
- package/deps/librdkafka/tests/0184-share_consumer_topic_recreate.c +1356 -0
- package/deps/librdkafka/tests/0185-share_consumer_max_poll_interval.c +557 -0
- package/deps/librdkafka/tests/0186-share_consumer_fatal_error.c +360 -0
- package/deps/librdkafka/tests/0190-share_consumer_telemetry.c +387 -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 +193 -0
- package/deps/librdkafka/tests/LibrdkafkaTestApp.py +291 -0
- package/deps/librdkafka/tests/Makefile +182 -0
- package/deps/librdkafka/tests/README.md +514 -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 +203 -0
- package/deps/librdkafka/tests/delete-test-topics.sh +56 -0
- package/deps/librdkafka/tests/fixtures/oauthbearer/jwt_assertion_template.json +10 -0
- package/deps/librdkafka/tests/fixtures/ssl/Makefile +8 -0
- package/deps/librdkafka/tests/fixtures/ssl/README.md +13 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.intermediate.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client.keystore.p12 +0 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.intermediate.pem +72 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.certificate.pem +50 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.intermediate.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/client2.key +46 -0
- package/deps/librdkafka/tests/fixtures/ssl/create_keys.sh +168 -0
- package/deps/librdkafka/tests/fuzzers/Makefile +12 -0
- package/deps/librdkafka/tests/fuzzers/README.md +31 -0
- package/deps/librdkafka/tests/fuzzers/fuzz_regex.c +74 -0
- package/deps/librdkafka/tests/fuzzers/helpers.h +90 -0
- package/deps/librdkafka/tests/gen-ssl-certs.sh +165 -0
- package/deps/librdkafka/tests/interactive_broker_version.py +170 -0
- package/deps/librdkafka/tests/interceptor_test/CMakeLists.txt +16 -0
- package/deps/librdkafka/tests/interceptor_test/Makefile +22 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.c +314 -0
- package/deps/librdkafka/tests/interceptor_test/interceptor_test.h +54 -0
- package/deps/librdkafka/tests/java/IncrementalRebalanceCli.java +97 -0
- package/deps/librdkafka/tests/java/Makefile +13 -0
- package/deps/librdkafka/tests/java/Murmur2Cli.java +46 -0
- package/deps/librdkafka/tests/java/README.md +14 -0
- package/deps/librdkafka/tests/java/TransactionProducerCli.java +162 -0
- package/deps/librdkafka/tests/java/run-class.sh +11 -0
- package/deps/librdkafka/tests/librdkafka.suppressions +483 -0
- package/deps/librdkafka/tests/lz4_manual_test.sh +59 -0
- package/deps/librdkafka/tests/multi-broker-version-test.sh +50 -0
- package/deps/librdkafka/tests/parse-refcnt.sh +43 -0
- package/deps/librdkafka/tests/performance_plot.py +115 -0
- package/deps/librdkafka/tests/plugin_test/Makefile +19 -0
- package/deps/librdkafka/tests/plugin_test/plugin_test.c +58 -0
- package/deps/librdkafka/tests/requirements.txt +2 -0
- package/deps/librdkafka/tests/run-all-tests.sh +81 -0
- package/deps/librdkafka/tests/run-consumer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-producer-tests.sh +16 -0
- package/deps/librdkafka/tests/run-test-batches.py +157 -0
- package/deps/librdkafka/tests/run-test.sh +141 -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/share_telemetry_verify/share-otel-collector-config.yaml +28 -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 +8376 -0
- package/deps/librdkafka/tests/test.conf.example +27 -0
- package/deps/librdkafka/tests/test.h +1150 -0
- package/deps/librdkafka/tests/testcpp.cpp +131 -0
- package/deps/librdkafka/tests/testcpp.h +388 -0
- package/deps/librdkafka/tests/testshared.h +416 -0
- package/deps/librdkafka/tests/tools/README.md +4 -0
- package/deps/librdkafka/tests/tools/stats/README.md +21 -0
- package/deps/librdkafka/tests/tools/stats/filter.jq +42 -0
- package/deps/librdkafka/tests/tools/stats/graph.py +150 -0
- package/deps/librdkafka/tests/tools/stats/requirements.txt +3 -0
- package/deps/librdkafka/tests/tools/stats/to_csv.py +124 -0
- package/deps/librdkafka/tests/trivup/trivup-0.15.0.tar.gz +0 -0
- package/deps/librdkafka/tests/until-fail.sh +87 -0
- package/deps/librdkafka/tests/xxxx-assign_partition.c +122 -0
- package/deps/librdkafka/tests/xxxx-metadata.cpp +159 -0
- package/deps/librdkafka/vcpkg.json +23 -0
- package/deps/librdkafka/win32/README.md +5 -0
- package/deps/librdkafka/win32/build-package.bat +3 -0
- package/deps/librdkafka/win32/build.bat +19 -0
- package/deps/librdkafka/win32/common.vcxproj +84 -0
- package/deps/librdkafka/win32/interceptor_test/interceptor_test.vcxproj +87 -0
- package/deps/librdkafka/win32/librdkafka.autopkg.template +54 -0
- package/deps/librdkafka/win32/librdkafka.master.testing.targets +13 -0
- package/deps/librdkafka/win32/librdkafka.sln +226 -0
- package/deps/librdkafka/win32/librdkafka.vcxproj +282 -0
- package/deps/librdkafka/win32/librdkafkacpp/librdkafkacpp.vcxproj +104 -0
- package/deps/librdkafka/win32/msbuild.ps1 +58 -0
- package/deps/librdkafka/win32/openssl_engine_example/openssl_engine_example.vcxproj +132 -0
- package/deps/librdkafka/win32/package-zip.ps1 +46 -0
- package/deps/librdkafka/win32/packages/repositories.config +4 -0
- package/deps/librdkafka/win32/push-package.bat +4 -0
- package/deps/librdkafka/win32/rdkafka_complex_consumer_example_cpp/rdkafka_complex_consumer_example_cpp.vcxproj +67 -0
- package/deps/librdkafka/win32/rdkafka_example/rdkafka_example.vcxproj +97 -0
- package/deps/librdkafka/win32/rdkafka_performance/rdkafka_performance.vcxproj +97 -0
- package/deps/librdkafka/win32/setup-msys2.ps1 +47 -0
- package/deps/librdkafka/win32/setup-vcpkg.ps1 +34 -0
- package/deps/librdkafka/win32/tests/test.conf.example +25 -0
- package/deps/librdkafka/win32/tests/tests.vcxproj +278 -0
- package/deps/librdkafka/win32/win_ssl_cert_store/win_ssl_cert_store.vcxproj +132 -0
- package/deps/librdkafka/win32/wingetopt.c +564 -0
- package/deps/librdkafka/win32/wingetopt.h +101 -0
- package/deps/librdkafka/win32/wintime.h +33 -0
- package/deps/librdkafka.gyp +83 -0
- package/deps/windows-install.py +80 -0
- package/index.d.ts +3 -0
- package/lib/admin.js +732 -0
- package/lib/client.js +679 -0
- package/lib/error.js +501 -0
- package/lib/index.js +8 -0
- package/lib/kafka-consumer-stream.js +399 -0
- package/lib/kafka-consumer.js +798 -0
- package/lib/kafkajs/_admin.js +1052 -0
- package/lib/kafkajs/_common.js +887 -0
- package/lib/kafkajs/_consumer.js +2156 -0
- package/lib/kafkajs/_consumer_cache.js +310 -0
- package/lib/kafkajs/_error.js +298 -0
- package/lib/kafkajs/_kafka.js +125 -0
- package/lib/kafkajs/_linked-list.js +220 -0
- package/lib/kafkajs/_producer.js +863 -0
- package/lib/kafkajs/index.js +5 -0
- package/lib/producer/high-level-producer.js +400 -0
- package/lib/producer-stream.js +337 -0
- package/lib/producer.js +405 -0
- package/lib/rdkafka.js +44 -0
- package/lib/tools/ref-counter.js +53 -0
- package/lib/topic-partition.js +91 -0
- package/lib/topic.js +43 -0
- package/lib/util.js +55 -0
- package/librdkafka.js +12 -0
- package/package.json +85 -0
- package/shim/source_location +54 -0
- package/src/admin.cc +1597 -0
- package/src/admin.h +112 -0
- package/src/binding.cc +76 -0
- package/src/binding.h +25 -0
- package/src/callbacks.cc +676 -0
- package/src/callbacks.h +302 -0
- package/src/common.cc +1628 -0
- package/src/common.h +192 -0
- package/src/config.cc +219 -0
- package/src/config.h +61 -0
- package/src/connection.cc +703 -0
- package/src/connection.h +117 -0
- package/src/errors.cc +119 -0
- package/src/errors.h +60 -0
- package/src/kafka-consumer.cc +1539 -0
- package/src/kafka-consumer.h +147 -0
- package/src/producer.cc +917 -0
- package/src/producer.h +124 -0
- package/src/topic.cc +173 -0
- package/src/topic.h +54 -0
- package/src/workers.cc +1714 -0
- package/src/workers.h +690 -0
- package/types/config.d.ts +1269 -0
- package/types/errors.d.ts +373 -0
- package/types/kafkajs.d.ts +568 -0
- package/types/rdkafka.d.ts +571 -0
- package/util/configure.js +32 -0
- package/util/generate-docs.sh +18 -0
- package/util/get-env.js +6 -0
- package/util/test-compile.js +11 -0
- package/util/test-producer-delivery.js +100 -0
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 Blizzard Entertainment
|
|
5
|
+
* (c) 2023 Confluent, Inc.
|
|
6
|
+
*
|
|
7
|
+
* This software may be modified and distributed under the terms
|
|
8
|
+
* of the MIT license. See the LICENSE.txt file for details.
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
module.exports = KafkaConsumer;
|
|
13
|
+
|
|
14
|
+
var Client = require('./client');
|
|
15
|
+
var util = require('util');
|
|
16
|
+
var Kafka = require('../librdkafka');
|
|
17
|
+
var KafkaConsumerStream = require('./kafka-consumer-stream');
|
|
18
|
+
var LibrdKafkaError = require('./error');
|
|
19
|
+
var TopicPartition = require('./topic-partition');
|
|
20
|
+
var shallowCopy = require('./util').shallowCopy;
|
|
21
|
+
var DEFAULT_CONSUME_LOOP_TIMEOUT_DELAY = 500;
|
|
22
|
+
var DEFAULT_CONSUME_TIME_OUT = 1000;
|
|
23
|
+
const DEFAULT_IS_TIMEOUT_ONLY_FOR_FIRST_MESSAGE = false;
|
|
24
|
+
util.inherits(KafkaConsumer, Client);
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* KafkaConsumer class for reading messages from Kafka.
|
|
28
|
+
*
|
|
29
|
+
* This is the main entry point for reading data from Kafka. You
|
|
30
|
+
* configure this like you do any other client, with a global
|
|
31
|
+
* configuration and default topic configuration.
|
|
32
|
+
*
|
|
33
|
+
* Data will not be read until you tell the consumer what topics
|
|
34
|
+
* you want to read from.
|
|
35
|
+
*
|
|
36
|
+
* Methods on a KafkaConsumer will throw a [LibrdKafkaError]{@link RdKafka.LibrdKafkaError}
|
|
37
|
+
* on failure.
|
|
38
|
+
*
|
|
39
|
+
* @param {object} conf - Key value pairs to configure the consumer.
|
|
40
|
+
* @param {object?} topicConf - Key value pairs to create a default topic configuration.
|
|
41
|
+
* @extends RdKafka.Client
|
|
42
|
+
* @memberof RdKafka
|
|
43
|
+
* @constructor
|
|
44
|
+
* @see [Consumer example]{@link https://github.com/confluentinc/confluent-kafka-javascript/blob/master/examples/node-rdkafka/consumer-flow.md}
|
|
45
|
+
*/
|
|
46
|
+
function KafkaConsumer(conf, topicConf) {
|
|
47
|
+
if (!(this instanceof KafkaConsumer)) {
|
|
48
|
+
return new KafkaConsumer(conf, topicConf);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
conf = shallowCopy(conf);
|
|
52
|
+
topicConf = shallowCopy(topicConf);
|
|
53
|
+
|
|
54
|
+
var onRebalance = conf.rebalance_cb;
|
|
55
|
+
|
|
56
|
+
var self = this;
|
|
57
|
+
|
|
58
|
+
// If rebalance is undefined we don't want any part of this
|
|
59
|
+
if (onRebalance && typeof onRebalance === 'boolean') {
|
|
60
|
+
conf.rebalance_cb = function(err, assignment) {
|
|
61
|
+
// Create the librdkafka error
|
|
62
|
+
err = LibrdKafkaError.create(err);
|
|
63
|
+
// Emit the event
|
|
64
|
+
self.emit('rebalance', err, assignment);
|
|
65
|
+
|
|
66
|
+
// That's it
|
|
67
|
+
try {
|
|
68
|
+
if (err.code === -175 /*ERR__ASSIGN_PARTITIONS*/) {
|
|
69
|
+
if (self.rebalanceProtocol() === 'COOPERATIVE') {
|
|
70
|
+
self.incrementalAssign(assignment);
|
|
71
|
+
} else {
|
|
72
|
+
self.assign(assignment);
|
|
73
|
+
}
|
|
74
|
+
} else if (err.code === -174 /*ERR__REVOKE_PARTITIONS*/) {
|
|
75
|
+
if (self.rebalanceProtocol() === 'COOPERATIVE') {
|
|
76
|
+
self.incrementalUnassign(assignment);
|
|
77
|
+
} else {
|
|
78
|
+
self.unassign();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
} catch (e) {
|
|
82
|
+
// Ignore exceptions if we are not connected
|
|
83
|
+
if (self.isConnected()) {
|
|
84
|
+
self.emit('rebalance.error', e);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
} else if (onRebalance && typeof onRebalance === 'function') {
|
|
89
|
+
/*
|
|
90
|
+
* Once this is opted in to, that's it. It's going to manually rebalance
|
|
91
|
+
* forever. There is no way to unset config values in librdkafka, just
|
|
92
|
+
* a way to override them.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
conf.rebalance_cb = function(err, assignment) {
|
|
96
|
+
// Create the librdkafka error
|
|
97
|
+
err = err ? LibrdKafkaError.create(err) : undefined;
|
|
98
|
+
|
|
99
|
+
self.emit('rebalance', err, assignment);
|
|
100
|
+
onRebalance.call(self, err, assignment);
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Same treatment for offset_commit_cb
|
|
105
|
+
var onOffsetCommit = conf.offset_commit_cb;
|
|
106
|
+
|
|
107
|
+
if (onOffsetCommit && typeof onOffsetCommit === 'boolean') {
|
|
108
|
+
conf.offset_commit_cb = function(err, offsets) {
|
|
109
|
+
if (err) {
|
|
110
|
+
err = LibrdKafkaError.create(err);
|
|
111
|
+
}
|
|
112
|
+
// Emit the event
|
|
113
|
+
self.emit('offset.commit', err, offsets);
|
|
114
|
+
};
|
|
115
|
+
} else if (onOffsetCommit && typeof onOffsetCommit === 'function') {
|
|
116
|
+
conf.offset_commit_cb = function(err, offsets) {
|
|
117
|
+
if (err) {
|
|
118
|
+
err = LibrdKafkaError.create(err);
|
|
119
|
+
}
|
|
120
|
+
// Emit the event
|
|
121
|
+
self.emit('offset.commit', err, offsets);
|
|
122
|
+
onOffsetCommit.call(self, err, offsets);
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Note: This configuration is for internal use for now, and hence is not documented, or
|
|
127
|
+
// exposed via types.
|
|
128
|
+
const queue_non_empty_cb = conf.queue_non_empty_cb || null;
|
|
129
|
+
delete conf.queue_non_empty_cb;
|
|
130
|
+
|
|
131
|
+
Client.call(this, conf, Kafka.KafkaConsumer, topicConf);
|
|
132
|
+
|
|
133
|
+
this.globalConfig = conf;
|
|
134
|
+
this.topicConfig = topicConf;
|
|
135
|
+
|
|
136
|
+
this._consumeTimeout = DEFAULT_CONSUME_TIME_OUT;
|
|
137
|
+
this._consumeLoopTimeoutDelay = DEFAULT_CONSUME_LOOP_TIMEOUT_DELAY;
|
|
138
|
+
this._consumeIsTimeoutOnlyForFirstMessage = DEFAULT_IS_TIMEOUT_ONLY_FOR_FIRST_MESSAGE;
|
|
139
|
+
|
|
140
|
+
if (queue_non_empty_cb) {
|
|
141
|
+
this._cb_configs.event.queue_non_empty_cb = queue_non_empty_cb;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Set the default consume timeout provided to C++land.
|
|
147
|
+
*
|
|
148
|
+
* @param {number} timeoutMs - number of milliseconds to wait for a message to be fetched.
|
|
149
|
+
*/
|
|
150
|
+
KafkaConsumer.prototype.setDefaultConsumeTimeout = function(timeoutMs) {
|
|
151
|
+
this._consumeTimeout = timeoutMs;
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Set the default sleep delay for the next consume loop after the previous one has timed out.
|
|
156
|
+
*
|
|
157
|
+
* @param {number} intervalMs - number of milliseconds to sleep after a message fetch has timed out.
|
|
158
|
+
*/
|
|
159
|
+
KafkaConsumer.prototype.setDefaultConsumeLoopTimeoutDelay = function(intervalMs) {
|
|
160
|
+
this._consumeLoopTimeoutDelay = intervalMs;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* If true:
|
|
165
|
+
* In consume(number, cb), we will wait for `timeoutMs` for the first message to be fetched.
|
|
166
|
+
* Subsequent messages will not be waited for and will be fetched (upto `number`) if already ready.
|
|
167
|
+
*
|
|
168
|
+
* If false:
|
|
169
|
+
* In consume(number, cb), we will wait for upto `timeoutMs` for each message to be fetched.
|
|
170
|
+
*
|
|
171
|
+
* @param {boolean} isTimeoutOnlyForFirstMessage
|
|
172
|
+
* @private
|
|
173
|
+
*/
|
|
174
|
+
KafkaConsumer.prototype.setDefaultIsTimeoutOnlyForFirstMessage = function(isTimeoutOnlyForFirstMessage) {
|
|
175
|
+
this._consumeIsTimeoutOnlyForFirstMessage = isTimeoutOnlyForFirstMessage;
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Get a stream representation of this KafkaConsumer.
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* var consumerStream = Kafka.KafkaConsumer.createReadStream({
|
|
183
|
+
* 'metadata.broker.list': 'localhost:9092',
|
|
184
|
+
* 'group.id': 'librd-test',
|
|
185
|
+
* 'socket.keepalive.enable': true,
|
|
186
|
+
* 'enable.auto.commit': false
|
|
187
|
+
* }, {}, { topics: [ 'test' ] });
|
|
188
|
+
*
|
|
189
|
+
* @param {object} conf - Key value pairs to configure the consumer.
|
|
190
|
+
* @param {object?} topicConf - Key value pairs to create a default topic configuration. May be null.
|
|
191
|
+
* @param {object} streamOptions - Stream options.
|
|
192
|
+
* @param {array} streamOptions.topics - Array of topics to subscribe to.
|
|
193
|
+
* @return {RdKafka.KafkaConsumerStream} - Readable stream that receives messages when new ones become available.
|
|
194
|
+
*/
|
|
195
|
+
KafkaConsumer.createReadStream = function(conf, topicConf, streamOptions) {
|
|
196
|
+
var consumer = new KafkaConsumer(conf, topicConf);
|
|
197
|
+
return new KafkaConsumerStream(consumer, streamOptions);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Get a current list of the committed offsets per topic partition.
|
|
202
|
+
*
|
|
203
|
+
* Calls back with array of objects in the form of a topic partition list.
|
|
204
|
+
*
|
|
205
|
+
* @param {TopicPartition[]?} toppars - Topic partition list to query committed
|
|
206
|
+
* offsets for. Defaults to the current assignment.
|
|
207
|
+
* @param {number} timeout - Number of ms to block before calling back
|
|
208
|
+
* and erroring.
|
|
209
|
+
* @param {function} cb - Callback method to execute when finished or timed out.
|
|
210
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
211
|
+
*/
|
|
212
|
+
KafkaConsumer.prototype.committed = function(toppars, timeout, cb) {
|
|
213
|
+
// We want to be backwards compatible here, and the previous version of
|
|
214
|
+
// this function took two arguments
|
|
215
|
+
|
|
216
|
+
// If CB is not set, shift to backwards compatible version
|
|
217
|
+
if (!cb) {
|
|
218
|
+
cb = arguments[1];
|
|
219
|
+
timeout = arguments[0];
|
|
220
|
+
toppars = this.assignments();
|
|
221
|
+
} else {
|
|
222
|
+
toppars = toppars || this.assignments();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
this._client.committed(toppars, timeout, function(err, topicPartitions) {
|
|
226
|
+
if (err) {
|
|
227
|
+
cb(LibrdKafkaError.create(err));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
cb(null, topicPartitions);
|
|
232
|
+
});
|
|
233
|
+
return this;
|
|
234
|
+
};
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Seek consumer for topic+partition to offset which is either an absolute or
|
|
238
|
+
* logical offset.
|
|
239
|
+
*
|
|
240
|
+
* The consumer must have previously been assigned to topics and partitions that
|
|
241
|
+
* are being seeked to in the call.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* consumer.seek({ topic: 'topic', partition: 0, offset: 1000 }, 2000, function(err) {
|
|
245
|
+
* if (err) {
|
|
246
|
+
*
|
|
247
|
+
* }
|
|
248
|
+
* });
|
|
249
|
+
*
|
|
250
|
+
* @param {TopicPartition} toppar - Topic partition to seek, including offset.
|
|
251
|
+
* @param {number} timeout - Number of ms to try seeking before erroring out.
|
|
252
|
+
* @param {function} cb - Callback method to execute when finished or timed
|
|
253
|
+
* out. If the seek timed out, the internal state of the
|
|
254
|
+
* consumer is unknown.
|
|
255
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
256
|
+
*/
|
|
257
|
+
KafkaConsumer.prototype.seek = function(toppar, timeout, cb) {
|
|
258
|
+
this._client.seek(TopicPartition.create(toppar), timeout, function(err) {
|
|
259
|
+
if (err) {
|
|
260
|
+
cb(LibrdKafkaError.create(err));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
cb();
|
|
265
|
+
});
|
|
266
|
+
return this;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
* Assign the consumer specific partitions and topics. Used for
|
|
271
|
+
* eager (non-cooperative) rebalancing from within the rebalance callback.
|
|
272
|
+
*
|
|
273
|
+
* @param {array} assignments - Assignments array. Should contain
|
|
274
|
+
* objects with topic and partition set.
|
|
275
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
276
|
+
* @see RdKafka.KafkaConsumer#incrementalAssign
|
|
277
|
+
*/
|
|
278
|
+
KafkaConsumer.prototype.assign = function(assignments) {
|
|
279
|
+
this._client.assign(TopicPartition.map(assignments));
|
|
280
|
+
return this;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Unassign the consumer from its assigned partitions and topics. Used for
|
|
285
|
+
* eager (non-cooperative) rebalancing from within the rebalance callback.
|
|
286
|
+
*
|
|
287
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
288
|
+
* @see RdKafka.KafkaConsumer#incrementalUnassign
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
KafkaConsumer.prototype.unassign = function() {
|
|
292
|
+
this._client.unassign();
|
|
293
|
+
return this;
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* Assign the consumer specific partitions and topics. Used for
|
|
298
|
+
* cooperative rebalancing from within the rebalance callback.
|
|
299
|
+
*
|
|
300
|
+
* @param {array} assignments - Assignments array. Should contain
|
|
301
|
+
* objects with topic and partition set. Assignments are additive.
|
|
302
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
303
|
+
* @see RdKafka.KafkaConsumer#assign
|
|
304
|
+
*/
|
|
305
|
+
KafkaConsumer.prototype.incrementalAssign = function(assignments) {
|
|
306
|
+
this._client.incrementalAssign(TopicPartition.map(assignments));
|
|
307
|
+
return this;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* Unassign the consumer specific partitions and topics. Used for
|
|
312
|
+
* cooperative rebalancing from within the rebalance callback.
|
|
313
|
+
*
|
|
314
|
+
* @param {array} assignments - Assignments array. Should contain
|
|
315
|
+
* objects with topic and partition set. Assignments are subtractive.
|
|
316
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
317
|
+
* @see RdKafka.KafkaConsumer#unassign
|
|
318
|
+
*/
|
|
319
|
+
KafkaConsumer.prototype.incrementalUnassign = function(assignments) {
|
|
320
|
+
this._client.incrementalUnassign(TopicPartition.map(assignments));
|
|
321
|
+
return this;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Get the assignments for the consumer.
|
|
326
|
+
*
|
|
327
|
+
* @return {array} assignments - Array of topic partitions.
|
|
328
|
+
*/
|
|
329
|
+
KafkaConsumer.prototype.assignments = function() {
|
|
330
|
+
return this._errorWrap(this._client.assignments(), true);
|
|
331
|
+
};
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* Is current assignment in rebalance callback lost?
|
|
335
|
+
*
|
|
336
|
+
* @note This method should only be called from within the rebalance callback
|
|
337
|
+
* when partitions are revoked.
|
|
338
|
+
*
|
|
339
|
+
* @return {boolean} true if assignment was lost.
|
|
340
|
+
*/
|
|
341
|
+
|
|
342
|
+
KafkaConsumer.prototype.assignmentLost = function() {
|
|
343
|
+
return this._client.assignmentLost();
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Get the type of rebalance protocol used in the consumer group.
|
|
348
|
+
*
|
|
349
|
+
* @returns {string} "NONE" (if not in a group yet), "COOPERATIVE" or "EAGER".
|
|
350
|
+
*/
|
|
351
|
+
KafkaConsumer.prototype.rebalanceProtocol = function() {
|
|
352
|
+
return this._client.rebalanceProtocol();
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Subscribe to an array of topics (synchronously).
|
|
357
|
+
*
|
|
358
|
+
* This operation is pretty fast because it just sets
|
|
359
|
+
* an assignment in librdkafka. This is the recommended
|
|
360
|
+
* way to deal with subscriptions in a situation where you
|
|
361
|
+
* will be reading across multiple files or as part of
|
|
362
|
+
* your configure-time initialization.
|
|
363
|
+
*
|
|
364
|
+
* This is also a good way to do it for streams.
|
|
365
|
+
*
|
|
366
|
+
* This does not actually cause any reassignment of topic partitions until
|
|
367
|
+
* the consume loop is running or the consume method is called.
|
|
368
|
+
*
|
|
369
|
+
* @param {array} topics - An array of topics to listen to.
|
|
370
|
+
* @fires RdKafka.KafkaConsumer#subscribed
|
|
371
|
+
* @return {KafkaConsumer} - Returns itself.
|
|
372
|
+
*/
|
|
373
|
+
KafkaConsumer.prototype.subscribe = function(topics) {
|
|
374
|
+
// Will throw if it is a bad error.
|
|
375
|
+
this._errorWrap(this._client.subscribe(topics));
|
|
376
|
+
/**
|
|
377
|
+
* Subscribe event. Called efter changing subscription.
|
|
378
|
+
*
|
|
379
|
+
* @event RdKafka.KafkaConsumer#subscribed
|
|
380
|
+
* @type {Array<string>}
|
|
381
|
+
*/
|
|
382
|
+
this.emit('subscribed', topics);
|
|
383
|
+
return this;
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Get the current subscription of the KafkaConsumer.
|
|
388
|
+
*
|
|
389
|
+
* Get a list of subscribed topics. Should generally match what you
|
|
390
|
+
* passed on via subscribe.
|
|
391
|
+
*
|
|
392
|
+
* @see RdKafka.KafkaConsumer#subscribe
|
|
393
|
+
* @return {array} - Array of topic string to show the current subscription.
|
|
394
|
+
*/
|
|
395
|
+
KafkaConsumer.prototype.subscription = function() {
|
|
396
|
+
return this._errorWrap(this._client.subscription(), true);
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Get the current offset position of the KafkaConsumer.
|
|
401
|
+
*
|
|
402
|
+
* Returns a list of TopicPartitions on success, or throws
|
|
403
|
+
* an error on failure.
|
|
404
|
+
*
|
|
405
|
+
* @param {TopicPartition[]} toppars - List of topic partitions to query
|
|
406
|
+
* position for. Defaults to the current assignment.
|
|
407
|
+
* @return {array} - TopicPartition array. Each item is an object with
|
|
408
|
+
* an offset, topic, and partition.
|
|
409
|
+
*/
|
|
410
|
+
KafkaConsumer.prototype.position = function(toppars) {
|
|
411
|
+
if (!toppars) {
|
|
412
|
+
toppars = this.assignments();
|
|
413
|
+
}
|
|
414
|
+
return this._errorWrap(this._client.position(toppars), true);
|
|
415
|
+
};
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Unsubscribe from all currently subscribed topics.
|
|
419
|
+
*
|
|
420
|
+
* Before you subscribe to new topics you need to unsubscribe
|
|
421
|
+
* from the old ones, if there is an active subscription.
|
|
422
|
+
* Otherwise, you will get an error because there is an
|
|
423
|
+
* existing subscription.
|
|
424
|
+
*
|
|
425
|
+
* @return {RdKafka.KafkaConsumer} - Returns itself.
|
|
426
|
+
*/
|
|
427
|
+
KafkaConsumer.prototype.unsubscribe = function() {
|
|
428
|
+
this._errorWrap(this._client.unsubscribe());
|
|
429
|
+
this.emit('unsubscribed', []);
|
|
430
|
+
// Backwards compatible change
|
|
431
|
+
this.emit('unsubscribe', []);
|
|
432
|
+
return this;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Consume messages from the subscribed topics.
|
|
437
|
+
*
|
|
438
|
+
* This method can be used in two ways.
|
|
439
|
+
*
|
|
440
|
+
* 1. To read messages as fast as possible.
|
|
441
|
+
* A background thread is created to fetch the messages as quickly as it can,
|
|
442
|
+
* sleeping only in between EOF and broker timeouts.
|
|
443
|
+
* If called in this way, the method returns immediately. Messages will be
|
|
444
|
+
* sent via an optional callback that can be provided to the method, and via
|
|
445
|
+
* the [data]{@link RdKafka.KafkaConsumer#data} event.
|
|
446
|
+
*
|
|
447
|
+
* 2. To read a certain number of messages.
|
|
448
|
+
* If the first argument provided is a number, this method reads multiple
|
|
449
|
+
* messages, the count of which doesn't exceed the number. No additional thread
|
|
450
|
+
* is created.
|
|
451
|
+
*
|
|
452
|
+
* Configuring timeouts for consume:
|
|
453
|
+
*
|
|
454
|
+
* 1. [setDefaultConsumeTimeout]{@link RdKafka.KafkaConsumer#setDefaultConsumeTimeout} -
|
|
455
|
+
* This is the time we wait for a message to be fetched from the underlying library.
|
|
456
|
+
* If this is exceeded, we either backoff for a while (Way 1), or return with however
|
|
457
|
+
* many messages we've already fetched by that point (Way 2).
|
|
458
|
+
*
|
|
459
|
+
* 2. [setDefaultConsumeLoopTimeoutDelay]{@link RdKafka.KafkaConsumer#setDefaultConsumeLoopTimeoutDelay} -
|
|
460
|
+
* This is the time we wait before attempting another fetch after a message fetch has timed out.
|
|
461
|
+
* This is only used in Way 1.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* // Way 1:
|
|
465
|
+
* consumer.consume(); // No callback is okay.
|
|
466
|
+
* consumer.consume(processMessage); // Messages will be send to the callback.
|
|
467
|
+
*
|
|
468
|
+
* // Way 2:
|
|
469
|
+
* consumer.consume(10); // First parameter must be number of messages.
|
|
470
|
+
* consumer.consume(10, processMessage); // Callback can be given as the second parameter.
|
|
471
|
+
*
|
|
472
|
+
* @param {number|function|null} sizeOrCb - Either the number of messages to
|
|
473
|
+
* read (if using in second way, or the
|
|
474
|
+
* callback) if using the first way.
|
|
475
|
+
* @param {RdKafka.KafkaConsumer~readCallback?} cb - Callback to return when work is done, if using second way.
|
|
476
|
+
*/
|
|
477
|
+
KafkaConsumer.prototype.consume = function(number, cb) {
|
|
478
|
+
var timeoutMs = this._consumeTimeout !== undefined ? this._consumeTimeout : DEFAULT_CONSUME_TIME_OUT;
|
|
479
|
+
|
|
480
|
+
if ((number && typeof number === 'number') || (number && cb)) {
|
|
481
|
+
|
|
482
|
+
if (cb === undefined) {
|
|
483
|
+
cb = function() {};
|
|
484
|
+
} else if (typeof cb !== 'function') {
|
|
485
|
+
throw new TypeError('Callback must be a function');
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
this._consumeNum(timeoutMs, number, cb);
|
|
489
|
+
} else {
|
|
490
|
+
|
|
491
|
+
// See https://github.com/confluentinc/confluent-kafka-javascript/issues/220
|
|
492
|
+
// Docs specify just a callback can be provided but really we needed
|
|
493
|
+
// a fallback to the number argument
|
|
494
|
+
// @deprecated
|
|
495
|
+
if (cb === undefined) {
|
|
496
|
+
if (typeof number === 'function') {
|
|
497
|
+
cb = number;
|
|
498
|
+
} else {
|
|
499
|
+
cb = function() {};
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
this._consumeLoop(timeoutMs, cb);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
|
|
507
|
+
/**
|
|
508
|
+
* Open a background thread and keep getting messages as fast
|
|
509
|
+
* as we can. Should not be called directly, and instead should
|
|
510
|
+
* be called using consume.
|
|
511
|
+
*
|
|
512
|
+
* @private
|
|
513
|
+
* @see consume
|
|
514
|
+
*/
|
|
515
|
+
KafkaConsumer.prototype._consumeLoop = function(timeoutMs, cb) {
|
|
516
|
+
var self = this;
|
|
517
|
+
var retryReadInterval = this._consumeLoopTimeoutDelay;
|
|
518
|
+
self._client.consumeLoop(timeoutMs, retryReadInterval, function readCallback(err, message, eofEvent, warning) {
|
|
519
|
+
|
|
520
|
+
if (err) {
|
|
521
|
+
// A few different types of errors here
|
|
522
|
+
// but the two we do NOT care about are
|
|
523
|
+
// time outs at least now
|
|
524
|
+
// Broker no more messages will also not come here
|
|
525
|
+
cb(LibrdKafkaError.create(err));
|
|
526
|
+
} else if (eofEvent) {
|
|
527
|
+
self.emit('partition.eof', eofEvent);
|
|
528
|
+
} else if (warning) {
|
|
529
|
+
self.emit('warning', LibrdKafkaError.create(warning));
|
|
530
|
+
} else {
|
|
531
|
+
/**
|
|
532
|
+
* Data event. called whenever a message is received.
|
|
533
|
+
*
|
|
534
|
+
* @event RdKafka.KafkaConsumer#data
|
|
535
|
+
* @type {RdKafka.KafkaConsumer~Message}
|
|
536
|
+
*/
|
|
537
|
+
self.emit('data', message);
|
|
538
|
+
cb(err, message);
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
/**
|
|
545
|
+
* Consume a number of messages and wrap in a try catch with
|
|
546
|
+
* proper error reporting. Should not be called directly,
|
|
547
|
+
* and instead should be called using consume.
|
|
548
|
+
*
|
|
549
|
+
* @private
|
|
550
|
+
* @see consume
|
|
551
|
+
*/
|
|
552
|
+
KafkaConsumer.prototype._consumeNum = function(timeoutMs, numMessages, cb) {
|
|
553
|
+
var self = this;
|
|
554
|
+
|
|
555
|
+
this._client.consume(timeoutMs, numMessages, this._consumeIsTimeoutOnlyForFirstMessage, function(err, messages, eofEvents) {
|
|
556
|
+
if (err) {
|
|
557
|
+
err = LibrdKafkaError.create(err);
|
|
558
|
+
if (cb) {
|
|
559
|
+
cb(err);
|
|
560
|
+
}
|
|
561
|
+
return;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
var currentEofEventsIndex = 0;
|
|
565
|
+
|
|
566
|
+
function emitEofEventsFor(messageIndex) {
|
|
567
|
+
while (currentEofEventsIndex < eofEvents.length && eofEvents[currentEofEventsIndex].messageIndex === messageIndex) {
|
|
568
|
+
delete eofEvents[currentEofEventsIndex].messageIndex;
|
|
569
|
+
self.emit('partition.eof', eofEvents[currentEofEventsIndex]);
|
|
570
|
+
++currentEofEventsIndex;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
emitEofEventsFor(-1);
|
|
575
|
+
|
|
576
|
+
for (var i = 0; i < messages.length; i++) {
|
|
577
|
+
self.emit('data', messages[i]);
|
|
578
|
+
emitEofEventsFor(i);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
emitEofEventsFor(messages.length);
|
|
582
|
+
|
|
583
|
+
if (cb) {
|
|
584
|
+
cb(null, messages);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* This callback returns the message read from Kafka.
|
|
593
|
+
*
|
|
594
|
+
* @callback KafkaConsumer~readCallback
|
|
595
|
+
* @param {LibrdKafkaError} err - An error, if one occurred while reading
|
|
596
|
+
* the data.
|
|
597
|
+
* @param {KafkaConsumer~Message} message
|
|
598
|
+
*/
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* Commit specific topic partitions, or all the topic partitions that have been read.
|
|
602
|
+
*
|
|
603
|
+
* This is asynchronous, and when this method returns, it's not guaranteed that the
|
|
604
|
+
* offsets have been committed. If you need that, use
|
|
605
|
+
* [commitSync]{@link RdKafka.KafkaConsumer#commitSync} or
|
|
606
|
+
* [commitCb]{@link RdKafka.KafkaConsumer#commitCb}.
|
|
607
|
+
*
|
|
608
|
+
* If you provide a topic partition, or an array of topic parrtitins, it will commit those.
|
|
609
|
+
* Otherwise, it will commit all read offsets for all topic partitions.
|
|
610
|
+
*
|
|
611
|
+
* @param {object|array|null} - Topic partition object to commit, list of topic
|
|
612
|
+
* partitions, or null if you want to commit all read offsets.
|
|
613
|
+
* @return {RdKafka.KafkaConsumer} - returns itself.
|
|
614
|
+
*/
|
|
615
|
+
KafkaConsumer.prototype.commit = function(topicPartition) {
|
|
616
|
+
this._errorWrap(this._client.commit(topicPartition), true);
|
|
617
|
+
return this;
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Commit a message.
|
|
622
|
+
*
|
|
623
|
+
* This is a convenience method to map commit properly. The offset of the message + 1 is committed
|
|
624
|
+
* for the topic partition where the message comes from.
|
|
625
|
+
*
|
|
626
|
+
* @param {object} - Message object to commit.
|
|
627
|
+
*
|
|
628
|
+
* @return {RdKafka.KafkaConsumer} - returns itself.
|
|
629
|
+
*/
|
|
630
|
+
KafkaConsumer.prototype.commitMessage = function(msg) {
|
|
631
|
+
var topicPartition = {
|
|
632
|
+
topic: msg.topic,
|
|
633
|
+
partition: msg.partition,
|
|
634
|
+
offset: msg.offset + 1,
|
|
635
|
+
leaderEpoch: msg.leaderEpoch
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
this._errorWrap(this._client.commit(topicPartition), true);
|
|
639
|
+
return this;
|
|
640
|
+
};
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Commit a topic partition (or all topic partitions) synchronously.
|
|
644
|
+
*
|
|
645
|
+
* @param {object|array|null} - Topic partition object to commit, list of topic
|
|
646
|
+
* partitions, or null if you want to commit all read offsets.
|
|
647
|
+
* @return {RdKafka.KafkaConsumer} - returns itself.
|
|
648
|
+
*/
|
|
649
|
+
KafkaConsumer.prototype.commitSync = function(topicPartition) {
|
|
650
|
+
this._errorWrap(this._client.commitSync(topicPartition), true);
|
|
651
|
+
return this;
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* Commit a message synchronously.
|
|
656
|
+
*
|
|
657
|
+
* @see RdKafka.KafkaConsumer#commitMessageSync
|
|
658
|
+
* @param {object} msg - A message object to commit.
|
|
659
|
+
* @return {RdKafka.KafkaConsumer} - returns itself.
|
|
660
|
+
*/
|
|
661
|
+
KafkaConsumer.prototype.commitMessageSync = function(msg) {
|
|
662
|
+
var topicPartition = {
|
|
663
|
+
topic: msg.topic,
|
|
664
|
+
partition: msg.partition,
|
|
665
|
+
offset: msg.offset + 1,
|
|
666
|
+
leaderEpoch: msg.leaderEpoch,
|
|
667
|
+
};
|
|
668
|
+
|
|
669
|
+
this._errorWrap(this._client.commitSync(topicPartition), true);
|
|
670
|
+
return this;
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Commits a list of offsets per topic partition, using provided callback.
|
|
675
|
+
*
|
|
676
|
+
* @param {TopicPartition[]} toppars - Topic partition list to commit
|
|
677
|
+
* offsets for. Defaults to the current assignment.
|
|
678
|
+
* @param {function} cb - Callback method to execute when finished.
|
|
679
|
+
* @return {RdKafka.KafkaConsumer} - returns itself.
|
|
680
|
+
*/
|
|
681
|
+
KafkaConsumer.prototype.commitCb = function(toppars, cb) {
|
|
682
|
+
this._client.commitCb(toppars, function(err) {
|
|
683
|
+
if (err) {
|
|
684
|
+
cb(LibrdKafkaError.create(err));
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
cb(null);
|
|
689
|
+
});
|
|
690
|
+
return this;
|
|
691
|
+
};
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* Get last known offsets from the client.
|
|
695
|
+
*
|
|
696
|
+
* The low offset is updated periodically (if statistics.interval.ms is set)
|
|
697
|
+
* while the high offset is updated on each fetched message set from the
|
|
698
|
+
* broker.
|
|
699
|
+
*
|
|
700
|
+
* If there is no cached offset (either low or high, or both), then this will
|
|
701
|
+
* throw an error.
|
|
702
|
+
*
|
|
703
|
+
* @param {string} topic - Topic to recieve offsets from.
|
|
704
|
+
* @param {number} partition - Partition of the provided topic to recieve offsets from.
|
|
705
|
+
* @return {RdKafka.Client~watermarkOffsets} - Returns an object with a high and low property, specifying
|
|
706
|
+
* the high and low offsets for the topic partition.
|
|
707
|
+
*/
|
|
708
|
+
KafkaConsumer.prototype.getWatermarkOffsets = function(topic, partition) {
|
|
709
|
+
if (!this.isConnected()) {
|
|
710
|
+
throw new Error('Client is disconnected');
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
return this._errorWrap(this._client.getWatermarkOffsets(topic, partition), true);
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* Store offset for topic partition.
|
|
718
|
+
*
|
|
719
|
+
* The offset will be committed (written) to the offset store according to the auto commit interval,
|
|
720
|
+
* if auto commit is on, or next manual offset if not.
|
|
721
|
+
*
|
|
722
|
+
* enable.auto.offset.store must be set to false to use this API.
|
|
723
|
+
*
|
|
724
|
+
* @see {@link https://github.com/confluentinc/librdkafka/blob/261371dc0edef4cea9e58a076c8e8aa7dc50d452/src-cpp/rdkafkacpp.h#L1702}
|
|
725
|
+
*
|
|
726
|
+
* @param {Array.<TopicPartition>} topicPartitions - Topic partitions with offsets to store offsets for.
|
|
727
|
+
*/
|
|
728
|
+
KafkaConsumer.prototype.offsetsStore = function(topicPartitions) {
|
|
729
|
+
if (!this.isConnected()) {
|
|
730
|
+
throw new Error('Client is disconnected');
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
return this._errorWrap(this._client.offsetsStore(topicPartitions), true);
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* Store offset for a single topic partition. Do not use this method.
|
|
738
|
+
* This method is meant for internal use, and the API is not guaranteed to be stable.
|
|
739
|
+
* Use offsetsStore instead.
|
|
740
|
+
*
|
|
741
|
+
* @param {string} topic - Topic to store offset for.
|
|
742
|
+
* @param {number} partition - Partition of the provided topic to store offset for.
|
|
743
|
+
* @param {number} offset - Offset to store.
|
|
744
|
+
* @param {number} leaderEpoch - Leader epoch of the provided offset.
|
|
745
|
+
* @private
|
|
746
|
+
*/
|
|
747
|
+
KafkaConsumer.prototype._offsetsStoreSingle = function(topic, partition, offset, leaderEpoch) {
|
|
748
|
+
if (!this.isConnected()) {
|
|
749
|
+
throw new Error('Client is disconnected');
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
return this._errorWrap(
|
|
753
|
+
this._client.offsetsStoreSingle(topic, partition, offset, leaderEpoch), true);
|
|
754
|
+
};
|
|
755
|
+
|
|
756
|
+
/**
|
|
757
|
+
* Resume consumption for the provided list of partitions.
|
|
758
|
+
*
|
|
759
|
+
* @param {Array.<TopicPartition>} topicPartitions - List of topic partitions to resume consumption on.
|
|
760
|
+
*/
|
|
761
|
+
KafkaConsumer.prototype.resume = function(topicPartitions) {
|
|
762
|
+
if (!this.isConnected()) {
|
|
763
|
+
throw new Error('Client is disconnected');
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
return this._errorWrap(this._client.resume(topicPartitions), true);
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Pause consumption for the provided list of partitions.
|
|
771
|
+
*
|
|
772
|
+
* @param {Array.<TopicPartition>} topicPartitions - List of topics to pause consumption on.
|
|
773
|
+
*/
|
|
774
|
+
KafkaConsumer.prototype.pause = function(topicPartitions) {
|
|
775
|
+
if (!this.isConnected()) {
|
|
776
|
+
throw new Error('Client is disconnected');
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
return this._errorWrap(this._client.pause(topicPartitions), true);
|
|
780
|
+
};
|
|
781
|
+
|
|
782
|
+
/**
|
|
783
|
+
* @typedef {object} RdKafka.KafkaConsumer~MessageHeader
|
|
784
|
+
* The key of this object denotes the header key, and the value of the key is the header value.
|
|
785
|
+
*/
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* @typedef {object} RdKafka.KafkaConsumer~Message
|
|
789
|
+
* @property {string} topic - The topic the message was read from.
|
|
790
|
+
* @property {number} partition - The partition the message was read from.
|
|
791
|
+
* @property {number} offset - The offset of the message.
|
|
792
|
+
* @property {Buffer?} key - The key of the message.
|
|
793
|
+
* @property {Buffer?} value - The value of the message.
|
|
794
|
+
* @property {number} size - The size of the message.
|
|
795
|
+
* @property {number} timestamp - The timestamp of the message (in milliseconds since the epoch in UTC).
|
|
796
|
+
* @property {number?} leaderEpoch - The leader epoch of the message if available.
|
|
797
|
+
* @property {RdKafka.KafkaConsumer~MessageHeader[]?} headers - The headers of the message.
|
|
798
|
+
*/
|