pulsar-client 1.13.2 → 1.14.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.
Files changed (77) hide show
  1. package/.idea/aws.xml +18 -0
  2. package/.idea/codeStyles/Project.xml +7 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. package/.idea/misc.xml +7 -0
  6. package/.idea/modules.xml +9 -0
  7. package/.idea/pulsar-client-node.iml +46 -0
  8. package/.idea/pulsar_client_node.iml +8 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/index.d.ts +17 -0
  11. package/package.json +1 -1
  12. package/src/Client.cc +2 -1
  13. package/src/Client.h +1 -0
  14. package/src/ConsumerConfig.cc +66 -0
  15. package/src/cert.pem +3278 -0
  16. package/.clang-format +0 -26
  17. package/.eslintignore +0 -21
  18. package/.eslintrc.json +0 -22
  19. package/.github/PULL_REQUEST_TEMPLATE.md +0 -85
  20. package/.github/workflows/ci-build-release-napi.yml +0 -211
  21. package/.github/workflows/ci-pr-validation.yml +0 -334
  22. package/build-support/download-release-artifacts.py +0 -77
  23. package/build-support/generate-source-archive.sh +0 -28
  24. package/build-support/pulsar-test-container-start.sh +0 -43
  25. package/build-support/pulsar-test-service-start.sh +0 -39
  26. package/build-support/pulsar-test-service-stop.sh +0 -32
  27. package/build-support/sign-files.sh +0 -32
  28. package/build-support/stage-release.sh +0 -44
  29. package/docs/release-process.md +0 -291
  30. package/examples/certificate/private-key.client-rsa.pem +0 -27
  31. package/examples/certificate/public-key.client-rsa.pem +0 -9
  32. package/examples/consumer-schema.js +0 -66
  33. package/examples/consumer.js +0 -46
  34. package/examples/consumer_listener.js +0 -44
  35. package/examples/consumer_tls_auth.js +0 -51
  36. package/examples/consummer_token_auth.js +0 -50
  37. package/examples/consummer_token_auth_supplier.js +0 -56
  38. package/examples/custom_logger.js +0 -60
  39. package/examples/encryption-consumer.js +0 -47
  40. package/examples/encryption-producer.js +0 -50
  41. package/examples/encryption-reader.js +0 -44
  42. package/examples/producer-schema.js +0 -76
  43. package/examples/producer.js +0 -48
  44. package/examples/producer_tls_auth.js +0 -52
  45. package/examples/producer_token_auth.js +0 -48
  46. package/examples/producer_token_auth_supplier.js +0 -53
  47. package/examples/reader.js +0 -43
  48. package/examples/reader_listener.js +0 -37
  49. package/license-checker-config.json +0 -43
  50. package/license-header.txt +0 -16
  51. package/perf/perf_consumer.js +0 -103
  52. package/perf/perf_producer.js +0 -118
  53. package/pkg/linux/Dockerfile_linux_glibc +0 -31
  54. package/pkg/linux/Dockerfile_linux_musl +0 -32
  55. package/pkg/linux/build-napi-inside-docker.sh +0 -31
  56. package/pkg/linux/download-cpp-client.sh +0 -65
  57. package/pkg/load_test.js +0 -34
  58. package/pkg/mac/download-cpp-client.sh +0 -36
  59. package/pkg/windows/download-cpp-client.bat +0 -12
  60. package/tests/certificate/private-key.client-rsa.pem +0 -27
  61. package/tests/certificate/public-key.client-rsa.pem +0 -9
  62. package/tests/certificate/server.crt +0 -20
  63. package/tests/certificate/server.key +0 -28
  64. package/tests/client.test.js +0 -122
  65. package/tests/conf/standalone.conf +0 -308
  66. package/tests/consumer.test.js +0 -434
  67. package/tests/docker-load-test.sh +0 -35
  68. package/tests/end_to_end.test.js +0 -1447
  69. package/tests/http_utils.js +0 -45
  70. package/tests/load-test.sh +0 -43
  71. package/tests/producer.test.js +0 -160
  72. package/tests/reader.test.js +0 -175
  73. package/tests/run-unit-tests.sh +0 -35
  74. package/tsconfig.json +0 -22
  75. package/tslint.json +0 -9
  76. package/tstest.ts +0 -408
  77. package/typedoc.json +0 -15
