pulsar-client 1.8.1-rc.2 → 1.8.2-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.
@@ -167,7 +167,7 @@ jobs:
167
167
  docker run -i -v $PWD:/pulsar-client-node build:latest \
168
168
  /pulsar-client-node/pkg/linux/build-napi-inside-docker.sh
169
169
 
170
- - name: Test NAPI file in other containers
170
+ - name: Test NAPI file in linux_glibc containers
171
171
  if: matrix.image == 'linux_glibc'
172
172
  run: |
173
173
  ./tests/load-test.sh node:16-buster ${{matrix.cpu.platform}}
@@ -175,6 +175,12 @@ jobs:
175
175
  ./tests/load-test.sh node:19-buster ${{matrix.cpu.platform}}
176
176
  ./tests/load-test.sh node:19-bullseye ${{matrix.cpu.platform}}
177
177
 
178
+ - name: Test NAPI file in linux_musl containers
179
+ if: matrix.image == 'linux_musl'
180
+ run: |
181
+ ./tests/load-test.sh node:18-alpine3.15 ${{matrix.cpu.platform}}
182
+ ./tests/load-test.sh node:16-alpine3.15 ${{matrix.cpu.platform}}
183
+
178
184
  windows-napi:
179
185
  name: Build NAPI windows - Node ${{matrix.nodejs}} - ${{matrix.arch}}
180
186
  runs-on: windows-2022
