@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
package/lib/producer.js
ADDED
|
@@ -0,0 +1,405 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 Blizzard Entertainment
|
|
5
|
+
* (c) 2024 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
|
+
|
|
11
|
+
module.exports = Producer;
|
|
12
|
+
|
|
13
|
+
var Client = require('./client');
|
|
14
|
+
|
|
15
|
+
var util = require('util');
|
|
16
|
+
var Kafka = require('../librdkafka.js');
|
|
17
|
+
var ProducerStream = require('./producer-stream');
|
|
18
|
+
var LibrdKafkaError = require('./error');
|
|
19
|
+
var shallowCopy = require('./util').shallowCopy;
|
|
20
|
+
|
|
21
|
+
util.inherits(Producer, Client);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Producer class for sending messages to Kafka
|
|
25
|
+
*
|
|
26
|
+
* This is the main entry point for writing data to Kafka. You
|
|
27
|
+
* configure this like you do any other client, with a global
|
|
28
|
+
* configuration and default topic configuration.
|
|
29
|
+
*
|
|
30
|
+
* Once you instantiate this object, you need to connect to it first.
|
|
31
|
+
* This allows you to get the metadata and make sure the connection
|
|
32
|
+
* can be made before you depend on it. After that, problems with
|
|
33
|
+
* the connection will by brought down by using poll, which automatically
|
|
34
|
+
* runs when a transaction is made on the object.
|
|
35
|
+
*
|
|
36
|
+
* Methods on a Producer will throw a [LibrdKafkaError]{@link RdKafka.LibrdKafkaError}
|
|
37
|
+
* on failure.
|
|
38
|
+
*
|
|
39
|
+
* @param {object} conf - Key value pairs to configure the producer
|
|
40
|
+
* @param {object?} topicConf - Key value pairs to create a default
|
|
41
|
+
* topic configuration
|
|
42
|
+
* @extends RdKafka.Client
|
|
43
|
+
* @constructor
|
|
44
|
+
* @memberof RdKafka
|
|
45
|
+
* @see [Producer example]{@link https://github.com/confluentinc/confluent-kafka-javascript/blob/master/examples/node-rdkafka/producer.md}
|
|
46
|
+
*/
|
|
47
|
+
function Producer(conf, topicConf) {
|
|
48
|
+
if (!(this instanceof Producer)) {
|
|
49
|
+
return new Producer(conf, topicConf);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
conf = shallowCopy(conf);
|
|
53
|
+
topicConf = shallowCopy(topicConf);
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Producer message. This is sent to the wrapper, not received from it
|
|
57
|
+
*
|
|
58
|
+
* @typedef {object} Producer~Message
|
|
59
|
+
* @property {string|buffer} message - The buffer to send to Kafka.
|
|
60
|
+
* @property {Topic} topic - The Kafka topic to produce to.
|
|
61
|
+
* @property {number} partition - The partition to produce to. Defaults to
|
|
62
|
+
* the partitioner
|
|
63
|
+
* @property {string} key - The key string to use for the message.
|
|
64
|
+
* @see Consumer~Message
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
var gTopic = conf.topic || false;
|
|
68
|
+
var gPart = conf.partition || null;
|
|
69
|
+
var dr_cb = conf.dr_cb || null;
|
|
70
|
+
var dr_msg_cb = conf.dr_msg_cb || null;
|
|
71
|
+
|
|
72
|
+
// delete keys we don't want to pass on
|
|
73
|
+
delete conf.topic;
|
|
74
|
+
delete conf.partition;
|
|
75
|
+
|
|
76
|
+
delete conf.dr_cb;
|
|
77
|
+
delete conf.dr_msg_cb;
|
|
78
|
+
|
|
79
|
+
// client is an initialized producer object
|
|
80
|
+
// @see NodeKafka::Producer::Init
|
|
81
|
+
Client.call(this, conf, Kafka.Producer, topicConf);
|
|
82
|
+
|
|
83
|
+
// Delete these keys after saving them in vars
|
|
84
|
+
this.globalConfig = conf;
|
|
85
|
+
this.topicConfig = topicConf;
|
|
86
|
+
this.defaultTopic = gTopic || null;
|
|
87
|
+
this.defaultPartition = gPart === null ? -1 : gPart;
|
|
88
|
+
|
|
89
|
+
this.sentMessages = 0;
|
|
90
|
+
|
|
91
|
+
this.pollInterval = undefined;
|
|
92
|
+
|
|
93
|
+
if (dr_msg_cb || dr_cb) {
|
|
94
|
+
this._cb_configs.event.delivery_cb = function(err, report) {
|
|
95
|
+
if (err) {
|
|
96
|
+
err = LibrdKafkaError.create(err);
|
|
97
|
+
}
|
|
98
|
+
this.emit('delivery-report', err, report);
|
|
99
|
+
}.bind(this);
|
|
100
|
+
this._cb_configs.event.delivery_cb.dr_msg_cb = !!dr_msg_cb;
|
|
101
|
+
|
|
102
|
+
if (typeof dr_cb === 'function') {
|
|
103
|
+
this.on('delivery-report', dr_cb);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Produce a message to Kafka asynchronously.
|
|
111
|
+
*
|
|
112
|
+
* This is the method mainly used in this class. Use it to produce
|
|
113
|
+
* a message to Kafka.
|
|
114
|
+
*
|
|
115
|
+
* When this is sent off, there is no guarantee it is delivered, as the method
|
|
116
|
+
* returns immediately after queuing the message in the library.
|
|
117
|
+
*
|
|
118
|
+
* If you need guaranteed delivery, change your `acks` settings and use delivery reports.
|
|
119
|
+
*
|
|
120
|
+
* @param {string} topic - The topic name to produce to.
|
|
121
|
+
* @param {number|null} partition - The partition number to produce to.
|
|
122
|
+
* @param {Buffer|null} message - The message to produce.
|
|
123
|
+
* @param {string} key - The key associated with the message.
|
|
124
|
+
* @param {number|null} timestamp - Timestamp to send with the message.
|
|
125
|
+
* @param {object} opaque - An object you want passed along with this message, if provided.
|
|
126
|
+
* This will be available in the delivery report
|
|
127
|
+
* @param {object} headers - A list of custom key value pairs that provide message metadata.
|
|
128
|
+
* @return {boolean} - throws an error if it failed, or returns true if not.
|
|
129
|
+
*/
|
|
130
|
+
Producer.prototype.produce = function(topic, partition, message, key, timestamp, opaque, headers) {
|
|
131
|
+
if (!this._isConnected) {
|
|
132
|
+
throw new Error('Producer not connected');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// I have removed support for using a topic object. It is going to be removed
|
|
136
|
+
// from librdkafka soon, and it causes issues with shutting down
|
|
137
|
+
if (!topic || typeof topic !== 'string') {
|
|
138
|
+
throw new TypeError('"topic" must be a string');
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
this.sentMessages++;
|
|
142
|
+
|
|
143
|
+
partition = partition === null ? this.defaultPartition : partition;
|
|
144
|
+
|
|
145
|
+
return this._errorWrap(
|
|
146
|
+
this._client.produce(topic, partition, message, key, timestamp, opaque, headers));
|
|
147
|
+
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Create a write stream interface for a producer.
|
|
152
|
+
*
|
|
153
|
+
* This stream does not run in object mode. It only takes buffers of data.
|
|
154
|
+
*
|
|
155
|
+
* @param {object} conf - Key value pairs to configure the producer.
|
|
156
|
+
* @param {object} topicConf - Key value pairs to create a default topic configuration.
|
|
157
|
+
* @param {object} streamOptions - Stream options.
|
|
158
|
+
* @return {RdKafka.ProducerStream} - returns the write stream for writing to Kafka.
|
|
159
|
+
*/
|
|
160
|
+
Producer.createWriteStream = function(conf, topicConf, streamOptions) {
|
|
161
|
+
var producer = new Producer(conf, topicConf);
|
|
162
|
+
return new ProducerStream(producer, streamOptions);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Poll for events.
|
|
167
|
+
*
|
|
168
|
+
* We need to run poll in order to learn about new events that have occurred.
|
|
169
|
+
* This is not done automatically when we produce, so we need to run
|
|
170
|
+
* it manually, or set the producer to automatically poll using
|
|
171
|
+
* {@link RdKafka.Producer#setPollInterval} or {@link RdKafka.Producer#setPollInBackground}.
|
|
172
|
+
*
|
|
173
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
174
|
+
*/
|
|
175
|
+
Producer.prototype.poll = function() {
|
|
176
|
+
if (!this._isConnected) {
|
|
177
|
+
throw new Error('Producer not connected');
|
|
178
|
+
}
|
|
179
|
+
this._client.poll();
|
|
180
|
+
return this;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Set automatic polling for events.
|
|
185
|
+
*
|
|
186
|
+
* We need to run poll in order to learn about new events that have occurred.
|
|
187
|
+
* If you would like this done on an interval with disconnects and reconnections
|
|
188
|
+
* managed, you can do it here.
|
|
189
|
+
*
|
|
190
|
+
* @param {number} interval - Interval, in milliseconds, to poll for.
|
|
191
|
+
*
|
|
192
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
193
|
+
*/
|
|
194
|
+
Producer.prototype.setPollInterval = function(interval) {
|
|
195
|
+
// If we already have a poll interval we need to stop it
|
|
196
|
+
if (this.pollInterval) {
|
|
197
|
+
clearInterval(this.pollInterval);
|
|
198
|
+
this.pollInterval = undefined;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (interval === 0) {
|
|
202
|
+
// If the interval was set to 0, bail out. We don't want to process this.
|
|
203
|
+
// If there was an interval previously set, it has been removed.
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
var self = this;
|
|
208
|
+
|
|
209
|
+
// Now we want to make sure we are connected.
|
|
210
|
+
if (!this._isConnected) {
|
|
211
|
+
// If we are not, execute this once the connection goes through.
|
|
212
|
+
this.once('ready', function() {
|
|
213
|
+
self.setPollInterval(interval);
|
|
214
|
+
});
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// We know we are connected at this point.
|
|
219
|
+
// Unref this interval
|
|
220
|
+
this.pollInterval = setInterval(function() {
|
|
221
|
+
try {
|
|
222
|
+
self.poll();
|
|
223
|
+
} catch {
|
|
224
|
+
// We can probably ignore errors here as far as broadcasting.
|
|
225
|
+
// Disconnection issues will get handled below
|
|
226
|
+
}
|
|
227
|
+
}, interval).unref();
|
|
228
|
+
|
|
229
|
+
// Handle disconnections
|
|
230
|
+
this.once('disconnected', function() {
|
|
231
|
+
// Just rerun this function with interval 0. If any
|
|
232
|
+
// poll interval is set, this will remove it
|
|
233
|
+
self.setPollInterval(0);
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return this;
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Set automatic polling for events on the librdkafka background thread.
|
|
241
|
+
*
|
|
242
|
+
* This provides several advantages over `setPollInterval`, as the polling
|
|
243
|
+
* does not happen on the event loop, but on the C thread spawned by librdkafka,
|
|
244
|
+
* and can be more efficient for high-throughput producers.
|
|
245
|
+
*
|
|
246
|
+
* If set = true, this will disable any polling interval set by `setPollInterval`.
|
|
247
|
+
*
|
|
248
|
+
* @param {boolean} set Whether to poll in the background or not.
|
|
249
|
+
* @returns {RdKafka.Producer} - returns itself.
|
|
250
|
+
*/
|
|
251
|
+
Producer.prototype.setPollInBackground = function(set) {
|
|
252
|
+
if (set) {
|
|
253
|
+
this.setPollInterval(0); // Clear poll interval from JS.
|
|
254
|
+
}
|
|
255
|
+
this._client.setPollInBackground(set);
|
|
256
|
+
return this;
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Flush the producer,
|
|
261
|
+
*
|
|
262
|
+
* The producer accumulates messages upto `linger.ms` on an internal buffer.
|
|
263
|
+
* This method flushes on the buffer immediately. Do this before disconnects, usually.
|
|
264
|
+
*
|
|
265
|
+
* @param {number?} timeout - Number of milliseconds to try to flush before giving up.
|
|
266
|
+
* @param {function?} callback - Callback to fire when the flush is done.
|
|
267
|
+
*
|
|
268
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
269
|
+
*/
|
|
270
|
+
Producer.prototype.flush = function(timeout, callback) {
|
|
271
|
+
if (!this._isConnected) {
|
|
272
|
+
throw new Error('Producer not connected');
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (timeout === undefined || timeout === null) {
|
|
276
|
+
timeout = 500;
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
this._client.flush(timeout, function(err) {
|
|
280
|
+
if (err) {
|
|
281
|
+
err = LibrdKafkaError.create(err);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
if (callback) {
|
|
285
|
+
callback(err);
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
return this;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Save the base disconnect method here so we can overwrite it and add a flush.
|
|
293
|
+
* @private
|
|
294
|
+
*/
|
|
295
|
+
Producer.prototype._disconnect = Producer.prototype.disconnect;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Disconnect the producer.
|
|
299
|
+
*
|
|
300
|
+
* Flush everything on the internal librdkafka producer buffer. Then disconnect.
|
|
301
|
+
*
|
|
302
|
+
* @param {number?} timeout - Number of milliseconds to try to flush before giving up, defaults to 5 seconds.
|
|
303
|
+
* @param {function?} cb - The callback to fire when disconnected.
|
|
304
|
+
*/
|
|
305
|
+
Producer.prototype.disconnect = function(timeout, cb) {
|
|
306
|
+
var self = this;
|
|
307
|
+
var timeoutInterval = 5000;
|
|
308
|
+
|
|
309
|
+
if (typeof timeout === 'function') {
|
|
310
|
+
cb = timeout;
|
|
311
|
+
} else {
|
|
312
|
+
timeoutInterval = timeout;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
this.flush(timeoutInterval, function() {
|
|
316
|
+
self._disconnect(cb);
|
|
317
|
+
});
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Initialize transactions for this producer instance.
|
|
322
|
+
*
|
|
323
|
+
* Initialize transactions, this must only be performed once per transactional producer,
|
|
324
|
+
* before it can be used.
|
|
325
|
+
*
|
|
326
|
+
* @param {number} timeout - Number of milliseconds to try to initialize before giving up, defaults to 5 seconds.
|
|
327
|
+
* @param {function} cb - Callback to fire when operation is completed.
|
|
328
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
329
|
+
*/
|
|
330
|
+
Producer.prototype.initTransactions = function(timeout, cb) {
|
|
331
|
+
if (typeof timeout === 'function') {
|
|
332
|
+
cb = timeout;
|
|
333
|
+
timeout = 5000;
|
|
334
|
+
}
|
|
335
|
+
this._client.initTransactions(timeout, function(err) {
|
|
336
|
+
cb(err ? LibrdKafkaError.create(err) : err);
|
|
337
|
+
});
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Begin a transaction.
|
|
342
|
+
*
|
|
343
|
+
* `initTransaction` must have been called successfully (once) before this function is called.
|
|
344
|
+
*
|
|
345
|
+
* There can only be one ongoing transaction at a time.
|
|
346
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
347
|
+
*/
|
|
348
|
+
Producer.prototype.beginTransaction = function(cb) {
|
|
349
|
+
this._client.beginTransaction(function(err) {
|
|
350
|
+
cb(err ? LibrdKafkaError.create(err) : err);
|
|
351
|
+
});
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Commit the current transaction (as started with `beginTransaction`).
|
|
356
|
+
*
|
|
357
|
+
* @param {number} timeout - Number of milliseconds to try to commit before giving up, defaults to 5 seconds.
|
|
358
|
+
* @param {function} cb - Callback to fire when operation is completed.
|
|
359
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
360
|
+
*/
|
|
361
|
+
Producer.prototype.commitTransaction = function(timeout, cb) {
|
|
362
|
+
if (typeof timeout === 'function') {
|
|
363
|
+
cb = timeout;
|
|
364
|
+
timeout = 5000;
|
|
365
|
+
}
|
|
366
|
+
this._client.commitTransaction(timeout, function(err) {
|
|
367
|
+
cb(err ? LibrdKafkaError.create(err) : err);
|
|
368
|
+
});
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
* Aborts the ongoing transaction (as started with `beginTransaction`).
|
|
373
|
+
*
|
|
374
|
+
* @param {number} timeout - Number of milliseconds to try to abort, defaults to 5 seconds.
|
|
375
|
+
* @param {function} cb - Callback to fire when operation is completed.
|
|
376
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
377
|
+
*/
|
|
378
|
+
Producer.prototype.abortTransaction = function(timeout, cb) {
|
|
379
|
+
if (typeof timeout === 'function') {
|
|
380
|
+
cb = timeout;
|
|
381
|
+
timeout = 5000;
|
|
382
|
+
}
|
|
383
|
+
this._client.abortTransaction(timeout, function(err) {
|
|
384
|
+
cb(err ? LibrdKafkaError.create(err) : err);
|
|
385
|
+
});
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* Send the current offsets of the consumer to the ongoing transaction.
|
|
390
|
+
*
|
|
391
|
+
* @param {RdKafka.TopicPartition[]} offsets - An array of topic-partitions with offsets filled in.
|
|
392
|
+
* @param {RdKafka.KafkaConsumer} consumer - An instance of the consumer to send offsets for.
|
|
393
|
+
* @param {number} timeout - Number of milliseconds to try to send offsets, defaults to 5 seconds.
|
|
394
|
+
* @param {function} cb - Callback to return when operation is completed.
|
|
395
|
+
* @return {RdKafka.Producer} - returns itself.
|
|
396
|
+
*/
|
|
397
|
+
Producer.prototype.sendOffsetsToTransaction = function(offsets, consumer, timeout, cb) {
|
|
398
|
+
if (typeof timeout === 'function') {
|
|
399
|
+
cb = timeout;
|
|
400
|
+
timeout = 5000;
|
|
401
|
+
}
|
|
402
|
+
this._client.sendOffsetsToTransaction(offsets, consumer.getClient(), timeout, function(err) {
|
|
403
|
+
cb(err ? LibrdKafkaError.create(err) : err);
|
|
404
|
+
});
|
|
405
|
+
};
|
package/lib/rdkafka.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 Blizzard Entertainment
|
|
5
|
+
* (c) 2024 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
|
+
|
|
11
|
+
var KafkaConsumer = require('./kafka-consumer');
|
|
12
|
+
var Producer = require('./producer');
|
|
13
|
+
var HighLevelProducer = require('./producer/high-level-producer');
|
|
14
|
+
var error = require('./error');
|
|
15
|
+
var util = require('util');
|
|
16
|
+
var lib = require('../librdkafka');
|
|
17
|
+
var Topic = require('./topic');
|
|
18
|
+
var Admin = require('./admin');
|
|
19
|
+
var features = lib.features().split(',');
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Namespace for non-promifisied, callback-based Kafka client API.
|
|
23
|
+
* @namespace RdKafka
|
|
24
|
+
*/
|
|
25
|
+
module.exports = {
|
|
26
|
+
Consumer: util.deprecate(KafkaConsumer, 'Use KafkaConsumer instead. This may be changed in a later version'),
|
|
27
|
+
Producer: Producer,
|
|
28
|
+
HighLevelProducer: HighLevelProducer,
|
|
29
|
+
AdminClient: Admin,
|
|
30
|
+
KafkaConsumer: KafkaConsumer,
|
|
31
|
+
createReadStream: KafkaConsumer.createReadStream,
|
|
32
|
+
createWriteStream: Producer.createWriteStream,
|
|
33
|
+
CODES: {
|
|
34
|
+
ERRORS: error.codes,
|
|
35
|
+
},
|
|
36
|
+
Topic: Topic,
|
|
37
|
+
features: features,
|
|
38
|
+
librdkafkaVersion: lib.librdkafkaVersion,
|
|
39
|
+
IsolationLevel: Admin.IsolationLevel,
|
|
40
|
+
OffsetSpec: Admin.OffsetSpec,
|
|
41
|
+
ConsumerGroupStates: Admin.ConsumerGroupStates,
|
|
42
|
+
ConsumerGroupTypes: Admin.ConsumerGroupTypes,
|
|
43
|
+
AclOperationTypes: Admin.AclOperationTypes,
|
|
44
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 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
|
+
module.exports = RefCounter;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Ref counter class.
|
|
14
|
+
*
|
|
15
|
+
* Is used to basically determine active/inactive and allow callbacks that
|
|
16
|
+
* hook into each.
|
|
17
|
+
*
|
|
18
|
+
* For the producer, it is used to begin rapid polling after a produce until
|
|
19
|
+
* the delivery report is dispatched.
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
function RefCounter(onActive, onPassive) {
|
|
23
|
+
this.context = {};
|
|
24
|
+
this.onActive = onActive;
|
|
25
|
+
this.onPassive = onPassive;
|
|
26
|
+
this.currentValue = 0;
|
|
27
|
+
this.isRunning = false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Increment the ref counter
|
|
32
|
+
*/
|
|
33
|
+
RefCounter.prototype.increment = function() {
|
|
34
|
+
this.currentValue += 1;
|
|
35
|
+
|
|
36
|
+
// If current value exceeds 0, activate the start
|
|
37
|
+
if (this.currentValue > 0 && !this.isRunning) {
|
|
38
|
+
this.isRunning = true;
|
|
39
|
+
this.onActive(this.context);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Decrement the ref counter
|
|
45
|
+
*/
|
|
46
|
+
RefCounter.prototype.decrement = function() {
|
|
47
|
+
this.currentValue -= 1;
|
|
48
|
+
|
|
49
|
+
if (this.currentValue <= 0 && this.isRunning) {
|
|
50
|
+
this.isRunning = false;
|
|
51
|
+
this.onPassive(this.context);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 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
|
+
var Topic = require('./topic');
|
|
11
|
+
|
|
12
|
+
module.exports = TopicPartition;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Map an array of topic partition js objects to real topic partition objects.
|
|
16
|
+
*
|
|
17
|
+
* @param array The array of topic partition raw objects to map to topic
|
|
18
|
+
* partition objects
|
|
19
|
+
* @private
|
|
20
|
+
*/
|
|
21
|
+
TopicPartition.map = function(array) {
|
|
22
|
+
return array.map(function(element) {
|
|
23
|
+
return TopicPartition.create(element);
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Take a topic partition javascript object and convert it to the class.
|
|
29
|
+
* The class will automatically convert offset identifiers to special constants
|
|
30
|
+
*
|
|
31
|
+
* @param element The topic partition raw javascript object
|
|
32
|
+
* @private
|
|
33
|
+
*/
|
|
34
|
+
TopicPartition.create = function(element) {
|
|
35
|
+
// Just ensure we take something that can have properties. The topic partition
|
|
36
|
+
// class will
|
|
37
|
+
element = element || {};
|
|
38
|
+
return new TopicPartition(element.topic, element.partition, element.offset);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create a topic partition. Just does some validation and decoration
|
|
43
|
+
* on topic partitions provided.
|
|
44
|
+
*
|
|
45
|
+
* Goal is still to behave like a plain javascript object but with validation
|
|
46
|
+
* and potentially some extra methods
|
|
47
|
+
* @private
|
|
48
|
+
*/
|
|
49
|
+
function TopicPartition(topic, partition, offset) {
|
|
50
|
+
if (!(this instanceof TopicPartition)) {
|
|
51
|
+
return new TopicPartition(topic, partition, offset);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Validate that the elements we are iterating over are actual topic partition
|
|
55
|
+
// js objects. They do not need an offset, but they do need partition
|
|
56
|
+
if (!topic) {
|
|
57
|
+
throw new TypeError('"topic" must be a string and must be set');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (partition === null || partition === undefined) {
|
|
61
|
+
throw new TypeError('"partition" must be a number and must set');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// We can just set topic and partition as they stand.
|
|
65
|
+
this.topic = topic;
|
|
66
|
+
this.partition = partition;
|
|
67
|
+
|
|
68
|
+
if (offset === undefined || offset === null) {
|
|
69
|
+
this.offset = Topic.OFFSET_STORED;
|
|
70
|
+
} else if (typeof offset === 'string') {
|
|
71
|
+
switch (offset.toLowerCase()) {
|
|
72
|
+
case 'earliest':
|
|
73
|
+
case 'beginning':
|
|
74
|
+
this.offset = Topic.OFFSET_BEGINNING;
|
|
75
|
+
break;
|
|
76
|
+
case 'latest':
|
|
77
|
+
case 'end':
|
|
78
|
+
this.offset = Topic.OFFSET_END;
|
|
79
|
+
break;
|
|
80
|
+
case 'stored':
|
|
81
|
+
this.offset = Topic.OFFSET_STORED;
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
throw new TypeError('"offset", if provided as a string, must be beginning, end, or stored.');
|
|
85
|
+
}
|
|
86
|
+
} else if (typeof offset === 'number') {
|
|
87
|
+
this.offset = offset;
|
|
88
|
+
} else {
|
|
89
|
+
throw new TypeError('"offset" must be a special string or number if it is set');
|
|
90
|
+
}
|
|
91
|
+
}
|
package/lib/topic.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 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
|
+
var librdkafka = require('../librdkafka');
|
|
11
|
+
|
|
12
|
+
module.exports = Topic;
|
|
13
|
+
|
|
14
|
+
var topicKey = 'RdKafka::Topic::';
|
|
15
|
+
var topicKeyLength = topicKey.length;
|
|
16
|
+
|
|
17
|
+
// Take all of the topic special codes from librdkafka and add them
|
|
18
|
+
// to the object
|
|
19
|
+
// You can find this list in the C++ code at
|
|
20
|
+
// https://github.com/confluentinc/librdkafka/blob/master/src-cpp/rdkafkacpp.h#L1250
|
|
21
|
+
for (var key in librdkafka.topic) {
|
|
22
|
+
// Skip it if it doesn't start with ErrorCode
|
|
23
|
+
if (key.indexOf('RdKafka::Topic::') !== 0) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Replace/add it if there are any discrepancies
|
|
28
|
+
var newKey = key.substring(topicKeyLength);
|
|
29
|
+
Topic[newKey] = librdkafka.topic[key];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Create a topic. Just returns the string you gave it right now.
|
|
34
|
+
*
|
|
35
|
+
* Looks like a class, but all it does is return the topic name.
|
|
36
|
+
* This is so that one day if there are interface changes that allow
|
|
37
|
+
* different use of topic parameters, we can just add to this constructor and
|
|
38
|
+
* have it return something richer
|
|
39
|
+
* @private
|
|
40
|
+
*/
|
|
41
|
+
function Topic(topicName) {
|
|
42
|
+
return topicName;
|
|
43
|
+
}
|
package/lib/util.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 Blizzard Entertainment
|
|
5
|
+
* 2024 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
|
+
|
|
11
|
+
var util = module.exports = {};
|
|
12
|
+
|
|
13
|
+
util.shallowCopy = function (obj) {
|
|
14
|
+
|
|
15
|
+
if (!util.isObject(obj)) { return obj; }
|
|
16
|
+
|
|
17
|
+
var copy = {};
|
|
18
|
+
|
|
19
|
+
for (var k in obj) {
|
|
20
|
+
if (Object.hasOwn(obj, k)) {
|
|
21
|
+
copy[k] = obj[k];
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return copy;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
util.isObject = function (obj) {
|
|
29
|
+
return obj && typeof obj === 'object';
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// Convert Map or object to a list of [key, value, key, value...].
|
|
33
|
+
util.dictToStringList = function (mapOrObject) {
|
|
34
|
+
let list = null;
|
|
35
|
+
if (mapOrObject && (mapOrObject instanceof Map)) {
|
|
36
|
+
list =
|
|
37
|
+
Array
|
|
38
|
+
.from(mapOrObject).reduce((acc, [key, value]) => {
|
|
39
|
+
acc.push(key, value);
|
|
40
|
+
return acc;
|
|
41
|
+
}, [])
|
|
42
|
+
.map(v => String(v));
|
|
43
|
+
} else if (util.isObject(mapOrObject)) {
|
|
44
|
+
list =
|
|
45
|
+
Object
|
|
46
|
+
.entries(mapOrObject).reduce((acc, [key, value]) => {
|
|
47
|
+
acc.push(key, value);
|
|
48
|
+
return acc;
|
|
49
|
+
}, [])
|
|
50
|
+
.map(v => String(v));
|
|
51
|
+
}
|
|
52
|
+
return list;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
util.bindingVersion = '1.10.0';
|
package/librdkafka.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* confluent-kafka-javascript - Node.js wrapper for RdKafka C/C++ library
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2016-2023 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
|
+
var kafka = require('bindings')('confluent-kafka-javascript');
|
|
11
|
+
|
|
12
|
+
module.exports = kafka;
|