@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,887 @@
|
|
|
1
|
+
const error = require("./_error");
|
|
2
|
+
const process = require("process");
|
|
3
|
+
const { AsyncLocalStorage } = require('node:async_hooks');
|
|
4
|
+
|
|
5
|
+
/* A list of kafkaJS compatible properties that we process.
|
|
6
|
+
* All of these are not necessarily supported, and an error will be
|
|
7
|
+
* thrown if they aren't. */
|
|
8
|
+
const kafkaJSProperties = {
|
|
9
|
+
common: [
|
|
10
|
+
"brokers",
|
|
11
|
+
"clientId",
|
|
12
|
+
"sasl",
|
|
13
|
+
"ssl",
|
|
14
|
+
"requestTimeout",
|
|
15
|
+
"enforceRequestTimeout",
|
|
16
|
+
"connectionTimeout",
|
|
17
|
+
"authenticationTimeout",
|
|
18
|
+
"retry",
|
|
19
|
+
"socketFactory",
|
|
20
|
+
"reauthenticationThreshold",
|
|
21
|
+
"logLevel",
|
|
22
|
+
'logger',
|
|
23
|
+
],
|
|
24
|
+
producer: [
|
|
25
|
+
'createPartitioner',
|
|
26
|
+
'metadataMaxAge',
|
|
27
|
+
'allowAutoTopicCreation',
|
|
28
|
+
'transactionTimeout',
|
|
29
|
+
'idempotent',
|
|
30
|
+
'maxInFlightRequests',
|
|
31
|
+
'transactionalId',
|
|
32
|
+
'compression',
|
|
33
|
+
'acks',
|
|
34
|
+
'timeout',
|
|
35
|
+
],
|
|
36
|
+
consumer: [
|
|
37
|
+
'groupId',
|
|
38
|
+
'partitionAssigners',
|
|
39
|
+
'partitionAssignors',
|
|
40
|
+
'sessionTimeout',
|
|
41
|
+
'rebalanceTimeout',
|
|
42
|
+
'heartbeatInterval',
|
|
43
|
+
'metadataMaxAge',
|
|
44
|
+
'allowAutoTopicCreation',
|
|
45
|
+
'maxBytesPerPartition',
|
|
46
|
+
'maxWaitTimeInMs',
|
|
47
|
+
'minBytes',
|
|
48
|
+
'maxBytes',
|
|
49
|
+
'readUncommitted',
|
|
50
|
+
'maxInFlightRequests',
|
|
51
|
+
'rackId',
|
|
52
|
+
'fromBeginning',
|
|
53
|
+
'autoCommit',
|
|
54
|
+
'autoCommitInterval',
|
|
55
|
+
'autoCommitThreshold',
|
|
56
|
+
],
|
|
57
|
+
admin: [],
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* A list of supported log levels.
|
|
62
|
+
* @enum {number}
|
|
63
|
+
* @readonly
|
|
64
|
+
* @memberof KafkaJS
|
|
65
|
+
*/
|
|
66
|
+
const logLevel = {
|
|
67
|
+
NOTHING: 0,
|
|
68
|
+
ERROR: 1,
|
|
69
|
+
WARN: 2,
|
|
70
|
+
INFO: 3,
|
|
71
|
+
DEBUG: 4,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const severityToLogLevel = Object.freeze({
|
|
75
|
+
0: logLevel.NOTHING,
|
|
76
|
+
1: logLevel.ERROR,
|
|
77
|
+
2: logLevel.ERROR,
|
|
78
|
+
3: logLevel.ERROR,
|
|
79
|
+
4: logLevel.WARN,
|
|
80
|
+
5: logLevel.WARN,
|
|
81
|
+
6: logLevel.INFO,
|
|
82
|
+
7: logLevel.DEBUG,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Default logger implementation.
|
|
87
|
+
* @type import("../../types/kafkajs").Logger
|
|
88
|
+
* @private
|
|
89
|
+
*/
|
|
90
|
+
class DefaultLogger {
|
|
91
|
+
constructor() {
|
|
92
|
+
this.logLevel = logLevel.INFO;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
setLogLevel(logLevel) {
|
|
96
|
+
this.logLevel = logLevel;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
info(message, extra) {
|
|
100
|
+
if (this.logLevel >= logLevel.INFO)
|
|
101
|
+
console.info({ message, ...extra });
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
error(message, extra) {
|
|
105
|
+
if (this.logLevel >= logLevel.ERROR)
|
|
106
|
+
console.error({ message, ...extra });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
warn(message, extra) {
|
|
110
|
+
if (this.logLevel >= logLevel.WARN)
|
|
111
|
+
console.warn({ message, ...extra });
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
debug(message, extra) {
|
|
115
|
+
if (this.logLevel >= logLevel.DEBUG)
|
|
116
|
+
console.log({ message, ...extra });
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
namespace() {
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Convenience function to create a new object to be used as metadata for log messages.
|
|
126
|
+
* Returned object is intended to be used immediately and not stored.
|
|
127
|
+
*
|
|
128
|
+
* @param {string|undefined} clientName
|
|
129
|
+
* @private
|
|
130
|
+
*/
|
|
131
|
+
function createBindingMessageMetadata(clientName) {
|
|
132
|
+
return {
|
|
133
|
+
name: clientName || '',
|
|
134
|
+
fac: 'BINDING',
|
|
135
|
+
timestamp: Date.now(),
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Trampoline for user defined logger, if any.
|
|
141
|
+
* @param {{severity: number, fac: string, message: string}} msg
|
|
142
|
+
* @private
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
function loggerTrampoline(msg, logger) {
|
|
146
|
+
if (!logger) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const level = severityToLogLevel[msg.severity];
|
|
151
|
+
switch (level) {
|
|
152
|
+
case logLevel.NOTHING:
|
|
153
|
+
break;
|
|
154
|
+
case logLevel.ERROR:
|
|
155
|
+
logger.error(msg.message, { fac: msg.fac, timestamp: Date.now(), name: msg.name });
|
|
156
|
+
break;
|
|
157
|
+
case logLevel.WARN:
|
|
158
|
+
logger.warn(msg.message, { fac: msg.fac, timestamp: Date.now(), name: msg.name });
|
|
159
|
+
break;
|
|
160
|
+
case logLevel.INFO:
|
|
161
|
+
logger.info(msg.message, { fac: msg.fac, timestamp: Date.now(), name: msg.name });
|
|
162
|
+
break;
|
|
163
|
+
case logLevel.DEBUG:
|
|
164
|
+
logger.debug(msg.message, { fac: msg.fac, timestamp: Date.now(), name: msg.name });
|
|
165
|
+
break;
|
|
166
|
+
default:
|
|
167
|
+
throw new error.KafkaJSError("Invalid logLevel", {
|
|
168
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function createReplacementErrorMessage(cOrP, fnCall, property, propertyVal, replacementVal, isLK = false) {
|
|
174
|
+
if (!isLK) {
|
|
175
|
+
replacementVal = `kafkaJS: { ${replacementVal}, ... }`;
|
|
176
|
+
}
|
|
177
|
+
return `'${property}' is not supported as a property to '${fnCall}', but must be passed to the ${cOrP} during creation.\n` +
|
|
178
|
+
`Before: \n` +
|
|
179
|
+
`\tconst ${cOrP} = kafka.${cOrP}({ ... });\n` +
|
|
180
|
+
`\tawait ${cOrP}.connect();\n` +
|
|
181
|
+
`\t${cOrP}.${fnCall}({ ${propertyVal}, ... });\n` +
|
|
182
|
+
`After: \n` +
|
|
183
|
+
`\tconst ${cOrP} = kafka.${cOrP}({ ${replacementVal}, ... });\n` +
|
|
184
|
+
`\tawait ${cOrP}.connect();\n` +
|
|
185
|
+
`\t${cOrP}.${fnCall}({ ... });\n` +
|
|
186
|
+
(isLK ? `For more details on what can be used outside the kafkaJS block, see https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md\n` : '');
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const CompatibilityErrorMessages = Object.freeze({
|
|
190
|
+
/* Common */
|
|
191
|
+
brokerString: () =>
|
|
192
|
+
"The 'brokers' property must be an array of strings.\n" +
|
|
193
|
+
"For example: ['kafka:9092', 'kafka2:9093']\n",
|
|
194
|
+
saslUnsupportedMechanism: (mechanism) =>
|
|
195
|
+
`SASL mechanism ${mechanism} is not supported.`,
|
|
196
|
+
saslUsernamePasswordString: (mechanism) =>
|
|
197
|
+
`The 'sasl.username' and 'sasl.password' properties must be strings and must be present for the mechanism ${mechanism}.`,
|
|
198
|
+
saslOauthBearerProvider: () =>
|
|
199
|
+
`The 'oauthBearerProvider' property must be a function.`,
|
|
200
|
+
sslObject: () =>
|
|
201
|
+
"The 'ssl' property must be a boolean. Any additional configuration must be provided outside the kafkaJS block.\n" +
|
|
202
|
+
"Before: \n" +
|
|
203
|
+
"\tconst kafka = new Kafka({ kafkaJS: { ssl: { rejectUnauthorized: false, ca: [ ... ], key: ..., cert: ... }, } }); \n" +
|
|
204
|
+
"After: \n" +
|
|
205
|
+
'\tconst kafka = new Kafka({ kafkaJS: { ssl: true, }, "enable.ssl.certificate.verification": false, "ssl.ca.location": ..., "ssl.certificate.pem": ... });\n' +
|
|
206
|
+
`For more details on what can be used outside the kafkaJS block, see https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md\n`,
|
|
207
|
+
retryFactorMultiplier: () =>
|
|
208
|
+
+ "The 'retry.factor' and 'retry.multiplier' are not supported. They are always set to the default of 0.2 and 2 respectively.",
|
|
209
|
+
retryRestartOnFailure: () =>
|
|
210
|
+
"The restartOnFailure property is ignored. The client always retries on failure.",
|
|
211
|
+
socketFactory: () =>
|
|
212
|
+
"The socketFactory property is not supported.",
|
|
213
|
+
logLevelName: (setLevel) =>
|
|
214
|
+
"The log level must be one of: " + Object.keys(logLevel).join(", ") + ", was " + setLevel,
|
|
215
|
+
reauthenticationThreshold: () =>
|
|
216
|
+
"Reauthentication threshold cannot be set, and reauthentication is automated when 80% of connections.max.reauth.ms is reached.",
|
|
217
|
+
unsupportedKey: (key) =>
|
|
218
|
+
`The '${key}' property is not supported.`,
|
|
219
|
+
kafkaJSCommonKey: (key) =>
|
|
220
|
+
`The '${key}' property seems to be a KafkaJS property in the main config block.` +
|
|
221
|
+
`It must be moved to the kafkaJS block.` +
|
|
222
|
+
`\nBefore: \n` +
|
|
223
|
+
`\tconst kafka = new Kafka({ ${key}: <value>, ... });\n` +
|
|
224
|
+
`After: \n` +
|
|
225
|
+
`\tconst kafka = new Kafka({ kafkaJS: { ${key}: <value>, ... }, ... });\n`,
|
|
226
|
+
kafkaJSClientKey: (key, cOrP) =>
|
|
227
|
+
`The '${key}' property seems to be a KafkaJS property in the main config block. ` +
|
|
228
|
+
`It must be moved to the kafkaJS block.` +
|
|
229
|
+
`\nBefore: \n` +
|
|
230
|
+
`\tconst kafka = new Kafka({ ... });\n` +
|
|
231
|
+
`\tconst ${cOrP} = kafka.${cOrP}({ ${key}: <value>, ... });\n` +
|
|
232
|
+
`After: \n` +
|
|
233
|
+
`\tconst kafka = new Kafka({ ... });\n` +
|
|
234
|
+
`\tconst ${cOrP} = kafka.${cOrP}({ kafkaJS: { ${key}: <value>, ... }, ... });\n`,
|
|
235
|
+
|
|
236
|
+
/* Producer */
|
|
237
|
+
createPartitioner: () =>
|
|
238
|
+
"The 'createPartitioner' property is not supported yet. The default partitioner is set to murmur2_random, compatible with the DefaultPartitioner and the Java partitioner.\n" +
|
|
239
|
+
"A number of alternative partioning strategies are available through the 'rdKafka' property, for example: \n" +
|
|
240
|
+
"\tconst kafka = new Kafka({ rdKafka: { 'partitioner': 'random|consistent_random|consistent|murmur2|murmur2_random|fnv1a|fnv1a_random' } });\n" +
|
|
241
|
+
`For more details on what can be used inside the rdKafka block, see https://github.com/confluentinc/librdkafka/blob/master/CONFIGURATION.md\n`,
|
|
242
|
+
sendOptionsMandatoryMissing: () =>
|
|
243
|
+
"The argument passed to send must be an object, and must contain the 'topic' and 'messages' properties: {topic: string, messages: Message[]}\n",
|
|
244
|
+
sendOptionsAcks: (fn) =>
|
|
245
|
+
createReplacementErrorMessage('producer', fn, 'acks', 'acks: <number>', 'acks: <number>', false),
|
|
246
|
+
sendOptionsCompression: (fn) =>
|
|
247
|
+
createReplacementErrorMessage('producer', fn, 'compression', 'compression: <type>', 'compression: CompressionTypes.GZIP|SNAPPY|LZ4|ZSTD', false),
|
|
248
|
+
sendOptionsTimeout: (fn) =>
|
|
249
|
+
createReplacementErrorMessage('producer', fn, 'timeout', 'timeout: <number>', 'timeout: <number>', false),
|
|
250
|
+
sendBatchMandatoryMissing: () =>
|
|
251
|
+
"The argument passed to sendbatch must be an object, and must contain the 'topicMessages' property: { topicMessages: {topic: string, messages: Message[]}[] } \n",
|
|
252
|
+
sendOffsetsMustProvideConsumer: () =>
|
|
253
|
+
"The sendOffsets method must be called with a connected consumer instance and without a consumerGroupId parameter.\n",
|
|
254
|
+
|
|
255
|
+
/* Consumer */
|
|
256
|
+
partitionAssignors: () =>
|
|
257
|
+
'partitionAssignors must be a list of strings from within `PartitionAssignors`.\n',
|
|
258
|
+
subscribeOptionsFromBeginning: () =>
|
|
259
|
+
createReplacementErrorMessage('consumer', 'subscribe', 'fromBeginning', 'fromBeginning: <boolean>', 'fromBeginning: <boolean>', false),
|
|
260
|
+
subscribeOptionsMandatoryMissing: () =>
|
|
261
|
+
"The argument passed to subscribe must be an object, and must contain the 'topics' or the 'topic' property: {topics: string[]} or {topic: string}\n",
|
|
262
|
+
subscribeOptionsRegexFlag: () =>
|
|
263
|
+
"If subscribing to topic by RegExp, no flags are allowed. /^abcd/ is okay, but /^abcd/i is not.\n",
|
|
264
|
+
subscribeOptionsRegexStart: () =>
|
|
265
|
+
"If subscribing to topic by RegExp, the pattern must start with a '^'. If you want to use something like /abcd/, /^.*abcd/ must be used.\n",
|
|
266
|
+
runOptionsAutoCommit: () =>
|
|
267
|
+
createReplacementErrorMessage('consumer', 'run', 'autoCommit', 'autoCommit: <boolean>', 'autoCommit: <boolean>', false),
|
|
268
|
+
runOptionsAutoCommitInterval: () =>
|
|
269
|
+
createReplacementErrorMessage('consumer', 'run', 'autoCommitInterval', 'autoCommitInterval: <number>', 'autoCommitInterval: <number>', false),
|
|
270
|
+
runOptionsAutoCommitThreshold: () =>
|
|
271
|
+
"The property 'autoCommitThreshold' is not supported by run.\n",
|
|
272
|
+
runOptionsRunConcurrently: () =>
|
|
273
|
+
"The property 'partitionsConsumedConcurrently' is not currently supported by run\n",
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Converts the common configuration from KafkaJS to a format that can be used by node-rdkafka.
|
|
278
|
+
* @param {object} config
|
|
279
|
+
* @returns {import('../../types/config').ProducerGlobalConfig | import('../../types/config').ConsumerGlobalConfig} the converted configuration
|
|
280
|
+
* @throws {error.KafkaJSError} if the configuration is invalid.
|
|
281
|
+
* The error code will be ERR__INVALID_ARG in case of invalid arguments or features that are not supported.
|
|
282
|
+
* The error code will be ERR__NOT_IMPLEMENTED in case of features that are not yet implemented.
|
|
283
|
+
* @private
|
|
284
|
+
*/
|
|
285
|
+
function kafkaJSToRdKafkaConfig(config) {
|
|
286
|
+
/* Since the kafkaJS block is specified, we operate in
|
|
287
|
+
* kafkaJS compatibility mode. That means we change the defaults
|
|
288
|
+
* match the kafkaJS defaults. */
|
|
289
|
+
const rdkafkaConfig = {};
|
|
290
|
+
|
|
291
|
+
if (Object.hasOwn(config, "brokers")) {
|
|
292
|
+
if (!Array.isArray(config["brokers"])) {
|
|
293
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.brokerString(), {
|
|
294
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
rdkafkaConfig["bootstrap.servers"] = config["brokers"].join(",");
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
if (Object.hasOwn(config, "clientId")) {
|
|
301
|
+
rdkafkaConfig["client.id"] = config.clientId;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
let withSASL = false;
|
|
305
|
+
|
|
306
|
+
if (Object.hasOwn(config, "sasl")) {
|
|
307
|
+
const sasl = config.sasl;
|
|
308
|
+
const mechanism = sasl.mechanism.toUpperCase();
|
|
309
|
+
|
|
310
|
+
if (mechanism === 'OAUTHBEARER') {
|
|
311
|
+
rdkafkaConfig["sasl.mechanism"] = mechanism;
|
|
312
|
+
if (Object.hasOwn(sasl, "oauthBearerProvider")) {
|
|
313
|
+
if (typeof sasl.oauthBearerProvider !== 'function') {
|
|
314
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.saslOauthBearerProvider(), {
|
|
315
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
rdkafkaConfig['oauthbearer_token_refresh_cb'] = function (oauthbearer_config) {
|
|
319
|
+
return sasl.oauthBearerProvider(oauthbearer_config)
|
|
320
|
+
.then((token) => {
|
|
321
|
+
if (!Object.hasOwn(token, 'value')) {
|
|
322
|
+
throw new error.KafkaJSError('Token must have a value property.', {
|
|
323
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
324
|
+
});
|
|
325
|
+
} else if (!Object.hasOwn(token, 'principal')) {
|
|
326
|
+
throw new error.KafkaJSError('Token must have a principal property.', {
|
|
327
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
328
|
+
});
|
|
329
|
+
} else if (!Object.hasOwn(token, 'lifetime')) {
|
|
330
|
+
throw new error.KafkaJSError('Token must have a lifetime property.', {
|
|
331
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// Recast token into a value expected by node-rdkafka's callback.
|
|
336
|
+
const setToken = {
|
|
337
|
+
tokenValue: token.value,
|
|
338
|
+
extensions: token.extensions,
|
|
339
|
+
principal: token.principal,
|
|
340
|
+
lifetime: token.lifetime,
|
|
341
|
+
};
|
|
342
|
+
return setToken;
|
|
343
|
+
})
|
|
344
|
+
.catch(err => {
|
|
345
|
+
if (!(err instanceof Error)) {
|
|
346
|
+
err = new Error(err);
|
|
347
|
+
}
|
|
348
|
+
throw err;
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
/* It's a valid case (unlike in KafkaJS) for oauthBearerProvider to be
|
|
353
|
+
* null, because librdkafka provides an unsecured token provider for
|
|
354
|
+
* non-prod usecases. So don't do anything in that case. */
|
|
355
|
+
} else if (mechanism === 'PLAIN' || mechanism.startsWith('SCRAM')) {
|
|
356
|
+
if (typeof sasl.username !== "string" || typeof sasl.password !== "string") {
|
|
357
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.saslUsernamePasswordString(mechanism), {
|
|
358
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
rdkafkaConfig["sasl.mechanism"] = mechanism;
|
|
362
|
+
rdkafkaConfig["sasl.username"] = sasl.username;
|
|
363
|
+
rdkafkaConfig["sasl.password"] = sasl.password;
|
|
364
|
+
} else {
|
|
365
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.saslUnsupportedMechanism(mechanism), {
|
|
366
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
withSASL = true;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (Object.hasOwn(config, "ssl") && config.ssl && withSASL) {
|
|
374
|
+
rdkafkaConfig["security.protocol"] = "sasl_ssl";
|
|
375
|
+
} else if (withSASL) {
|
|
376
|
+
rdkafkaConfig["security.protocol"] = "sasl_plaintext";
|
|
377
|
+
} else if (Object.hasOwn(config, "ssl") && config.ssl) {
|
|
378
|
+
rdkafkaConfig["security.protocol"] = "ssl";
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/* TODO: add best-effort support for ssl besides just true/false */
|
|
382
|
+
if (Object.hasOwn(config, "ssl") && typeof config.ssl !== "boolean") {
|
|
383
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.sslObject(), {
|
|
384
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (Object.hasOwn(config, "requestTimeout")) {
|
|
389
|
+
rdkafkaConfig["socket.timeout.ms"] = config.requestTimeout;
|
|
390
|
+
} else {
|
|
391
|
+
/* KafkaJS default */
|
|
392
|
+
rdkafkaConfig["socket.timeout.ms"] = 30000;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
if (Object.hasOwn(config, "enforceRequestTimeout") && !config.enforceRequestTimeout) {
|
|
396
|
+
rdkafkaConfig["socket.timeout.ms"] = 300000;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
const connectionTimeout = config.connectionTimeout ?? 1000;
|
|
400
|
+
const authenticationTimeout = config.authenticationTimeout ?? 10000;
|
|
401
|
+
let totalConnectionTimeout = Number(connectionTimeout) + Number(authenticationTimeout);
|
|
402
|
+
|
|
403
|
+
/* The minimum value for socket.connection.setup.timeout.ms is 1000. */
|
|
404
|
+
totalConnectionTimeout = Math.max(totalConnectionTimeout, 1000);
|
|
405
|
+
rdkafkaConfig["socket.connection.setup.timeout.ms"] = totalConnectionTimeout;
|
|
406
|
+
|
|
407
|
+
const retry = config.retry ?? {};
|
|
408
|
+
const { maxRetryTime, initialRetryTime, factor, multiplier, restartOnFailure } = retry;
|
|
409
|
+
|
|
410
|
+
rdkafkaConfig["retry.backoff.max.ms"] = maxRetryTime ?? 30000;
|
|
411
|
+
rdkafkaConfig["retry.backoff.ms"] = initialRetryTime ?? 300;
|
|
412
|
+
|
|
413
|
+
if ((typeof factor === 'number') || (typeof multiplier === 'number')) {
|
|
414
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.retryFactorMultiplier(), {
|
|
415
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (restartOnFailure) {
|
|
420
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.retryRestartOnFailure(), {
|
|
421
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (Object.hasOwn(config, "socketFactory")) {
|
|
426
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.socketFactory(), {
|
|
427
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
if (Object.hasOwn(config, "reauthenticationThreshold")) {
|
|
432
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.reauthenticationThreshold(), {
|
|
433
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
rdkafkaConfig["log_level"] = 6 /* LOG_INFO - default in KafkaJS compatibility mode. */;
|
|
438
|
+
if (Object.hasOwn(config, "logLevel")) {
|
|
439
|
+
let setLevel = config.logLevel;
|
|
440
|
+
|
|
441
|
+
if (process.env.KAFKAJS_LOG_LEVEL) {
|
|
442
|
+
setLevel = logLevel[process.env.KAFKAJS_LOG_LEVEL.toUpperCase()];
|
|
443
|
+
}
|
|
444
|
+
switch (setLevel) {
|
|
445
|
+
case logLevel.NOTHING:
|
|
446
|
+
rdkafkaConfig["log_level"] = 0; /* LOG_EMERG - we don't have a true log nothing yet */
|
|
447
|
+
break;
|
|
448
|
+
case logLevel.ERROR:
|
|
449
|
+
rdkafkaConfig["log_level"] = 3 /* LOG_ERR */;
|
|
450
|
+
break;
|
|
451
|
+
case logLevel.WARN:
|
|
452
|
+
rdkafkaConfig["log_level"] = 4 /* LOG_WARNING */;
|
|
453
|
+
break;
|
|
454
|
+
case logLevel.INFO:
|
|
455
|
+
rdkafkaConfig["log_level"] = 6 /* LOG_INFO */;
|
|
456
|
+
break;
|
|
457
|
+
case logLevel.DEBUG:
|
|
458
|
+
rdkafkaConfig["log_level"] = 7 /* LOG_DEBUG */;
|
|
459
|
+
break;
|
|
460
|
+
default:
|
|
461
|
+
throw new error.KafkaJSError(CompatibilityErrorMessages.logLevelName(setLevel), {
|
|
462
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
463
|
+
});
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return rdkafkaConfig;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Checks if the config object contains any keys not allowed by KafkaJS.
|
|
472
|
+
* @param {'producer'|'consumer'|'admin'} clientType
|
|
473
|
+
* @param {any} config
|
|
474
|
+
* @returns {string|null} the first unsupported key, or null if all keys are supported.
|
|
475
|
+
* @private
|
|
476
|
+
*/
|
|
477
|
+
function checkAllowedKeys(clientType, config) {
|
|
478
|
+
const allowedKeysCommon = kafkaJSProperties.common;
|
|
479
|
+
|
|
480
|
+
if (!Object.hasOwn(kafkaJSProperties, clientType)) {
|
|
481
|
+
throw new error.KafkaJSError(`Unknown client type ${clientType}`, {
|
|
482
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
const allowedKeysSpecific = kafkaJSProperties[clientType];
|
|
486
|
+
|
|
487
|
+
for (const key of Object.keys(config)) {
|
|
488
|
+
if (!allowedKeysCommon.includes(key) && !allowedKeysSpecific.includes(key)) {
|
|
489
|
+
return key;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
return null;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Checks if the config object contains any keys specific to KafkaJS.
|
|
498
|
+
* @param {'producer'|'consumer'|'admin'|'common'} propertyType
|
|
499
|
+
* @param {any} config
|
|
500
|
+
* @returns {string|null} the first KafkaJS specific key, or null if none is present.
|
|
501
|
+
* @private
|
|
502
|
+
*/
|
|
503
|
+
function checkIfKafkaJsKeysPresent(propertyType, config) {
|
|
504
|
+
if (!Object.hasOwn(kafkaJSProperties, propertyType)) {
|
|
505
|
+
throw new error.KafkaJSError(`Unknown config type for ${propertyType}`, {
|
|
506
|
+
code: error.ErrorCodes.ERR__INVALID_ARG,
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
const kjsKeys = kafkaJSProperties[propertyType];
|
|
510
|
+
|
|
511
|
+
for (const key of Object.keys(config)) {
|
|
512
|
+
/* We exclude 'acks' since it's common to both librdkafka and kafkaJS.
|
|
513
|
+
* We don't intend to keep up with new properties, so we don't need to really worry about making it extensible. */
|
|
514
|
+
if (kjsKeys.includes(key) && key !== 'acks') {
|
|
515
|
+
return key;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
return null;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Converts a topicPartitionOffset from KafkaJS to a format that can be used by node-rdkafka.
|
|
524
|
+
* @param {import("../../types/kafkajs").TopicPartitionOffset} tpo
|
|
525
|
+
* @returns {{topic: string, partition: number, offset: number}}
|
|
526
|
+
* @private
|
|
527
|
+
*/
|
|
528
|
+
function topicPartitionOffsetToRdKafka(tpo) {
|
|
529
|
+
// TODO: do we need some checks for negative offsets and stuff? Or 'named' offsets?
|
|
530
|
+
return {
|
|
531
|
+
topic: tpo.topic,
|
|
532
|
+
partition: tpo.partition,
|
|
533
|
+
offset: Number(tpo.offset),
|
|
534
|
+
leaderEpoch: tpo.leaderEpoch,
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
/**
|
|
539
|
+
* Converts a topicPartitionOffset from KafkaJS to a format that can be used by node-rdkafka.
|
|
540
|
+
* Includes metadata.
|
|
541
|
+
*
|
|
542
|
+
* @param {import("../../types/kafkajs").TopicPartitionOffsetAndMetadata} tpo
|
|
543
|
+
* @returns {import("../../types/rdkafka").TopicPartitionOffsetAndMetadata}
|
|
544
|
+
* @private
|
|
545
|
+
*/
|
|
546
|
+
function topicPartitionOffsetMetadataToRdKafka(tpo) {
|
|
547
|
+
return {
|
|
548
|
+
topic: tpo.topic,
|
|
549
|
+
partition: tpo.partition,
|
|
550
|
+
offset: tpo.offset ? Number(tpo.offset) : null,
|
|
551
|
+
metadata: tpo.metadata,
|
|
552
|
+
leaderEpoch: tpo.leaderEpoch,
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Converts a topicPartitionOffset from node-rdkafka to a format that can be used by KafkaJS.
|
|
558
|
+
* Includes metadata.
|
|
559
|
+
*
|
|
560
|
+
* @param {import("../../types/rdkafka").TopicPartitionOffsetAndMetadata} tpo
|
|
561
|
+
* @returns {import("../../types/kafkajs").TopicPartitionOffsetAndMetadata}
|
|
562
|
+
* @private
|
|
563
|
+
*/
|
|
564
|
+
function topicPartitionOffsetMetadataToKafkaJS(tpo) {
|
|
565
|
+
return {
|
|
566
|
+
topic: tpo.topic,
|
|
567
|
+
partition: tpo.partition,
|
|
568
|
+
offset: tpo.offset ? tpo.offset.toString() : null,
|
|
569
|
+
metadata: tpo.metadata,
|
|
570
|
+
leaderEpoch: tpo.leaderEpoch
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
/**
|
|
575
|
+
* Convert a librdkafka error from node-rdkafka into a KafkaJSError.
|
|
576
|
+
* @param {import("../error")} librdKafkaError to convert from.
|
|
577
|
+
* @returns {error.KafkaJSError} the converted error.
|
|
578
|
+
* @private
|
|
579
|
+
*/
|
|
580
|
+
function createKafkaJsErrorFromLibRdKafkaError(librdKafkaError) {
|
|
581
|
+
const properties = {
|
|
582
|
+
retriable: librdKafkaError.retriable,
|
|
583
|
+
fatal: librdKafkaError.fatal,
|
|
584
|
+
abortable: librdKafkaError.abortable,
|
|
585
|
+
stack: librdKafkaError.stack,
|
|
586
|
+
code: librdKafkaError.code,
|
|
587
|
+
};
|
|
588
|
+
|
|
589
|
+
let err = null;
|
|
590
|
+
|
|
591
|
+
if (properties.code === error.ErrorCodes.ERR_OFFSET_OUT_OF_RANGE) {
|
|
592
|
+
err = new error.KafkaJSOffsetOutOfRange(librdKafkaError, properties);
|
|
593
|
+
} else if (properties.code === error.ErrorCodes.ERR_REQUEST_TIMED_OUT) {
|
|
594
|
+
err = new error.KafkaJSRequestTimeoutError(librdKafkaError, properties);
|
|
595
|
+
} else if (properties.code === error.ErrorCodes.ERR__PARTIAL) {
|
|
596
|
+
err = new error.KafkaJSPartialMessageError(librdKafkaError, properties);
|
|
597
|
+
} else if (properties.code === error.ErrorCodes.ERR__AUTHENTICATION) {
|
|
598
|
+
err = new error.KafkaJSSASLAuthenticationError(librdKafkaError, properties);
|
|
599
|
+
} else if (properties.code === error.ErrorCodes.ERR_GROUP_COORDINATOR_NOT_AVAILABLE) {
|
|
600
|
+
err = new error.KafkaJSGroupCoordinatorNotAvailableError(librdKafkaError, properties);
|
|
601
|
+
} else if (properties.code === error.ErrorCodes.ERR__NOT_IMPLEMENTED) {
|
|
602
|
+
err = new error.KafkaJSNotImplemented(librdKafkaError, properties);
|
|
603
|
+
} else if (properties.code === error.ErrorCodes.ERR__TIMED_OUT) {
|
|
604
|
+
err = new error.KafkaJSTimeout(librdKafkaError, properties);
|
|
605
|
+
} else if (properties.code === error.ErrorCodes.ERR__ALL_BROKERS_DOWN) {
|
|
606
|
+
err = new error.KafkaJSNoBrokerAvailableError(librdKafkaError, properties);
|
|
607
|
+
} else if (properties.code === error.ErrorCodes.ERR__TRANSPORT) {
|
|
608
|
+
err = new error.KafkaJSConnectionError(librdKafkaError, properties);
|
|
609
|
+
} else if (properties.code > 0) { /* Indicates a non-local error */
|
|
610
|
+
err = new error.KafkaJSProtocolError(librdKafkaError, properties);
|
|
611
|
+
} else {
|
|
612
|
+
err = new error.KafkaJSError(librdKafkaError, properties);
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
return err;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Converts KafkaJS headers to a format that can be used by node-rdkafka.
|
|
620
|
+
* @param {import("../../types/kafkajs").IHeaders|null} kafkaJSHeaders
|
|
621
|
+
* @returns {import("../../").MessageHeader[]|null} the converted headers.
|
|
622
|
+
* @private
|
|
623
|
+
*/
|
|
624
|
+
function convertToRdKafkaHeaders(kafkaJSHeaders) {
|
|
625
|
+
if (!kafkaJSHeaders) return null;
|
|
626
|
+
|
|
627
|
+
const headers = [];
|
|
628
|
+
for (const [key, value] of Object.entries(kafkaJSHeaders)) {
|
|
629
|
+
if (value && value.constructor === Array) {
|
|
630
|
+
for (const v of value) {
|
|
631
|
+
const header = {};
|
|
632
|
+
header[key] = v;
|
|
633
|
+
headers.push(header);
|
|
634
|
+
}
|
|
635
|
+
} else {
|
|
636
|
+
const header = {};
|
|
637
|
+
header[key] = value;
|
|
638
|
+
headers.push(header);
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return headers;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
function notImplemented(msg = 'Not implemented') {
|
|
646
|
+
throw new error.KafkaJSError(msg, { code: error.ErrorCodes.ERR__NOT_IMPLEMENTED });
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* A promise that can be resolved externally.
|
|
651
|
+
* @private
|
|
652
|
+
*/
|
|
653
|
+
class DeferredPromise extends Promise{
|
|
654
|
+
#resolved = false;
|
|
655
|
+
|
|
656
|
+
/**
|
|
657
|
+
* JS expects a resolver function to be passed to classes extending Promise.
|
|
658
|
+
* that takes the same parameter a normal Promise constructor does.
|
|
659
|
+
* The DeferredPromise cannot be rejected to avoid unhandled rejections
|
|
660
|
+
* entirely.
|
|
661
|
+
* @param {(resolve: (value: any) => void, reject: (error: Error) => void) => void} resolver
|
|
662
|
+
*/
|
|
663
|
+
constructor(resolver) {
|
|
664
|
+
let resolveF;
|
|
665
|
+
super((resolve) => {
|
|
666
|
+
resolveF = resolve;
|
|
667
|
+
});
|
|
668
|
+
this.resolve = (...args) => {
|
|
669
|
+
this.#resolved = true;
|
|
670
|
+
resolveF(...args);
|
|
671
|
+
};
|
|
672
|
+
if (resolver)
|
|
673
|
+
resolver(this.resolve, () => {});
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
get resolved() {
|
|
677
|
+
return this.#resolved;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
/**
|
|
682
|
+
* Utility class for time related functions
|
|
683
|
+
* @private
|
|
684
|
+
*/
|
|
685
|
+
class Timer {
|
|
686
|
+
/**
|
|
687
|
+
* Function that resolves when the given timeout is reached
|
|
688
|
+
* or the passed promise resolves, when it's passed, clearing the timeout
|
|
689
|
+
* in any case.
|
|
690
|
+
*
|
|
691
|
+
* WARNING: it must be avoided to call `withTimeout` with the same promise
|
|
692
|
+
* more than once, as `Promise.race` will add more callbacks to it,
|
|
693
|
+
* creating a memory leak if the promise is never resolved or not resolved
|
|
694
|
+
* soon enough.
|
|
695
|
+
*
|
|
696
|
+
* @param {number} timeoutMs The timeout in milliseconds.
|
|
697
|
+
* @param {Promise|undefined} promise The promise to wait for,
|
|
698
|
+
* alternatively to the timeout, or `undefined` to just wait for the timeout.
|
|
699
|
+
*/
|
|
700
|
+
static async withTimeout(timeoutMs, promise) {
|
|
701
|
+
const timer = new DeferredPromise();
|
|
702
|
+
const registration = setTimeout(timer.resolve, timeoutMs);
|
|
703
|
+
if (!promise)
|
|
704
|
+
await timer;
|
|
705
|
+
else {
|
|
706
|
+
await Promise.race([
|
|
707
|
+
promise,
|
|
708
|
+
timer
|
|
709
|
+
]);
|
|
710
|
+
}
|
|
711
|
+
if (!timer.resolved) {
|
|
712
|
+
timer.resolve();
|
|
713
|
+
}
|
|
714
|
+
clearTimeout(registration);
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
/**
|
|
719
|
+
* Readers-writer lock with reentrant calls.
|
|
720
|
+
* Upgrading from a read to a write lock is supported.
|
|
721
|
+
* Acquiring a read lock while holding a write lock is a no-op.
|
|
722
|
+
* @private
|
|
723
|
+
*/
|
|
724
|
+
class Lock {
|
|
725
|
+
// Total number of readers, not increases when already holding a write lock
|
|
726
|
+
#readers = 0;
|
|
727
|
+
|
|
728
|
+
// Total number of writers, increased only by a single write and
|
|
729
|
+
// its reentrant calls
|
|
730
|
+
#writers = 0;
|
|
731
|
+
|
|
732
|
+
#asyncLocalStorage = new AsyncLocalStorage();
|
|
733
|
+
|
|
734
|
+
// Promise to resolve and recreate when there are no readers or writers
|
|
735
|
+
// This is used to notify all waiting writers so at least one can proceed.
|
|
736
|
+
// It's also used to notify all waiting readers so they can can check
|
|
737
|
+
// the writer has finished.
|
|
738
|
+
#zeroReadersAndWritersPromise = new DeferredPromise();
|
|
739
|
+
|
|
740
|
+
#notifyZeroReadersAndWriters() {
|
|
741
|
+
if (this.#readers === 0 && this.#writers === 0) {
|
|
742
|
+
this.#zeroReadersAndWritersPromise.resolve();
|
|
743
|
+
this.#zeroReadersAndWritersPromise = new DeferredPromise();
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
#createAsyncLocalStorageStore() {
|
|
748
|
+
return {
|
|
749
|
+
// All reentrant calls
|
|
750
|
+
stack: [],
|
|
751
|
+
// Number of write locks in reentrant calls
|
|
752
|
+
writers: 0,
|
|
753
|
+
// Number of read locks in reentrant calls
|
|
754
|
+
readers: 0,
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
async #runAsyncStack(type, f) {
|
|
759
|
+
let store = this.#asyncLocalStorage.getStore();
|
|
760
|
+
if (store) {
|
|
761
|
+
let promise = f();
|
|
762
|
+
store.stack.push(promise);
|
|
763
|
+
await promise;
|
|
764
|
+
} else {
|
|
765
|
+
await this.#asyncLocalStorage.run(this.#createAsyncLocalStorageStore(type),
|
|
766
|
+
async () => {
|
|
767
|
+
store = this.#asyncLocalStorage.getStore();
|
|
768
|
+
let promise = f();
|
|
769
|
+
store.stack.push(promise);
|
|
770
|
+
// Await all promises are settled
|
|
771
|
+
await Promise.allSettled(store.stack);
|
|
772
|
+
// Reject if any promise is rejected
|
|
773
|
+
await Promise.all(store.stack);
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
async #acquireRead() {
|
|
779
|
+
let store = this.#asyncLocalStorage.getStore();
|
|
780
|
+
if (!store.writers) {
|
|
781
|
+
while (this.#writers > 0) {
|
|
782
|
+
await this.#zeroReadersAndWritersPromise;
|
|
783
|
+
}
|
|
784
|
+
this.#readers++;
|
|
785
|
+
store.readers++;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
async #acquireWrite() {
|
|
790
|
+
let store = this.#asyncLocalStorage.getStore();
|
|
791
|
+
// We remove current stack readers and writers so it
|
|
792
|
+
// becomes reentrant
|
|
793
|
+
let readers = this.#readers - store.readers;
|
|
794
|
+
let writers = this.#writers - store.writers;
|
|
795
|
+
while (readers > 0 || writers > 0) {
|
|
796
|
+
await this.#zeroReadersAndWritersPromise;
|
|
797
|
+
writers = this.#writers - store.writers;
|
|
798
|
+
readers = this.#readers - store.readers;
|
|
799
|
+
}
|
|
800
|
+
this.#writers++;
|
|
801
|
+
store.writers++;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
async #releaseRead() {
|
|
805
|
+
let store = this.#asyncLocalStorage.getStore();
|
|
806
|
+
this.#readers--;
|
|
807
|
+
store.readers--;
|
|
808
|
+
this.#notifyZeroReadersAndWriters();
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
async #releaseWrite() {
|
|
812
|
+
let store = this.#asyncLocalStorage.getStore();
|
|
813
|
+
this.#writers--;
|
|
814
|
+
store.writers--;
|
|
815
|
+
this.#notifyZeroReadersAndWriters();
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Acquire a write (exclusive) lock while executing
|
|
820
|
+
* the given task.
|
|
821
|
+
* @param {function} task The task to execute.
|
|
822
|
+
* @returns {Promise} The result of the task.
|
|
823
|
+
*/
|
|
824
|
+
async write(task) {
|
|
825
|
+
let withWriteLock = async () => {
|
|
826
|
+
try {
|
|
827
|
+
await this.#acquireWrite();
|
|
828
|
+
return await task();
|
|
829
|
+
} finally {
|
|
830
|
+
await this.#releaseWrite();
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
await this.#runAsyncStack(1, withWriteLock);
|
|
834
|
+
}
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Acquire a read (shared) lock while executing
|
|
839
|
+
* the given task.
|
|
840
|
+
* @param {function} task The task to execute.
|
|
841
|
+
* @returns {Promise} The result of the task.
|
|
842
|
+
*/
|
|
843
|
+
async read(task) {
|
|
844
|
+
let withReadLock = async () => {
|
|
845
|
+
try {
|
|
846
|
+
await this.#acquireRead();
|
|
847
|
+
return await task();
|
|
848
|
+
} finally {
|
|
849
|
+
await this.#releaseRead();
|
|
850
|
+
}
|
|
851
|
+
};
|
|
852
|
+
await this.#runAsyncStack(0, withReadLock);
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
/**
|
|
857
|
+
* Creates a key for maps from a topicPartition object.
|
|
858
|
+
* @param {{topic: string, partition: number}} topicPartition Any object which can be treated as a topic partition.
|
|
859
|
+
* @returns {string} The created key.
|
|
860
|
+
* @private
|
|
861
|
+
*/
|
|
862
|
+
function partitionKey(topicPartition) {
|
|
863
|
+
return topicPartition.topic + '|'+ (topicPartition.partition);
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
module.exports = {
|
|
867
|
+
kafkaJSToRdKafkaConfig,
|
|
868
|
+
topicPartitionOffsetToRdKafka,
|
|
869
|
+
topicPartitionOffsetMetadataToRdKafka,
|
|
870
|
+
topicPartitionOffsetMetadataToKafkaJS,
|
|
871
|
+
createKafkaJsErrorFromLibRdKafkaError,
|
|
872
|
+
convertToRdKafkaHeaders,
|
|
873
|
+
createBindingMessageMetadata,
|
|
874
|
+
notImplemented,
|
|
875
|
+
logLevel: Object.freeze(logLevel),
|
|
876
|
+
loggerTrampoline,
|
|
877
|
+
DefaultLogger,
|
|
878
|
+
createReplacementErrorMessage,
|
|
879
|
+
CompatibilityErrorMessages,
|
|
880
|
+
severityToLogLevel,
|
|
881
|
+
checkAllowedKeys,
|
|
882
|
+
checkIfKafkaJsKeysPresent,
|
|
883
|
+
Lock,
|
|
884
|
+
DeferredPromise,
|
|
885
|
+
Timer,
|
|
886
|
+
partitionKey,
|
|
887
|
+
};
|