package/README.md CHANGED
@@ -154,4 +154,13 @@ Sent message: my-message-9
154
154
  ```
155
155
 
156
156
  ## Documentation
157
+
157
158
  * Please see https://pulsar.apache.org/docs/client-libraries-node/ for more details about the Pulsar Node.js client.
159
+
160
+ You can generate the API docs by:
161
+
162
+ ```shell
163
+ npm install
164
+ npx typedoc
165
+ # Documentation generated at ./apidocs
166
+ ```
package/binding.gyp CHANGED
@@ -21,7 +21,7 @@
21
21
  "targets": [
22
22
  {
23
23
  "target_name": "pulsar",
24
- "cflags_cc": ["-std=gnu++11"],
24
+ "cflags_cc": ["-std=gnu++11", "-fvisibility=hidden"],
25
25
  "cflags!": ["-fno-exceptions"],
26
26
  "cflags_cc!": ["-fno-exceptions", "-std=gnu++14", "-std=gnu++17"],
27
27
  "include_dirs": [
@@ -85,6 +85,9 @@
85
85
  ]
86
86
  }],
87
87
  ['OS=="linux"', {
88
+ "ldflags": [
89
+ "-Wl,--exclude-libs,ALL"
90
+ ],
88
91
  "dependencies": [
89
92
  "<!@(node -p \"require('node-addon-api').gyp\")"
90
93
  ],
@@ -30,6 +30,14 @@ bin/pulsar-daemon start standalone \
30
30
  --bookkeeper-dir data/bookkeeper
31
31
 
32
32
  echo "-- Wait for Pulsar service to be ready"
33
- until curl http://localhost:8080/metrics > /dev/null 2>&1 ; do sleep 1; done
33
+ for i in $(seq 30); do
34
+ curl http://localhost:8080/metrics > /dev/null 2>&1 && break
35
+ if [ $i -lt 30 ]; then
36
+ sleep 1
37
+ else
38
+ echo '-- Pulsar standalone server startup timed out'
39
+ exit 1
40
+ fi
41
+ done
34
42
 
35
43
  echo "-- Ready to start tests"
@@ -30,6 +30,8 @@ CONTAINER_ID=$(docker run -i -p 8080:8080 -p 6650:6650 -p 8443:8443 -p 6651:6651
30
30
  echo $CONTAINER_ID >.tests-container-id.txt
31
31
 
32
32
  docker cp $SRC_DIR/tests/conf $CONTAINER_ID:/pulsar/test-conf
33
+ docker cp $SRC_DIR/tests/certificate/server.crt $CONTAINER_ID:/pulsar/test-conf
34
+ docker cp $SRC_DIR/tests/certificate/server.key $CONTAINER_ID:/pulsar/test-conf
33
35
  docker cp $SRC_DIR/build-support/pulsar-test-container-start.sh $CONTAINER_ID:pulsar-test-container-start.sh
34
36
 
35
37
  docker exec -i $CONTAINER_ID /pulsar-test-container-start.sh
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulsar-client",
3
- "version": "1.8.1-rc.2",
3
+ "version": "1.8.2-rc.1",
4
4
  "description": "Pulsar Node.js client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,7 +19,8 @@
19
19
  "dtslint": "dtslint .",
20
20
  "license:report": "mkdir -p report && grunt grunt-license-report",
21
21
  "license:addheader": "license-check-and-add",
22
- "test": "jest --verbose --detectOpenHandles"
22
+ "test": "jest --verbose --detectOpenHandles",
23
+ "docs": "typedoc"
23
24
  },
24
25
  "repository": {
25
26
  "type": "git",
@@ -33,12 +34,12 @@
33
34
  "node": ">=10.16.0"
34
35
  },
35
36
  "devDependencies": {
37
+ "dtslint": "^4.2.0",
36
38
  "@seadub/clang-format-lint": "0.0.2",
37
39
  "@types/node": "^14.14.25",
38
40
  "clang-format": "^1.4.0",
39
41
  "commander": "^6.1.0",
40
42
  "delay": "^4.4.0",
41
- "dtslint": "^3.4.2",
42
43
  "eslint": "^7.8.1",
43
44
  "eslint-config-airbnb-base": "^14.2.0",
44
45
  "eslint-plugin-import": "^2.22.0",
@@ -49,7 +50,8 @@
49
50
  "jest": "^27.2.4",
50
51
  "license-check-and-add": "^2.3.6",
51
52
  "lodash": "^4.17.21",
52
- "typescript": "^4.1.3"
53
+ "typedoc": "^0.23.28",
54
+ "typescript": "^4.9.5"
53
55
  },
54
56
  "dependencies": {
55
57
  "@mapbox/node-pre-gyp": "^1.0.9",
@@ -19,7 +19,7 @@
19
19
 
20
20
  ARG NODE_VERSION
21
21
 
22
- FROM node:${NODE_VERSION}-alpine
22
+ FROM node:${NODE_VERSION}-alpine3.15
23
23
 
24
24
  RUN apk add \
25
25
  bash \
package/src/Client.cc CHANGED
@@ -93,12 +93,11 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(info)
93
93
  Napi::HandleScope scope(env);
94
94
  Napi::Object clientConfig = info[0].As<Napi::Object>();
95
95
 
96
- if (!clientConfig.Has(CFG_SERVICE_URL) || !clientConfig.Get(CFG_SERVICE_URL).IsString()) {
97
- if (clientConfig.Get(CFG_SERVICE_URL).ToString().Utf8Value().empty()) {
98
- Napi::Error::New(env, "Service URL is required and must be specified as a string")
99
- .ThrowAsJavaScriptException();
100
- return;
101
- }
96
+ if (!clientConfig.Has(CFG_SERVICE_URL) || !clientConfig.Get(CFG_SERVICE_URL).IsString() ||
97
+ clientConfig.Get(CFG_SERVICE_URL).ToString().Utf8Value().empty()) {
98
+ Napi::Error::New(env, "Service URL is required and must be specified as a string")
99
+ .ThrowAsJavaScriptException();
100
+ return;
102
101
  }
103
102
  Napi::String serviceUrl = clientConfig.Get(CFG_SERVICE_URL).ToString();
104
103
 
@@ -186,8 +185,12 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(info)
186
185
  pulsar_client_configuration_set_stats_interval_in_seconds(cClientConfig.get(), statsIntervalInSeconds);
187
186
  }
188
187
 
189
- this->cClient = std::shared_ptr<pulsar_client_t>(
190
- pulsar_client_create(serviceUrl.Utf8Value().c_str(), cClientConfig.get()), pulsar_client_free);
188
+ try {
189
+ this->cClient = std::shared_ptr<pulsar_client_t>(
190
+ pulsar_client_create(serviceUrl.Utf8Value().c_str(), cClientConfig.get()), pulsar_client_free);
191
+ } catch (const std::exception &e) {
192
+ Napi::Error::New(env, e.what()).ThrowAsJavaScriptException();
193
+ }
191
194
  }
192
195
 
193
196
  Client::~Client() {}
@@ -0,0 +1,20 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDSDCCAjACCQDP7B74131FAzANBgkqhkiG9w0BAQsFADBmMQswCQYDVQQGEwJK
3
+ UDEOMAwGA1UECAwFVG9reW8xFTATBgNVBAcMDERlZmF1bHQgQ2l0eTEcMBoGA1UE
4
+ CgwTRGVmYXVsdCBDb21wYW55IEx0ZDESMBAGA1UEAwwJbG9jYWxob3N0MB4XDTIz
5
+ MDQwNDAzNTYxNVoXDTMzMDQwMTAzNTYxNVowZjELMAkGA1UEBhMCSlAxDjAMBgNV
6
+ BAgMBVRva3lvMRUwEwYDVQQHDAxEZWZhdWx0IENpdHkxHDAaBgNVBAoME0RlZmF1
7
+ bHQgQ29tcGFueSBMdGQxEjAQBgNVBAMMCWxvY2FsaG9zdDCCASIwDQYJKoZIhvcN
8
+ AQEBBQADggEPADCCAQoCggEBALpN39t4b52CT58D3XO0pbAHaBmJ3BHsL/HZnLhl
9
+ 4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qdKHQDNBMLwL93SeYYQJAoGATf9n
22
+ C4r3FVzq8DHCWag9bao5Z0SQCbdEIsCrSa+c6AN7cVkW5eM7P2ADk70k8ULKXq0V
23
+ dqK66+RWBvR2/KpAMU7FylXOQzUlaVy4Kn1DrpX3L12mCdMpgjvl87re7FXoBmo/
24
+ 4veRybntytl6WNtagN9xfJoEV/aGJA4u554Ei9sCgYEAtLscB69G9XbWo6YAsgbG
25
+ cBcbwFZku7tyyrcnqptxSza95w0Y9MDVUtMcgOEehLkSeIpdnIgq14Alln753BYJ
26
+ WyNI6s+fYrusaK/aqNniQJaZRFF6K/55dVwKETUwBhsT8a1JuDVKuAXhq0YF/0Ji
27
+ Z/yve3En4WV+agiOP0teQJM=
28
+ -----END PRIVATE KEY-----
@@ -0,0 +1,53 @@
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
+ (() => {
23
+ describe('Client', () => {
24
+ describe('CreateFailedByUrlSetIncorrect', () => {
25
+ test('No Set Url', async () => {
26
+ await expect(() => new Pulsar.Client({
27
+ operationTimeoutSeconds: 30,
28
+ })).toThrow('Service URL is required and must be specified as a string');
29
+ });
30
+
31
+ test('Set empty url', async () => {
32
+ await expect(() => new Pulsar.Client({
33
+ serviceUrl: '',
34
+ operationTimeoutSeconds: 30,
35
+ })).toThrow('Service URL is required and must be specified as a string');
36
+ });
37
+
38
+ test('Set invalid url', async () => {
39
+ await expect(() => new Pulsar.Client({
40
+ serviceUrl: 'invalid://localhost:6655',
41
+ operationTimeoutSeconds: 30,
42
+ })).toThrow('Invalid scheme: invalid');
43
+ });
44
+
45
+ test('Set not string url', async () => {
46
+ await expect(() => new Pulsar.Client({
47
+ serviceUrl: -1,
48
+ operationTimeoutSeconds: 30,
49
+ })).toThrow('Service URL is required and must be specified as a string');
50
+ });
51
+ });
52
+ });
53
+ })();
@@ -26,9 +26,11 @@ zookeeperServers=
26
26
  globalZookeeperServers=
27
27
 
28
28
  brokerServicePort=6650
29
+ brokerServicePortTls=6651
29
30
 
30
31
  # Port to use to server HTTP request
31
32
  webServicePort=8080
33
+ webServicePortTls=8443
32
34
 
33
35
  # Hostname or IP address the service binds on, default is 0.0.0.0.
34
36
  bindAddress=0.0.0.0
@@ -90,6 +92,19 @@ delayedDeliveryEnabled=true
90
92
  # Default is 1 second.
91
93
  delayedDeliveryTickTimeMillis=1000
92
94
 
95
+ ### --- TLS --- ###
96
+ # Path for the TLS certificate file
97
+ tlsCertificateFilePath=/pulsar/test-conf/server.crt
98
+
99
+ # Path for the TLS private key file
100
+ tlsKeyFilePath=/pulsar/test-conf/server.key
101
+
102
+ # Path for the trusted TLS certificate file.
103
+ # This cert is used to verify that any certs presented by connecting clients
104
+ # are signed by a certificate authority. If this verification
105
+ # fails, then the certs are untrusted and the connections are dropped.
106
+ tlsTrustCertsFilePath=/pulsar/test-conf/server.crt
107
+
93
108
  ### --- Authentication --- ###
94
109
 
95
110
  # Enable authentication
@@ -22,9 +22,15 @@ const Pulsar = require('../index.js');
22
22
 
23
23
  (() => {
24
24
  describe('End To End', () => {
25
- test('Produce/Consume', async () => {
25
+ test.each([
26
+ ['pulsar://localhost:6650'],
27
+ ['pulsar+ssl://localhost:6651'],
28
+ ['http://localhost:8080'],
29
+ ['https://localhost:8443'],
30
+ ])('Produce/Consume to %s', async (serviceUrl) => {
26
31
  const client = new Pulsar.Client({
27
- serviceUrl: 'pulsar://localhost:6650',
32
+ serviceUrl,
33
+ tlsTrustCertsFilePath: `${__dirname}/certificate/server.crt`,
28
34
  operationTimeoutSeconds: 30,
29
35
  });
30
36
 
@@ -38,6 +38,6 @@ cd $ROOT_DIR
38
38
  git archive -o pulsar-client-node.tar.gz HEAD
39
39
 
40
40
  docker run --platform $PLATFORM -v $PWD:/pulsar-client-node $IMAGE \
41
- /bin/bash /pulsar-client-node/tests/docker-load-test.sh
41
+ sh /pulsar-client-node/tests/docker-load-test.sh
42
42
 
43
43
  rm pulsar-client-node.tar.gz
@@ -28,7 +28,7 @@ pkg/linux/download-cpp-client.sh
28
28
 
29
29
  cd $ROOT_DIR
30
30
  build-support/pulsar-test-service-start.sh
31
- npm install && npm run lint && npm run dtslint && npm run build && npm run test
31
+ npm install && npm run lint && npm run dtslint && npm run build && npm run test && npm run docs
32
32
  RES=$?
33
33
  build-support/pulsar-test-service-stop.sh
34
34
 
package/tslint.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "dtslint/dtslint.json",
3
3
  "rules": {
4
+ "semicolon": false,
4
5
  "no-unnecessary-class": false,
5
6
  "no-relative-import-in-test": false,
6
7
  "strict-export-declare-modifiers": false
package/tstest.ts CHANGED
@@ -315,33 +315,33 @@ import Pulsar = require('./index');
315
315
 
316
316
  // Missing required parameters
317
317
  (async () => {
318
- // $ExpectError
318
+ // @ts-expect-error
319
319
  const authAthenz: Pulsar.AuthenticationAthenz = new Pulsar.AuthenticationAthenz({
320
320
  });
321
321
 
322
- // $ExpectError
322
+ // @ts-expect-error
323
323
  const client: Pulsar.Client = new Pulsar.Client({
324
324
  });
325
325
 
326
- // $ExpectError
326
+ // @ts-expect-error
327
327
  const producer: Pulsar.Producer = await client.createProducer({
328
328
  });
329
329
 
330
- // $ExpectError
330
+ // @ts-expect-error
331
331
  const consumer: Pulsar.Consumer = await client.subscribe({
332
332
  });
333
333
 
334
- // $ExpectError
334
+ // @ts-expect-error
335
335
  const reader1: Pulsar.Reader = await client.createReader({
336
336
  topic: 'persistent://public/default/my-topic',
337
337
  });
338
338
 
339
- // $ExpectError
339
+ // @ts-expect-error
340
340
  const reader2: Pulsar.Reader = await client.createReader({
341
341
  startMessageId: Pulsar.MessageId.latest(),
342
342
  });
343
343
 
344
- // $ExpectError
344
+ // @ts-expect-error
345
345
  const messageId: Pulsar.MessageId = await producer.send({
346
346
  });
347
347
  })();
package/typedoc.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "entryPoints": ["index.d.ts"],
3
+ "out": "apidocs",
4
+ "name": "Apache Pulsar",
5
+ "tsconfig": "tsconfig.json",
6
+ "excludePrivate": true,
7
+ "excludeProtected": true,
8
+ "excludeExternals": true,
9
+ "includeVersion": true,
10
+ "githubPages": false,
11
+ "navigationLinks": {
12
+ "Homepage": "https://pulsar.apache.org/",
13
+ "GitHub": "https://github.com/apache/pulsar-client-node"
14
+ }
15
+ }