pulsar-client 1.7.0 → 1.8.0-rc1
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/.asf.yaml +8 -1
- package/.github/PULL_REQUEST_TEMPLATE.md +65 -0
- package/.github/workflows/ci-build-release-napi.yml +195 -0
- package/.github/workflows/ci-pr-validation.yml +225 -0
- package/README.md +83 -107
- package/binding.gyp +28 -44
- package/{pulsar-test-service-stop.sh → build-support/dep-version.py} +4 -6
- package/build-support/download-release-artifacts.py +74 -0
- package/build-support/generate-source-archive.sh +28 -0
- package/build-support/install-cpp-client.sh +66 -0
- package/{pulsar-test-service-start.sh → build-support/pulsar-test-container-start.sh} +11 -21
- package/build-support/pulsar-test-service-start.sh +37 -0
- package/build-support/pulsar-test-service-stop.sh +32 -0
- package/{.github/workflows/nodejs.yml → build-support/sign-files.sh} +13 -12
- package/build-support/stage-release.sh +44 -0
- package/dependencies.yaml +28 -0
- package/docs/release-process.md +242 -0
- package/examples/consumer.js +1 -1
- package/examples/consumer_listener.js +1 -1
- package/examples/consumer_tls_auth.js +1 -1
- package/examples/custom_logger.js +60 -0
- package/examples/encryption-consumer.js +1 -1
- package/examples/encryption-producer.js +1 -1
- package/examples/producer.js +1 -1
- package/examples/producer_tls_auth.js +1 -1
- package/examples/reader.js +1 -1
- package/examples/reader_listener.js +1 -1
- package/index.d.ts +7 -0
- package/index.js +2 -1
- package/package.json +15 -7
- package/pkg/build-napi-inside-docker.sh +31 -0
- package/pkg/linux_glibc/Dockerfile +33 -0
- package/pkg/linux_musl/Dockerfile +32 -0
- package/pkg/load_test.js +30 -0
- package/pkg/mac/build-cpp-deps-lib.sh +186 -0
- package/pkg/mac/build-cpp-lib.sh +51 -0
- package/pkg/mac/common.sh +37 -0
- package/pkg/windows/download-cpp-client.bat +12 -0
- package/pulsar-client-cpp.txt +2 -0
- package/src/AuthenticationAthenz.js +1 -1
- package/src/AuthenticationOauth2.js +1 -1
- package/src/AuthenticationTls.js +1 -1
- package/src/AuthenticationToken.js +1 -1
- package/src/Consumer.cc +72 -4
- package/src/Consumer.h +2 -0
- package/src/ConsumerConfig.cc +21 -0
- package/src/ProducerConfig.cc +6 -0
- package/src/Reader.cc +51 -1
- package/src/Reader.h +2 -0
- package/src/pulsar-binding.js +8 -0
- package/tests/conf/standalone.conf +6 -0
- package/tests/end_to_end.test.js +212 -0
- package/{docker-tests.sh → tests/run-unit-tests.sh} +10 -13
- package/pulsar-version.txt +0 -1
- package/run-unit-tests.sh +0 -44
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
|
4
|
+
# distributed with this work for additional information
|
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
|
7
|
+
# "License"); you may not use this file except in compliance
|
|
8
|
+
# with the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
|
13
|
+
# software distributed under the License is distributed on an
|
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
# KIND, either express or implied. See the License for the
|
|
16
|
+
# specific language governing permissions and limitations
|
|
17
|
+
# under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
ARG NODE_VERSION
|
|
21
|
+
|
|
22
|
+
FROM node:${NODE_VERSION}-alpine
|
|
23
|
+
|
|
24
|
+
RUN apk add \
|
|
25
|
+
bash \
|
|
26
|
+
curl \
|
|
27
|
+
python3 \
|
|
28
|
+
make \
|
|
29
|
+
g++ \
|
|
30
|
+
sudo
|
|
31
|
+
|
|
32
|
+
CMD ["sh"]
|
package/pkg/load_test.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
* or more contributor license agreements. See the NOTICE file
|
|
4
|
+
* distributed with this work for additional information
|
|
5
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
* to you under the Apache License, Version 2.0 (the
|
|
7
|
+
* "License"); you may not use this file except in compliance
|
|
8
|
+
* with the License. You may obtain a copy of the License at
|
|
9
|
+
*
|
|
10
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
*
|
|
12
|
+
* Unless required by applicable law or agreed to in writing,
|
|
13
|
+
* software distributed under the License is distributed on an
|
|
14
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
* KIND, either express or implied. See the License for the
|
|
16
|
+
* specific language governing permissions and limitations
|
|
17
|
+
* under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const Pulsar = require('../index.js');
|
|
21
|
+
|
|
22
|
+
(async () => {
|
|
23
|
+
// Create a client
|
|
24
|
+
const clientConfig = {
|
|
25
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const client = new Pulsar.Client(clientConfig);
|
|
29
|
+
await client.close();
|
|
30
|
+
})();
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
source $(dirname $0)/common.sh
|
|
22
|
+
|
|
23
|
+
cd $ROOT_DIR
|
|
24
|
+
|
|
25
|
+
pip3 install pyyaml
|
|
26
|
+
|
|
27
|
+
dep=$ROOT_DIR/build-support/dep-version.py
|
|
28
|
+
ZLIB_VERSION=$($dep zlib)
|
|
29
|
+
OPENSSL_VERSION=$($dep openssl)
|
|
30
|
+
BOOST_VERSION=$($dep boost)
|
|
31
|
+
PROTOBUF_VERSION=$($dep protobuf)
|
|
32
|
+
ZSTD_VERSION=$($dep zstd)
|
|
33
|
+
SNAPPY_VERSION=$($dep snappy)
|
|
34
|
+
CURL_VERSION=$($dep curl)
|
|
35
|
+
|
|
36
|
+
cd $MAC_BUILD_DIR/build
|
|
37
|
+
|
|
38
|
+
##############################################################################
|
|
39
|
+
if [ ! -f zlib-${ZLIB_VERSION}.done ]; then
|
|
40
|
+
echo "Building ZLib"
|
|
41
|
+
curl -O -L https://zlib.net/fossils/zlib-${ZLIB_VERSION}.tar.gz
|
|
42
|
+
tar xfz zlib-$ZLIB_VERSION.tar.gz
|
|
43
|
+
pushd zlib-$ZLIB_VERSION
|
|
44
|
+
CFLAGS="-fPIC -O3 -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" ./configure --prefix=$PREFIX
|
|
45
|
+
make -j16
|
|
46
|
+
make install
|
|
47
|
+
popd
|
|
48
|
+
|
|
49
|
+
rm -rf zlib-$ZLIB_VERSION.tar.gz zlib-$ZLIB_VERSION
|
|
50
|
+
touch zlib-${ZLIB_VERSION}.done
|
|
51
|
+
else
|
|
52
|
+
echo "Using cached ZLib"
|
|
53
|
+
fi
|
|
54
|
+
|
|
55
|
+
###############################################################################
|
|
56
|
+
OPENSSL_VERSION_UNDERSCORE=$(echo $OPENSSL_VERSION | sed 's/\./_/g')
|
|
57
|
+
if [ ! -f openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.done ]; then
|
|
58
|
+
echo "Building OpenSSL"
|
|
59
|
+
curl -O -L https://github.com/openssl/openssl/archive/OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz
|
|
60
|
+
tar xfz OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz
|
|
61
|
+
pushd openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}
|
|
62
|
+
if [ $ARCH = 'arm64' ]; then
|
|
63
|
+
PLATFORM=darwin64-arm64-cc
|
|
64
|
+
else
|
|
65
|
+
PLATFORM=darwin64-x86_64-cc
|
|
66
|
+
fi
|
|
67
|
+
./Configure --prefix=$PREFIX no-shared no-unit-test $PLATFORM
|
|
68
|
+
make -j8
|
|
69
|
+
make install_sw
|
|
70
|
+
popd
|
|
71
|
+
|
|
72
|
+
rm -rf OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.tar.gz openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}
|
|
73
|
+
touch openssl-OpenSSL_${OPENSSL_VERSION_UNDERSCORE}.done
|
|
74
|
+
else
|
|
75
|
+
echo "Using cached OpenSSL"
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
###############################################################################
|
|
79
|
+
BOOST_VERSION_=${BOOST_VERSION//./_}
|
|
80
|
+
DIR=boost-src-${BOOST_VERSION}
|
|
81
|
+
if [ ! -f $DIR.done ]; then
|
|
82
|
+
echo "Building Boost"
|
|
83
|
+
curl -O -L https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION}/source/boost_${BOOST_VERSION_}.tar.gz
|
|
84
|
+
tar xfz boost_${BOOST_VERSION_}.tar.gz
|
|
85
|
+
rm -rf $DIR
|
|
86
|
+
mv boost_${BOOST_VERSION_} $DIR
|
|
87
|
+
|
|
88
|
+
pushd $DIR
|
|
89
|
+
./bootstrap.sh --prefix=$PREFIX --with-libraries=system
|
|
90
|
+
./b2 address-model=64 cxxflags="-fPIC -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
91
|
+
link=static threading=multi \
|
|
92
|
+
variant=release \
|
|
93
|
+
install
|
|
94
|
+
popd
|
|
95
|
+
|
|
96
|
+
rm -rf $DIR boost_${BOOST_VERSION_}.tar.gz
|
|
97
|
+
touch $DIR.done
|
|
98
|
+
else
|
|
99
|
+
echo "Using cached Boost"
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
###############################################################################
|
|
103
|
+
if [ ! -f protobuf-${PROTOBUF_VERSION}.done ]; then
|
|
104
|
+
echo "Building Protobuf"
|
|
105
|
+
curl -O -L https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
|
|
106
|
+
tar xfz protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
|
|
107
|
+
pushd protobuf-${PROTOBUF_VERSION}
|
|
108
|
+
CXXFLAGS="-fPIC -arch arm64 -arch x86_64 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
109
|
+
./configure --prefix=$PREFIX
|
|
110
|
+
make -j16 V=1
|
|
111
|
+
make install
|
|
112
|
+
popd
|
|
113
|
+
|
|
114
|
+
pushd install/lib
|
|
115
|
+
echo "Propose target arch static lib" ${ARCH}
|
|
116
|
+
mv libprotobuf.a libprotobuf_universal.a
|
|
117
|
+
lipo libprotobuf_universal.a -thin ${ARCH} -output libprotobuf.a
|
|
118
|
+
popd
|
|
119
|
+
|
|
120
|
+
rm -rf protobuf-${PROTOBUF_VERSION} protobuf-cpp-${PROTOBUF_VERSION}.tar.gz
|
|
121
|
+
touch protobuf-${PROTOBUF_VERSION}.done
|
|
122
|
+
else
|
|
123
|
+
echo "Using cached Protobuf"
|
|
124
|
+
fi
|
|
125
|
+
|
|
126
|
+
###############################################################################
|
|
127
|
+
if [ ! -f zstd-${ZSTD_VERSION}.done ]; then
|
|
128
|
+
echo "Building ZStd"
|
|
129
|
+
curl -O -L https://github.com/facebook/zstd/releases/download/v${ZSTD_VERSION}/zstd-${ZSTD_VERSION}.tar.gz
|
|
130
|
+
tar xfz zstd-${ZSTD_VERSION}.tar.gz
|
|
131
|
+
pushd zstd-${ZSTD_VERSION}
|
|
132
|
+
CFLAGS="-fPIC -O3 -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
133
|
+
PREFIX=$PREFIX \
|
|
134
|
+
make -j16 -C lib install
|
|
135
|
+
popd
|
|
136
|
+
|
|
137
|
+
rm -rf zstd-${ZSTD_VERSION} zstd-${ZSTD_VERSION}.tar.gz
|
|
138
|
+
touch zstd-${ZSTD_VERSION}.done
|
|
139
|
+
else
|
|
140
|
+
echo "Using cached ZStd"
|
|
141
|
+
fi
|
|
142
|
+
|
|
143
|
+
###############################################################################
|
|
144
|
+
if [ ! -f snappy-${SNAPPY_VERSION}.done ]; then
|
|
145
|
+
echo "Building Snappy"
|
|
146
|
+
curl -O -L https://github.com/google/snappy/archive/refs/tags/${SNAPPY_VERSION}.tar.gz
|
|
147
|
+
tar xfz ${SNAPPY_VERSION}.tar.gz
|
|
148
|
+
pushd snappy-${SNAPPY_VERSION}
|
|
149
|
+
CXXFLAGS="-fPIC -O3 -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
150
|
+
cmake . -DCMAKE_OSX_ARCHITECTURES=${ARCH} -DCMAKE_INSTALL_PREFIX=$PREFIX -DSNAPPY_BUILD_TESTS=OFF -DSNAPPY_BUILD_BENCHMARKS=OFF
|
|
151
|
+
make -j16
|
|
152
|
+
make install
|
|
153
|
+
touch .done
|
|
154
|
+
popd
|
|
155
|
+
|
|
156
|
+
rm -rf snappy-${SNAPPY_VERSION} ${SNAPPY_VERSION}.tar.gz
|
|
157
|
+
touch snappy-${SNAPPY_VERSION}.done
|
|
158
|
+
else
|
|
159
|
+
echo "Using cached Snappy"
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
###############################################################################
|
|
163
|
+
if [ ! -f curl-${CURL_VERSION}.done ]; then
|
|
164
|
+
echo "Building LibCurl"
|
|
165
|
+
CURL_VERSION_=${CURL_VERSION//./_}
|
|
166
|
+
curl -O -L https://github.com/curl/curl/releases/download/curl-${CURL_VERSION_}/curl-${CURL_VERSION}.tar.gz
|
|
167
|
+
tar xfz curl-${CURL_VERSION}.tar.gz
|
|
168
|
+
pushd curl-${CURL_VERSION}
|
|
169
|
+
CFLAGS="-fPIC -arch ${ARCH} -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}" \
|
|
170
|
+
./configure --with-ssl=$PREFIX \
|
|
171
|
+
--without-nghttp2 \
|
|
172
|
+
--without-libidn2 \
|
|
173
|
+
--disable-ldap \
|
|
174
|
+
--without-brotli \
|
|
175
|
+
--without-secure-transport \
|
|
176
|
+
--disable-ipv6 \
|
|
177
|
+
--prefix=$PREFIX \
|
|
178
|
+
--host=$ARCH-apple-darwin
|
|
179
|
+
make -j16 install
|
|
180
|
+
popd
|
|
181
|
+
|
|
182
|
+
rm -rf curl-${CURL_VERSION} curl-${CURL_VERSION}.tar.gz
|
|
183
|
+
touch curl-${CURL_VERSION}.done
|
|
184
|
+
else
|
|
185
|
+
echo "Using cached LibCurl"
|
|
186
|
+
fi
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
#
|
|
3
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
#
|
|
20
|
+
|
|
21
|
+
source $(dirname $0)/common.sh
|
|
22
|
+
|
|
23
|
+
PULSAR_DIR=${MAC_BUILD_DIR}/build-pulsar
|
|
24
|
+
PULSAR_PREFIX=${PULSAR_DIR}/install
|
|
25
|
+
mkdir -p $PULSAR_PREFIX
|
|
26
|
+
cd $PULSAR_DIR
|
|
27
|
+
|
|
28
|
+
## Fetch from official release
|
|
29
|
+
curl -O -L "$CPP_CLIENT_BASE_URL"/apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz
|
|
30
|
+
tar xfz apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz
|
|
31
|
+
pushd apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}
|
|
32
|
+
rm -f CMakeCache.txt
|
|
33
|
+
cmake . \
|
|
34
|
+
-DCMAKE_OSX_ARCHITECTURES=${ARCH} \
|
|
35
|
+
-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET} \
|
|
36
|
+
-DCMAKE_INSTALL_PREFIX=$PULSAR_PREFIX \
|
|
37
|
+
-DCMAKE_BUILD_TYPE=Release \
|
|
38
|
+
-DCMAKE_PREFIX_PATH=$PREFIX \
|
|
39
|
+
-DCMAKE_INSTALL_LIBDIR=$PULSAR_PREFIX/lib \
|
|
40
|
+
-DLINK_STATIC=ON \
|
|
41
|
+
-DBUILD_TESTS=OFF \
|
|
42
|
+
-DBUILD_PYTHON_WRAPPER=OFF \
|
|
43
|
+
-DBUILD_DYNAMIC_LIB=OFF \
|
|
44
|
+
-DPROTOC_PATH=$PREFIX/bin/protoc
|
|
45
|
+
make -j16 install
|
|
46
|
+
mkdir -p $ROOT_DIR/pkg/lib/
|
|
47
|
+
cp -r lib/libpulsarwithdeps.a $ROOT_DIR/pkg/lib/
|
|
48
|
+
popd
|
|
49
|
+
|
|
50
|
+
rm -rf apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}
|
|
51
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
|
4
|
+
# distributed with this work for additional information
|
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
|
7
|
+
# "License"); you may not use this file except in compliance
|
|
8
|
+
# with the License. You may obtain a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
|
13
|
+
# software distributed under the License is distributed on an
|
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
# KIND, either express or implied. See the License for the
|
|
16
|
+
# specific language governing permissions and limitations
|
|
17
|
+
# under the License.
|
|
18
|
+
#
|
|
19
|
+
|
|
20
|
+
set -e -x
|
|
21
|
+
|
|
22
|
+
if [ -z "$ARCH" ]; then
|
|
23
|
+
export ARCH=$(uname -m)
|
|
24
|
+
fi
|
|
25
|
+
|
|
26
|
+
export MACOSX_DEPLOYMENT_TARGET=11.0
|
|
27
|
+
|
|
28
|
+
MAC_BUILD_DIR=`cd $(dirname $0); pwd`
|
|
29
|
+
ROOT_DIR=$(git rev-parse --show-toplevel)
|
|
30
|
+
source $ROOT_DIR/pulsar-client-cpp.txt
|
|
31
|
+
|
|
32
|
+
cd $MAC_BUILD_DIR
|
|
33
|
+
mkdir -p build
|
|
34
|
+
cd build
|
|
35
|
+
mkdir -p install
|
|
36
|
+
export PREFIX=`pwd`/install
|
|
37
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cd %~dp0
|
|
2
|
+
set arch=%1
|
|
3
|
+
if "%arch%" == "" (
|
|
4
|
+
reg Query "HKLM\Hardware\Description\System\CentralProcessor\0" | find /i "x86" > NUL && set arch=x86 || set arch=x64
|
|
5
|
+
)
|
|
6
|
+
for /F "delims== tokens=1,2" %%a in (..\..\pulsar-client-cpp.txt) do set "%%a=%%b"
|
|
7
|
+
curl -O -L %CPP_CLIENT_BASE_URL%/%arch%-windows-static.tar.gz
|
|
8
|
+
tar -xvzf %arch%-windows-static.tar.gz
|
|
9
|
+
move %arch%-windows-static pulsar-cpp
|
|
10
|
+
dir
|
|
11
|
+
|
|
12
|
+
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* specific language governing permissions and limitations
|
|
17
17
|
* under the License.
|
|
18
18
|
*/
|
|
19
|
-
const PulsarBinding = require('
|
|
19
|
+
const PulsarBinding = require('./pulsar-binding');
|
|
20
20
|
|
|
21
21
|
class AuthenticationOauth2 {
|
|
22
22
|
constructor(params) {
|
package/src/AuthenticationTls.js
CHANGED
package/src/Consumer.cc
CHANGED
|
@@ -41,6 +41,8 @@ void Consumer::Init(Napi::Env env, Napi::Object exports) {
|
|
|
41
41
|
InstanceMethod("negativeAcknowledgeId", &Consumer::NegativeAcknowledgeId),
|
|
42
42
|
InstanceMethod("acknowledgeCumulative", &Consumer::AcknowledgeCumulative),
|
|
43
43
|
InstanceMethod("acknowledgeCumulativeId", &Consumer::AcknowledgeCumulativeId),
|
|
44
|
+
InstanceMethod("seek", &Consumer::Seek),
|
|
45
|
+
InstanceMethod("seekTimestamp", &Consumer::SeekTimestamp),
|
|
44
46
|
InstanceMethod("isConnected", &Consumer::IsConnected),
|
|
45
47
|
InstanceMethod("close", &Consumer::Close),
|
|
46
48
|
InstanceMethod("unsubscribe", &Consumer::Unsubscribe),
|
|
@@ -245,16 +247,35 @@ class ConsumerReceiveWorker : public Napi::AsyncWorker {
|
|
|
245
247
|
};
|
|
246
248
|
|
|
247
249
|
Napi::Value Consumer::Receive(const Napi::CallbackInfo &info) {
|
|
248
|
-
Napi::Promise::Deferred deferred = Napi::Promise::Deferred::New(info.Env());
|
|
249
250
|
if (info[0].IsUndefined()) {
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
auto deferred = ThreadSafeDeferred::New(Env());
|
|
252
|
+
auto ctx = new ExtDeferredContext(deferred);
|
|
253
|
+
pulsar_consumer_receive_async(
|
|
254
|
+
this->cConsumer.get(),
|
|
255
|
+
[](pulsar_result result, pulsar_message_t *rawMessage, void *ctx) {
|
|
256
|
+
auto deferredContext = static_cast<ExtDeferredContext *>(ctx);
|
|
257
|
+
auto deferred = deferredContext->deferred;
|
|
258
|
+
delete deferredContext;
|
|
259
|
+
|
|
260
|
+
if (result != pulsar_result_Ok) {
|
|
261
|
+
deferred->Reject(std::string("Failed to receive message: ") + pulsar_result_str(result));
|
|
262
|
+
} else {
|
|
263
|
+
deferred->Resolve([rawMessage](const Napi::Env env) {
|
|
264
|
+
Napi::Object obj = Message::NewInstance(
|
|
265
|
+
{}, std::shared_ptr<pulsar_message_t>(rawMessage, pulsar_message_free));
|
|
266
|
+
return obj;
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
ctx);
|
|
271
|
+
return deferred->Promise();
|
|
252
272
|
} else {
|
|
273
|
+
Napi::Promise::Deferred deferred = Napi::Promise::Deferred::New(info.Env());
|
|
253
274
|
Napi::Number timeout = info[0].As<Napi::Object>().ToNumber();
|
|
254
275
|
ConsumerReceiveWorker *wk = new ConsumerReceiveWorker(deferred, this->cConsumer, timeout.Int64Value());
|
|
255
276
|
wk->Queue();
|
|
277
|
+
return deferred.Promise();
|
|
256
278
|
}
|
|
257
|
-
return deferred.Promise();
|
|
258
279
|
}
|
|
259
280
|
|
|
260
281
|
Napi::Value Consumer::Acknowledge(const Napi::CallbackInfo &info) {
|
|
@@ -368,6 +389,53 @@ Napi::Value Consumer::AcknowledgeCumulativeId(const Napi::CallbackInfo &info) {
|
|
|
368
389
|
return deferred->Promise();
|
|
369
390
|
}
|
|
370
391
|
|
|
392
|
+
Napi::Value Consumer::Seek(const Napi::CallbackInfo &info) {
|
|
393
|
+
auto obj = info[0].As<Napi::Object>();
|
|
394
|
+
auto *msgId = MessageId::Unwrap(obj);
|
|
395
|
+
auto deferred = ThreadSafeDeferred::New(Env());
|
|
396
|
+
auto ctx = new ExtDeferredContext(deferred);
|
|
397
|
+
|
|
398
|
+
pulsar_consumer_seek_async(
|
|
399
|
+
this->cConsumer.get(), msgId->GetCMessageId().get(),
|
|
400
|
+
[](pulsar_result result, void *ctx) {
|
|
401
|
+
auto deferredContext = static_cast<ExtDeferredContext *>(ctx);
|
|
402
|
+
auto deferred = deferredContext->deferred;
|
|
403
|
+
delete deferredContext;
|
|
404
|
+
|
|
405
|
+
if (result != pulsar_result_Ok) {
|
|
406
|
+
deferred->Reject(std::string("Failed to seek message by id: ") + pulsar_result_str(result));
|
|
407
|
+
} else {
|
|
408
|
+
deferred->Resolve(THREADSAFE_DEFERRED_RESOLVER(env.Null()));
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
ctx);
|
|
412
|
+
|
|
413
|
+
return deferred->Promise();
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
Napi::Value Consumer::SeekTimestamp(const Napi::CallbackInfo &info) {
|
|
417
|
+
Napi::Number timestamp = info[0].As<Napi::Object>().ToNumber();
|
|
418
|
+
auto deferred = ThreadSafeDeferred::New(Env());
|
|
419
|
+
auto ctx = new ExtDeferredContext(deferred);
|
|
420
|
+
|
|
421
|
+
pulsar_consumer_seek_by_timestamp_async(
|
|
422
|
+
this->cConsumer.get(), timestamp.Int64Value(),
|
|
423
|
+
[](pulsar_result result, void *ctx) {
|
|
424
|
+
auto deferredContext = static_cast<ExtDeferredContext *>(ctx);
|
|
425
|
+
auto deferred = deferredContext->deferred;
|
|
426
|
+
delete deferredContext;
|
|
427
|
+
|
|
428
|
+
if (result != pulsar_result_Ok) {
|
|
429
|
+
deferred->Reject(std::string("Failed to seek message by timestamp: ") + pulsar_result_str(result));
|
|
430
|
+
} else {
|
|
431
|
+
deferred->Resolve(THREADSAFE_DEFERRED_RESOLVER(env.Null()));
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
ctx);
|
|
435
|
+
|
|
436
|
+
return deferred->Promise();
|
|
437
|
+
}
|
|
438
|
+
|
|
371
439
|
Napi::Value Consumer::IsConnected(const Napi::CallbackInfo &info) {
|
|
372
440
|
Napi::Env env = info.Env();
|
|
373
441
|
return Napi::Boolean::New(env, pulsar_consumer_is_connected(this->cConsumer.get()));
|
package/src/Consumer.h
CHANGED
|
@@ -48,6 +48,8 @@ class Consumer : public Napi::ObjectWrap<Consumer> {
|
|
|
48
48
|
void NegativeAcknowledgeId(const Napi::CallbackInfo &info);
|
|
49
49
|
Napi::Value AcknowledgeCumulative(const Napi::CallbackInfo &info);
|
|
50
50
|
Napi::Value AcknowledgeCumulativeId(const Napi::CallbackInfo &info);
|
|
51
|
+
Napi::Value Seek(const Napi::CallbackInfo &info);
|
|
52
|
+
Napi::Value SeekTimestamp(const Napi::CallbackInfo &info);
|
|
51
53
|
Napi::Value IsConnected(const Napi::CallbackInfo &info);
|
|
52
54
|
Napi::Value Close(const Napi::CallbackInfo &info);
|
|
53
55
|
Napi::Value Unsubscribe(const Napi::CallbackInfo &info);
|
package/src/ConsumerConfig.cc
CHANGED
|
@@ -42,6 +42,9 @@ static const std::string CFG_READ_COMPACTED = "readCompacted";
|
|
|
42
42
|
static const std::string CFG_SCHEMA = "schema";
|
|
43
43
|
static const std::string CFG_PRIVATE_KEY_PATH = "privateKeyPath";
|
|
44
44
|
static const std::string CFG_CRYPTO_FAILURE_ACTION = "cryptoFailureAction";
|
|
45
|
+
static const std::string CFG_MAX_PENDING_CHUNKED_MESSAGE = "maxPendingChunkedMessage";
|
|
46
|
+
static const std::string CFG_AUTO_ACK_OLDEST_CHUNKED_MESSAGE_ON_QUEUE_FULL =
|
|
47
|
+
"autoAckOldestChunkedMessageOnQueueFull";
|
|
45
48
|
|
|
46
49
|
static const std::map<std::string, pulsar_consumer_type> SUBSCRIPTION_TYPE = {
|
|
47
50
|
{"Exclusive", pulsar_ConsumerExclusive},
|
|
@@ -194,6 +197,24 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig, pulsar_messag
|
|
|
194
197
|
}
|
|
195
198
|
}
|
|
196
199
|
}
|
|
200
|
+
|
|
201
|
+
if (consumerConfig.Has(CFG_MAX_PENDING_CHUNKED_MESSAGE) &&
|
|
202
|
+
consumerConfig.Get(CFG_MAX_PENDING_CHUNKED_MESSAGE).IsNumber()) {
|
|
203
|
+
int32_t maxPendingChunkedMessage =
|
|
204
|
+
consumerConfig.Get(CFG_MAX_PENDING_CHUNKED_MESSAGE).ToNumber().Int32Value();
|
|
205
|
+
if (maxPendingChunkedMessage >= 0) {
|
|
206
|
+
pulsar_consumer_configuration_set_max_pending_chunked_message(this->cConsumerConfig.get(),
|
|
207
|
+
maxPendingChunkedMessage);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (consumerConfig.Has(CFG_AUTO_ACK_OLDEST_CHUNKED_MESSAGE_ON_QUEUE_FULL) &&
|
|
212
|
+
consumerConfig.Get(CFG_AUTO_ACK_OLDEST_CHUNKED_MESSAGE_ON_QUEUE_FULL).IsBoolean()) {
|
|
213
|
+
bool autoAckOldestChunkedMessageOnQueueFull =
|
|
214
|
+
consumerConfig.Get(CFG_AUTO_ACK_OLDEST_CHUNKED_MESSAGE_ON_QUEUE_FULL).ToBoolean();
|
|
215
|
+
pulsar_consumer_configuration_set_auto_ack_oldest_chunked_message_on_queue_full(
|
|
216
|
+
this->cConsumerConfig.get(), autoAckOldestChunkedMessageOnQueueFull);
|
|
217
|
+
}
|
|
197
218
|
}
|
|
198
219
|
|
|
199
220
|
ConsumerConfig::~ConsumerConfig() {
|
package/src/ProducerConfig.cc
CHANGED
|
@@ -38,6 +38,7 @@ static const std::string CFG_PROPS = "properties";
|
|
|
38
38
|
static const std::string CFG_PUBLIC_KEY_PATH = "publicKeyPath";
|
|
39
39
|
static const std::string CFG_ENCRYPTION_KEY = "encryptionKey";
|
|
40
40
|
static const std::string CFG_CRYPTO_FAILURE_ACTION = "cryptoFailureAction";
|
|
41
|
+
static const std::string CFG_CHUNK_ENABLED = "chunkingEnabled";
|
|
41
42
|
|
|
42
43
|
static const std::map<std::string, pulsar_partitions_routing_mode> MESSAGE_ROUTING_MODE = {
|
|
43
44
|
{"UseSinglePartition", pulsar_UseSinglePartition},
|
|
@@ -188,6 +189,11 @@ ProducerConfig::ProducerConfig(const Napi::Object& producerConfig) : topic("") {
|
|
|
188
189
|
this->cProducerConfig.get(), PRODUCER_CRYPTO_FAILURE_ACTION.at(cryptoFailureAction));
|
|
189
190
|
}
|
|
190
191
|
}
|
|
192
|
+
|
|
193
|
+
if (producerConfig.Has(CFG_CHUNK_ENABLED) && producerConfig.Get(CFG_CHUNK_ENABLED).IsBoolean()) {
|
|
194
|
+
bool chunkingEnabled = producerConfig.Get(CFG_CHUNK_ENABLED).ToBoolean().Value();
|
|
195
|
+
pulsar_producer_configuration_set_chunking_enabled(this->cProducerConfig.get(), chunkingEnabled);
|
|
196
|
+
}
|
|
191
197
|
}
|
|
192
198
|
|
|
193
199
|
ProducerConfig::~ProducerConfig() {}
|
package/src/Reader.cc
CHANGED
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
#include "Message.h"
|
|
21
21
|
#include "Reader.h"
|
|
22
22
|
#include "ReaderConfig.h"
|
|
23
|
+
#include "MessageId.h"
|
|
23
24
|
#include "ThreadSafeDeferred.h"
|
|
24
25
|
#include <pulsar/c/result.h>
|
|
25
26
|
#include <pulsar/c/reader.h>
|
|
@@ -36,6 +37,8 @@ void Reader::Init(Napi::Env env, Napi::Object exports) {
|
|
|
36
37
|
InstanceMethod("readNext", &Reader::ReadNext),
|
|
37
38
|
InstanceMethod("hasNext", &Reader::HasNext),
|
|
38
39
|
InstanceMethod("isConnected", &Reader::IsConnected),
|
|
40
|
+
InstanceMethod("seek", &Reader::Seek),
|
|
41
|
+
InstanceMethod("seekTimestamp", &Reader::SeekTimestamp),
|
|
39
42
|
InstanceMethod("close", &Reader::Close),
|
|
40
43
|
});
|
|
41
44
|
|
|
@@ -165,7 +168,7 @@ class ReaderReadNextWorker : public Napi::AsyncWorker {
|
|
|
165
168
|
result = pulsar_reader_read_next(this->cReader.get(), &rawMessage);
|
|
166
169
|
}
|
|
167
170
|
if (result != pulsar_result_Ok) {
|
|
168
|
-
SetError(std::string("Failed to
|
|
171
|
+
SetError(std::string("Failed to receive message: ") + pulsar_result_str(result));
|
|
169
172
|
}
|
|
170
173
|
this->cMessage = std::shared_ptr<pulsar_message_t>(rawMessage, pulsar_message_free);
|
|
171
174
|
}
|
|
@@ -213,6 +216,53 @@ Napi::Value Reader::IsConnected(const Napi::CallbackInfo &info) {
|
|
|
213
216
|
return Napi::Boolean::New(env, pulsar_reader_is_connected(this->cReader.get()));
|
|
214
217
|
}
|
|
215
218
|
|
|
219
|
+
Napi::Value Reader::Seek(const Napi::CallbackInfo &info) {
|
|
220
|
+
auto obj = info[0].As<Napi::Object>();
|
|
221
|
+
auto *msgId = MessageId::Unwrap(obj);
|
|
222
|
+
auto deferred = ThreadSafeDeferred::New(Env());
|
|
223
|
+
auto ctx = new ExtDeferredContext(deferred);
|
|
224
|
+
|
|
225
|
+
pulsar_reader_seek_async(
|
|
226
|
+
this->cReader.get(), msgId->GetCMessageId().get(),
|
|
227
|
+
[](pulsar_result result, void *ctx) {
|
|
228
|
+
auto deferredContext = static_cast<ExtDeferredContext *>(ctx);
|
|
229
|
+
auto deferred = deferredContext->deferred;
|
|
230
|
+
delete deferredContext;
|
|
231
|
+
|
|
232
|
+
if (result != pulsar_result_Ok) {
|
|
233
|
+
deferred->Reject(std::string("Failed to seek message by id: ") + pulsar_result_str(result));
|
|
234
|
+
} else {
|
|
235
|
+
deferred->Resolve(THREADSAFE_DEFERRED_RESOLVER(env.Null()));
|
|
236
|
+
}
|
|
237
|
+
},
|
|
238
|
+
ctx);
|
|
239
|
+
|
|
240
|
+
return deferred->Promise();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
Napi::Value Reader::SeekTimestamp(const Napi::CallbackInfo &info) {
|
|
244
|
+
Napi::Number timestamp = info[0].As<Napi::Object>().ToNumber();
|
|
245
|
+
auto deferred = ThreadSafeDeferred::New(Env());
|
|
246
|
+
auto ctx = new ExtDeferredContext(deferred);
|
|
247
|
+
|
|
248
|
+
pulsar_reader_seek_by_timestamp_async(
|
|
249
|
+
this->cReader.get(), timestamp.Int64Value(),
|
|
250
|
+
[](pulsar_result result, void *ctx) {
|
|
251
|
+
auto deferredContext = static_cast<ExtDeferredContext *>(ctx);
|
|
252
|
+
auto deferred = deferredContext->deferred;
|
|
253
|
+
delete deferredContext;
|
|
254
|
+
|
|
255
|
+
if (result != pulsar_result_Ok) {
|
|
256
|
+
deferred->Reject(std::string("Failed to seek message by timestamp: ") + pulsar_result_str(result));
|
|
257
|
+
} else {
|
|
258
|
+
deferred->Resolve(THREADSAFE_DEFERRED_RESOLVER(env.Null()));
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
ctx);
|
|
262
|
+
|
|
263
|
+
return deferred->Promise();
|
|
264
|
+
}
|
|
265
|
+
|
|
216
266
|
Napi::Value Reader::Close(const Napi::CallbackInfo &info) {
|
|
217
267
|
auto deferred = ThreadSafeDeferred::New(Env());
|
|
218
268
|
auto ctx = new ExtDeferredContext(deferred);
|
package/src/Reader.h
CHANGED
|
@@ -42,6 +42,8 @@ class Reader : public Napi::ObjectWrap<Reader> {
|
|
|
42
42
|
Napi::Value ReadNext(const Napi::CallbackInfo &info);
|
|
43
43
|
Napi::Value HasNext(const Napi::CallbackInfo &info);
|
|
44
44
|
Napi::Value IsConnected(const Napi::CallbackInfo &info);
|
|
45
|
+
Napi::Value Seek(const Napi::CallbackInfo &info);
|
|
46
|
+
Napi::Value SeekTimestamp(const Napi::CallbackInfo &info);
|
|
45
47
|
Napi::Value Close(const Napi::CallbackInfo &info);
|
|
46
48
|
void CleanupListener();
|
|
47
49
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const binary = require('@mapbox/node-pre-gyp');
|
|
3
|
+
|
|
4
|
+
const bindingPath = binary.find(path.resolve(path.join(__dirname, '../package.json')));
|
|
5
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
6
|
+
const binding = require(bindingPath);
|
|
7
|
+
// eslint-disable-next-line no-multi-assign
|
|
8
|
+
module.exports = exports = binding;
|
|
@@ -275,3 +275,9 @@ keepAliveIntervalSeconds=30
|
|
|
275
275
|
|
|
276
276
|
# How often broker checks for inactive topics to be deleted (topics with no subscriptions and no one connected)
|
|
277
277
|
brokerServicePurgeInactiveFrequencyInSeconds=60
|
|
278
|
+
|
|
279
|
+
### --- BookKeeper Configuration --- #####
|
|
280
|
+
|
|
281
|
+
# The maximum netty frame size in bytes. Any message received larger than this will be rejected. The default value is 5MB.
|
|
282
|
+
nettyMaxFrameSizeBytes=5253120
|
|
283
|
+
|