@@ -1,45 +0,0 @@
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 http = require('http');
21
-
22
- const request = (url, { headers, data = {}, method }) => new Promise((resolve, reject) => {
23
- const req = http.request(url, {
24
- headers,
25
- method,
26
- }, (res) => {
27
- let responseBody = '';
28
- res.on('data', (chunk) => {
29
- responseBody += chunk;
30
- });
31
- res.on('end', () => {
32
- resolve({ responseBody, statusCode: res.statusCode });
33
- });
34
- });
35
-
36
- req.on('error', (error) => {
37
- reject(error);
38
- });
39
-
40
- req.write(JSON.stringify(data));
41
-
42
- req.end();
43
- });
44
-
45
- module.exports = request;
@@ -1,43 +0,0 @@
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
- # Test if the Pulsar.node built from ../pkg/linux/build-napi-inside-docker.sh
22
- # can be loaded in other Linux distributions.
23
-
24
- set -e
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
-
35
- ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}
36
- cd $ROOT_DIR
37
-
38
- git archive -o pulsar-client-node.tar.gz HEAD
39
-
40
- docker run --platform $PLATFORM -v $PWD:/pulsar-client-node $IMAGE \
41
- sh /pulsar-client-node/tests/docker-load-test.sh
42
-
43
- rm pulsar-client-node.tar.gz
@@ -1,160 +0,0 @@
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');
21
-
22
- (() => {
23
- describe('Producer', () => {
24
- let client;
25
-
26
- beforeAll(() => {
27
- client = new Pulsar.Client({
28
- serviceUrl: 'pulsar://localhost:6650',
29
- operationTimeoutSeconds: 30,
30
- });
31
- });
32
-
33
- afterAll(async () => {
34
- await client.close();
35
- });
36
-
37
- describe('Create', () => {
38
- test('No Topic', async () => {
39
- await expect(client.createProducer({
40
- sendTimeoutMs: 30000,
41
- batchingEnabled: true,
42
- })).rejects.toThrow('Topic is required and must be specified as a string when creating producer');
43
- });
44
-
45
- test('Not String Topic', async () => {
46
- await expect(client.createProducer({
47
- topic: 0,
48
- sendTimeoutMs: 30000,
49
- batchingEnabled: true,
50
- })).rejects.toThrow('Topic is required and must be specified as a string when creating producer');
51
- });
52
-
53
- test('Not Exist Tenant', async () => {
54
- await expect(client.createProducer({
55
- topic: 'persistent://no-tenant/namespace/topic',
56
- sendTimeoutMs: 30000,
57
- batchingEnabled: true,
58
- })).rejects.toThrow('Failed to create producer: TopicNotFound');
59
- });
60
-
61
- test('Not Exist Namespace', async () => {
62
- await expect(client.createProducer({
63
- topic: 'persistent://public/no-namespace/topic',
64
- sendTimeoutMs: 30000,
65
- batchingEnabled: true,
66
- })).rejects.toThrow('Failed to create producer: TopicNotFound');
67
- });
68
-
69
- test('Automatic Producer Name', async () => {
70
- const producer = await client.createProducer({
71
- topic: 'persistent://public/default/topic',
72
- });
73
-
74
- expect(typeof producer.getProducerName()).toBe('string');
75
- await producer.close();
76
- });
77
-
78
- test('Explicit Producer Name', async () => {
79
- const producer = await client.createProducer({
80
- topic: 'persistent://public/default/topic',
81
- producerName: 'test-producer',
82
- });
83
-
84
- expect(producer.getProducerName()).toBe('test-producer');
85
- await producer.close();
86
- });
87
-
88
- test('Topic Name', async () => {
89
- const producer = await client.createProducer({
90
- topic: 'persistent://public/default/topic',
91
- });
92
-
93
- expect(producer.getTopic()).toBe('persistent://public/default/topic');
94
- await producer.close();
95
- });
96
- });
97
- describe('Access Mode', () => {
98
- test('Exclusive', async () => {
99
- const topicName = 'test-access-mode-exclusive';
100
- const producer1 = await client.createProducer({
101
- topic: topicName,
102
- producerName: 'p-1',
103
- accessMode: 'Exclusive',
104
- });
105
- expect(producer1.getProducerName()).toBe('p-1');
106
-
107
- await expect(client.createProducer({
108
- topic: topicName,
109
- producerName: 'p-2',
110
- accessMode: 'Exclusive',
111
- })).rejects.toThrow('Failed to create producer: ResultProducerFenced');
112
-
113
- await producer1.close();
114
- });
115
-
116
- test('WaitForExclusive', async () => {
117
- const topicName = 'test-access-mode-wait-for-exclusive';
118
- const producer1 = await client.createProducer({
119
- topic: topicName,
120
- producerName: 'p-1',
121
- accessMode: 'Exclusive',
122
- });
123
- expect(producer1.getProducerName()).toBe('p-1');
124
- // async close producer1
125
- producer1.close();
126
- // when p1 close, p2 success created.
127
- const producer2 = await client.createProducer({
128
- topic: topicName,
129
- producerName: 'p-2',
130
- accessMode: 'WaitForExclusive',
131
- });
132
- expect(producer2.getProducerName()).toBe('p-2');
133
- await producer2.close();
134
- });
135
-
136
- test('ExclusiveWithFencing', async () => {
137
- const topicName = 'test-access-mode';
138
- const producer1 = await client.createProducer({
139
- topic: topicName,
140
- producerName: 'p-1',
141
- accessMode: 'Exclusive',
142
- });
143
- expect(producer1.getProducerName()).toBe('p-1');
144
- const producer2 = await client.createProducer({
145
- topic: topicName,
146
- producerName: 'p-2',
147
- accessMode: 'ExclusiveWithFencing',
148
- });
149
- expect(producer2.getProducerName()).toBe('p-2');
150
- // producer1 will be fenced.
151
- await expect(
152
- producer1.send({
153
- data: Buffer.from('test-msg'),
154
- }),
155
- ).rejects.toThrow('Failed to send message: ResultProducerFenced');
156
- await producer2.close();
157
- });
158
- });
159
- });
160
- })();
@@ -1,175 +0,0 @@
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 lodash = require('lodash');
21
- const Pulsar = require('../index');
22
- const httpRequest = require('./http_utils');
23
-
24
- const baseUrl = 'http://localhost:8080';
25
-
26
- (() => {
27
- describe('Reader', () => {
28
- test('No Topic', async () => {
29
- const client = new Pulsar.Client({
30
- serviceUrl: 'pulsar://localhost:6650',
31
- operationTimeoutSeconds: 30,
32
- });
33
- await expect(client.createReader({
34
- startMessageId: Pulsar.MessageId.earliest(),
35
- })).rejects.toThrow('Topic is required and must be specified as a string when creating reader');
36
- await client.close();
37
- });
38
-
39
- test('Not String Topic', async () => {
40
- const client = new Pulsar.Client({
41
- serviceUrl: 'pulsar://localhost:6650',
42
- operationTimeoutSeconds: 30,
43
- });
44
- await expect(client.createReader({
45
- topic: 0,
46
- startMessageId: Pulsar.MessageId.earliest(),
47
- })).rejects.toThrow('Topic is required and must be specified as a string when creating reader');
48
- await client.close();
49
- });
50
-
51
- test('No StartMessageId', async () => {
52
- const client = new Pulsar.Client({
53
- serviceUrl: 'pulsar://localhost:6650',
54
- operationTimeoutSeconds: 30,
55
- });
56
- await expect(client.createReader({
57
- topic: 'persistent://public/default/topic',
58
- })).rejects.toThrow('StartMessageId is required and must be specified as a MessageId object when creating reader');
59
- await client.close();
60
- });
61
-
62
- test('Not StartMessageId as MessageId', async () => {
63
- const client = new Pulsar.Client({
64
- serviceUrl: 'pulsar://localhost:6650',
65
- operationTimeoutSeconds: 30,
66
- });
67
- await expect(client.createReader({
68
- topic: 'persistent://public/default/topic',
69
- startMessageId: 'not MessageId',
70
- })).rejects.toThrow('StartMessageId is required and must be specified as a MessageId object when creating reader');
71
- await client.close();
72
- });
73
-
74
- test('Reader by Partitioned Topic', async () => {
75
- const client = new Pulsar.Client({
76
- serviceUrl: 'pulsar://localhost:6650',
77
- operationTimeoutSeconds: 30,
78
- });
79
-
80
- // Create partitioned topic.
81
- const partitionedTopicName = 'test-reader-partitioned-topic';
82
- const partitionedTopic = `persistent://public/default/${partitionedTopicName}`;
83
- const partitionedTopicAdminURL = `${baseUrl}/admin/v2/persistent/public/default/${partitionedTopicName}/partitions`;
84
- const createPartitionedTopicRes = await httpRequest(
85
- partitionedTopicAdminURL, {
86
- headers: {
87
- 'Content-Type': 'text/plain',
88
- },
89
- data: 4,
90
- method: 'PUT',
91
- },
92
- );
93
- expect(createPartitionedTopicRes.statusCode).toBe(204);
94
-
95
- const producer = await client.createProducer({
96
- topic: partitionedTopic,
97
- sendTimeoutMs: 30000,
98
- batchingEnabled: true,
99
- });
100
- expect(producer).not.toBeNull();
101
-
102
- const reader = await client.createReader({
103
- topic: partitionedTopic,
104
- startMessageId: Pulsar.MessageId.latest(),
105
- });
106
- expect(reader).not.toBeNull();
107
-
108
- const messages = [];
109
- for (let i = 0; i < 10; i += 1) {
110
- const msg = `my-message-${i}`;
111
- producer.send({
112
- data: Buffer.from(msg),
113
- });
114
- messages.push(msg);
115
- }
116
- await producer.flush();
117
-
118
- expect(reader.hasNext()).toBe(true);
119
-
120
- const results = [];
121
- for (let i = 0; i < 10; i += 1) {
122
- const msg = await reader.readNext();
123
- results.push(msg.getData().toString());
124
- }
125
- expect(lodash.difference(messages, results)).toEqual([]);
126
-
127
- expect(reader.hasNext()).toBe(false);
128
-
129
- await producer.close();
130
- await reader.close();
131
- await client.close();
132
- });
133
-
134
- test('Reader should not throw segmentation fault when create and close', async () => {
135
- const NUM_ITS = 1000;
136
- const its = Array.from({ length: NUM_ITS }, (_, i) => i);
137
-
138
- const client = new Pulsar.Client({
139
- serviceUrl: 'pulsar://localhost:6650',
140
- });
141
-
142
- const producer = await client.createProducer({
143
- topic: 'persistent://public/default/my-topic',
144
- sendTimeoutMs: 30000,
145
- batchingEnabled: true,
146
- });
147
-
148
- // Send messages
149
- for (let i = 0; i < 10; i += 1) {
150
- const msg = `my-message-${i}`;
151
- producer.send({
152
- data: Buffer.from(msg),
153
- });
154
- console.log(`Sent message: ${msg}`);
155
- }
156
- await producer.flush();
157
-
158
- await Promise.all(
159
- its.map(async () => {
160
- const reader = await client.createReader({
161
- topic: 'persistent://public/default/my-topic',
162
- startMessageId: Pulsar.MessageId.earliest(),
163
- listener: (message) => {
164
- console.log(message.getData().toString());
165
- },
166
- });
167
- await reader.close();
168
- }),
169
- );
170
- await producer.close();
171
- await client.close();
172
- expect(true).toBe(true);
173
- });
174
- });
175
- })();
@@ -1,35 +0,0 @@
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
- set -e
22
-
23
- ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}
24
- cd $ROOT_DIR
25
-
26
- # download pulsar cpp client
27
- pkg/linux/download-cpp-client.sh
28
-
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 && npm run docs
32
- RES=$?
33
- build-support/pulsar-test-service-stop.sh
34
-
35
- exit $RES
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2015",
4
- "lib": [
5
- "ES2015"
6
- ],
7
- "module": "commonjs",
8
- "noImplicitAny": true,
9
- "noImplicitThis": true,
10
- "noImplicitReturns": true,
11
- "strictNullChecks": true,
12
- "strictFunctionTypes": true,
13
- "strictBindCallApply": true,
14
- "strictPropertyInitialization": true,
15
- "types": [],
16
- "forceConsistentCasingInFileNames": true
17
- },
18
- "files": [
19
- "index.d.ts",
20
- "tstest.ts"
21
- ]
22
- }
package/tslint.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "dtslint/dtslint.json",
3
- "rules": {
4
- "semicolon": false,
5
- "no-unnecessary-class": false,
6
- "no-relative-import-in-test": false,
7
- "strict-export-declare-modifiers": false
8
- }
9
- }