pulsar-client 1.7.0 → 1.8.0-rc.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/.asf.yaml +8 -1
- package/.github/PULL_REQUEST_TEMPLATE.md +85 -0
- package/.github/workflows/ci-build-release-napi.yml +213 -0
- package/.github/workflows/ci-pr-validation.yml +233 -0
- package/README.md +86 -106
- package/binding.gyp +34 -43
- 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/{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 +271 -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 +17 -8
- package/pkg/linux/Dockerfile_linux_glibc +35 -0
- package/pkg/linux/Dockerfile_linux_musl +32 -0
- package/pkg/linux/build-napi-inside-docker.sh +31 -0
- package/pkg/linux/download-cpp-client.sh +65 -0
- package/pkg/load_test.js +34 -0
- package/pkg/mac/build-cpp-deps-lib.sh +186 -0
- package/pkg/mac/build-cpp-lib.sh +48 -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 +26 -0
- package/tests/conf/standalone.conf +6 -0
- package/tests/docker-load-test.sh +35 -0
- package/tests/end_to_end.test.js +212 -0
- package/{run-unit-tests.sh → tests/load-test.sh} +18 -19
- package/{docker-tests.sh → tests/run-unit-tests.sh} +10 -13
- package/pulsar-version.txt +0 -1
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,26 @@
|
|
|
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
|
+
const path = require('path');
|
|
20
|
+
const binary = require('@mapbox/node-pre-gyp');
|
|
21
|
+
|
|
22
|
+
const bindingPath = binary.find(path.resolve(path.join(__dirname, '../package.json')));
|
|
23
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
24
|
+
const binding = require(bindingPath);
|
|
25
|
+
// eslint-disable-next-line no-multi-assign
|
|
26
|
+
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
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/bin/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
|
+
# NOTE: This script should only run inside a Node.js docker container.
|
|
22
|
+
# See ./load-test.sh for details.
|
|
23
|
+
set -ex
|
|
24
|
+
|
|
25
|
+
# Create an empty directory to test
|
|
26
|
+
mkdir -p /app && cd /app
|
|
27
|
+
tar zxf /pulsar-client-node/pulsar-client-node.tar.gz
|
|
28
|
+
|
|
29
|
+
# Use the existing Pulsar.node built in a specific container
|
|
30
|
+
mkdir -p lib/binding
|
|
31
|
+
cp /pulsar-client-node/build/Release/pulsar.node lib/binding/
|
|
32
|
+
npm install
|
|
33
|
+
|
|
34
|
+
# Test if Pulsar.node can be loaded
|
|
35
|
+
node pkg/load_test.js
|
package/tests/end_to_end.test.js
CHANGED
|
@@ -847,5 +847,217 @@ const Pulsar = require('../index.js');
|
|
|
847
847
|
|
|
848
848
|
await client.close();
|
|
849
849
|
});
|
|
850
|
+
|
|
851
|
+
test('Consumer seek by message Id', async () => {
|
|
852
|
+
const client = new Pulsar.Client({
|
|
853
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
854
|
+
operationTimeoutSeconds: 30,
|
|
855
|
+
});
|
|
856
|
+
|
|
857
|
+
const topic = 'persistent://public/default/seek-by-msgid';
|
|
858
|
+
const producer = await client.createProducer({
|
|
859
|
+
topic,
|
|
860
|
+
sendTimeoutMs: 30000,
|
|
861
|
+
batchingEnabled: false,
|
|
862
|
+
});
|
|
863
|
+
expect(producer).not.toBeNull();
|
|
864
|
+
|
|
865
|
+
const msgIds = [];
|
|
866
|
+
for (let i = 0; i < 10; i += 1) {
|
|
867
|
+
const msg = `my-message-${i}`;
|
|
868
|
+
console.log(msg);
|
|
869
|
+
const msgId = await producer.send({
|
|
870
|
+
data: Buffer.from(msg),
|
|
871
|
+
});
|
|
872
|
+
msgIds.push(msgId);
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
const consumer = await client.subscribe({
|
|
876
|
+
topic,
|
|
877
|
+
subscription: 'sub',
|
|
878
|
+
});
|
|
879
|
+
expect(consumer).not.toBeNull();
|
|
880
|
+
|
|
881
|
+
await consumer.seek(msgIds[5]);
|
|
882
|
+
const msg = consumer.receive(1000);
|
|
883
|
+
console.log((await msg).getMessageId().toString());
|
|
884
|
+
expect((await msg).getData().toString()).toBe('my-message-6');
|
|
885
|
+
|
|
886
|
+
await producer.close();
|
|
887
|
+
await consumer.close();
|
|
888
|
+
await client.close();
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
test('Consumer seek by timestamp', async () => {
|
|
892
|
+
const client = new Pulsar.Client({
|
|
893
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
894
|
+
operationTimeoutSeconds: 30,
|
|
895
|
+
});
|
|
896
|
+
|
|
897
|
+
const topic = 'persistent://public/default/seek-by-timestamp';
|
|
898
|
+
const producer = await client.createProducer({
|
|
899
|
+
topic,
|
|
900
|
+
sendTimeoutMs: 30000,
|
|
901
|
+
batchingEnabled: false,
|
|
902
|
+
});
|
|
903
|
+
expect(producer).not.toBeNull();
|
|
904
|
+
|
|
905
|
+
for (let i = 0; i < 10; i += 1) {
|
|
906
|
+
const msg = `my-message-${i}`;
|
|
907
|
+
console.log(msg);
|
|
908
|
+
await producer.send({
|
|
909
|
+
data: Buffer.from(msg),
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
const consumer = await client.subscribe({
|
|
914
|
+
topic,
|
|
915
|
+
subscription: 'sub',
|
|
916
|
+
});
|
|
917
|
+
expect(consumer).not.toBeNull();
|
|
918
|
+
|
|
919
|
+
const currentTime = Date.now();
|
|
920
|
+
console.log(currentTime);
|
|
921
|
+
|
|
922
|
+
await consumer.seekTimestamp(currentTime);
|
|
923
|
+
|
|
924
|
+
console.log('End seek');
|
|
925
|
+
|
|
926
|
+
await expect(consumer.receive(1000)).rejects.toThrow('Failed to receive message: TimeOut');
|
|
927
|
+
|
|
928
|
+
await consumer.seekTimestamp(currentTime - 100000);
|
|
929
|
+
|
|
930
|
+
const msg = consumer.receive(1000);
|
|
931
|
+
console.log((await msg).getMessageId().toString());
|
|
932
|
+
expect((await msg).getData().toString()).toBe('my-message-0');
|
|
933
|
+
|
|
934
|
+
await producer.close();
|
|
935
|
+
await consumer.close();
|
|
936
|
+
await client.close();
|
|
937
|
+
});
|
|
938
|
+
|
|
939
|
+
test('Reader seek by message Id', async () => {
|
|
940
|
+
const client = new Pulsar.Client({
|
|
941
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
942
|
+
operationTimeoutSeconds: 30,
|
|
943
|
+
});
|
|
944
|
+
|
|
945
|
+
const topic = 'persistent://public/default/reader-seek-by-msgid';
|
|
946
|
+
const producer = await client.createProducer({
|
|
947
|
+
topic,
|
|
948
|
+
sendTimeoutMs: 30000,
|
|
949
|
+
batchingEnabled: false,
|
|
950
|
+
});
|
|
951
|
+
expect(producer).not.toBeNull();
|
|
952
|
+
|
|
953
|
+
const msgIds = [];
|
|
954
|
+
for (let i = 0; i < 10; i += 1) {
|
|
955
|
+
const msg = `my-message-${i}`;
|
|
956
|
+
console.log(msg);
|
|
957
|
+
const msgId = await producer.send({
|
|
958
|
+
data: Buffer.from(msg),
|
|
959
|
+
});
|
|
960
|
+
msgIds.push(msgId);
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
const reader = await client.createReader({
|
|
964
|
+
topic,
|
|
965
|
+
startMessageId: Pulsar.MessageId.latest(),
|
|
966
|
+
});
|
|
967
|
+
expect(reader).not.toBeNull();
|
|
968
|
+
|
|
969
|
+
await reader.seek(msgIds[5]);
|
|
970
|
+
expect(reader.hasNext()).toBe(true);
|
|
971
|
+
const msg = reader.readNext(1000);
|
|
972
|
+
console.log((await msg).getMessageId().toString());
|
|
973
|
+
expect((await msg).getData().toString()).toBe('my-message-6');
|
|
974
|
+
|
|
975
|
+
await producer.close();
|
|
976
|
+
await reader.close();
|
|
977
|
+
await client.close();
|
|
978
|
+
});
|
|
979
|
+
|
|
980
|
+
test('Reader seek by timestamp', async () => {
|
|
981
|
+
const client = new Pulsar.Client({
|
|
982
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
983
|
+
operationTimeoutSeconds: 30,
|
|
984
|
+
});
|
|
985
|
+
|
|
986
|
+
const topic = 'persistent://public/default/reader-seek-timestamp';
|
|
987
|
+
const producer = await client.createProducer({
|
|
988
|
+
topic,
|
|
989
|
+
sendTimeoutMs: 30000,
|
|
990
|
+
batchingEnabled: false,
|
|
991
|
+
});
|
|
992
|
+
expect(producer).not.toBeNull();
|
|
993
|
+
|
|
994
|
+
for (let i = 0; i < 10; i += 1) {
|
|
995
|
+
const msg = `my-message-${i}`;
|
|
996
|
+
console.log(msg);
|
|
997
|
+
await producer.send({
|
|
998
|
+
data: Buffer.from(msg),
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
const reader = await client.createReader({
|
|
1003
|
+
topic,
|
|
1004
|
+
startMessageId: Pulsar.MessageId.latest(),
|
|
1005
|
+
});
|
|
1006
|
+
expect(reader).not.toBeNull();
|
|
1007
|
+
|
|
1008
|
+
const currentTime = Date.now();
|
|
1009
|
+
console.log(currentTime);
|
|
1010
|
+
|
|
1011
|
+
await reader.seekTimestamp(currentTime);
|
|
1012
|
+
|
|
1013
|
+
console.log('End seek');
|
|
1014
|
+
|
|
1015
|
+
expect(reader.hasNext()).toBe(false);
|
|
1016
|
+
|
|
1017
|
+
await reader.seekTimestamp(currentTime - 100000);
|
|
1018
|
+
console.log('Seek to previous time');
|
|
1019
|
+
|
|
1020
|
+
expect(reader.hasNext()).toBe(true);
|
|
1021
|
+
const msg = reader.readNext(1000);
|
|
1022
|
+
console.log((await msg).getMessageId().toString());
|
|
1023
|
+
expect((await msg).getData().toString()).toBe('my-message-0');
|
|
1024
|
+
|
|
1025
|
+
await producer.close();
|
|
1026
|
+
await reader.close();
|
|
1027
|
+
await client.close();
|
|
1028
|
+
});
|
|
1029
|
+
|
|
1030
|
+
test('Message chunking', async () => {
|
|
1031
|
+
const client = new Pulsar.Client({
|
|
1032
|
+
serviceUrl: 'pulsar://localhost:6650',
|
|
1033
|
+
operationTimeoutSeconds: 30,
|
|
1034
|
+
});
|
|
1035
|
+
|
|
1036
|
+
const topic = 'persistent://public/default/message-chunking';
|
|
1037
|
+
const producer = await client.createProducer({
|
|
1038
|
+
topic,
|
|
1039
|
+
batchingEnabled: false,
|
|
1040
|
+
chunkingEnabled: true,
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
const consumer = await client.subscribe({
|
|
1044
|
+
topic,
|
|
1045
|
+
subscription: 'sub',
|
|
1046
|
+
maxPendingChunkedMessage: 15,
|
|
1047
|
+
autoAckOldestChunkedMessageOnQueueFull: true,
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
const sendMsg = Buffer.alloc(10 * 1024 * 1024);
|
|
1051
|
+
|
|
1052
|
+
await producer.send({
|
|
1053
|
+
data: sendMsg,
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
const receiveMsg = await consumer.receive(3000);
|
|
1057
|
+
expect(receiveMsg.getData().length).toBe(sendMsg.length);
|
|
1058
|
+
await producer.close();
|
|
1059
|
+
await consumer.close();
|
|
1060
|
+
await client.close();
|
|
1061
|
+
});
|
|
850
1062
|
});
|
|
851
1063
|
})();
|
|
@@ -18,27 +18,26 @@
|
|
|
18
18
|
# under the License.
|
|
19
19
|
#
|
|
20
20
|
|
|
21
|
+
# Test if the Pulsar.node built from ../pkg/linux/build-napi-inside-docker.sh
|
|
22
|
+
# can be loaded in other Linux distributions.
|
|
23
|
+
|
|
21
24
|
set -e
|
|
22
25
|
|
|
26
|
+
if [[ $# -lt 2 ]]; then
|
|
27
|
+
echo "Usage $0 <node-image-name> <platform>
|
|
28
|
+
|
|
29
|
+
See https://hub.docker.com/_/node for valid images"
|
|
30
|
+
exit 1
|
|
31
|
+
fi
|
|
32
|
+
IMAGE=$1
|
|
33
|
+
PLATFORM=$2
|
|
34
|
+
|
|
23
35
|
ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}
|
|
24
36
|
cd $ROOT_DIR
|
|
25
37
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
done;
|
|
33
|
-
apt-get -y update
|
|
34
|
-
apt-get install -y software-properties-common
|
|
35
|
-
add-apt-repository ppa:ubuntu-toolchain-r/test && apt-get -y update
|
|
36
|
-
apt-get -y install gcc-4.9 && apt-get upgrade -y libstdc++6
|
|
37
|
-
apt install $PULSAR_PKG_DIR/apache-pulsar-client*.deb
|
|
38
|
-
|
|
39
|
-
./pulsar-test-service-start.sh
|
|
40
|
-
npm install && npm run lint && npm run dtslint && npm run build && npm run test
|
|
41
|
-
RES=$?
|
|
42
|
-
./pulsar-test-service-stop.sh
|
|
43
|
-
|
|
44
|
-
exit $RES
|
|
38
|
+
git archive -o pulsar-client-node.tar.gz HEAD
|
|
39
|
+
|
|
40
|
+
docker run --platform $PLATFORM -v $PWD:/pulsar-client-node $IMAGE \
|
|
41
|
+
/bin/bash /pulsar-client-node/tests/docker-load-test.sh
|
|
42
|
+
|
|
43
|
+
rm pulsar-client-node.tar.gz
|
|
@@ -18,21 +18,18 @@
|
|
|
18
18
|
# under the License.
|
|
19
19
|
#
|
|
20
20
|
|
|
21
|
+
set -e
|
|
22
|
+
|
|
21
23
|
ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}
|
|
22
24
|
cd $ROOT_DIR
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
IMAGE="$BUILD_IMAGE_NAME:$BUILD_IMAGE_VERSION"
|
|
28
|
-
|
|
29
|
-
echo "---- Testing Pulsar node client using image $IMAGE"
|
|
26
|
+
# download pulsar cpp client
|
|
27
|
+
pkg/linux/download-cpp-client.sh
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
cd $ROOT_DIR
|
|
30
|
+
build-support/pulsar-test-service-start.sh
|
|
31
|
+
npm install && npm run lint && npm run dtslint && npm run build && npm run test
|
|
32
|
+
RES=$?
|
|
33
|
+
build-support/pulsar-test-service-stop.sh
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
# and execute the tests
|
|
38
|
-
$DOCKER_CMD bash -c "cd /pulsar-client-node && ./run-unit-tests.sh"
|
|
35
|
+
exit $RES
|
package/pulsar-version.txt
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.10.1
|