pulsar-client 1.8.0 → 1.8.1-rc.2

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.
@@ -127,7 +127,7 @@ jobs:
127
127
  - name: Build Linux Docker image
128
128
  uses: docker/build-push-action@v3
129
129
  with:
130
- context: ./pkg/${{matrix.image}}
130
+ file: ./pkg/linux/Dockerfile_${{matrix.image}}
131
131
  load: true
132
132
  tags: build:latest
133
133
  platforms: linux/${{matrix.cpu.arch}}
@@ -141,7 +141,7 @@ jobs:
141
141
  - name: Build and Test NAPI file
142
142
  run: |
143
143
  docker run -i -v $PWD:/pulsar-client-node build:latest \
144
- /pulsar-client-node/pkg/build-napi-inside-docker.sh
144
+ /pulsar-client-node/pkg/linux/build-napi-inside-docker.sh
145
145
 
146
146
  - name: Upload artifacts
147
147
  uses: actions/upload-artifact@v3
@@ -151,7 +151,7 @@ jobs:
151
151
  - name: Build Linux Docker image
152
152
  uses: docker/build-push-action@v3
153
153
  with:
154
- context: ./pkg/${{matrix.image}}
154
+ file: ./pkg/linux/Dockerfile_${{matrix.image}}
155
155
  load: true
156
156
  tags: build:latest
157
157
  platforms: linux/${{matrix.cpu.arch}}
@@ -165,7 +165,15 @@ jobs:
165
165
  - name: Build and Test NAPI file
166
166
  run: |
167
167
  docker run -i -v $PWD:/pulsar-client-node build:latest \
168
- /pulsar-client-node/pkg/build-napi-inside-docker.sh
168
+ /pulsar-client-node/pkg/linux/build-napi-inside-docker.sh
169
+
170
+ - name: Test NAPI file in other containers
171
+ if: matrix.image == 'linux_glibc'
172
+ run: |
173
+ ./tests/load-test.sh node:16-buster ${{matrix.cpu.platform}}
174
+ ./tests/load-test.sh node:16-bullseye ${{matrix.cpu.platform}}
175
+ ./tests/load-test.sh node:19-buster ${{matrix.cpu.platform}}
176
+ ./tests/load-test.sh node:19-bullseye ${{matrix.cpu.platform}}
169
177
 
170
178
  windows-napi:
171
179
  name: Build NAPI windows - Node ${{matrix.nodejs}} - ${{matrix.arch}}
package/GenCertFile.js ADDED
@@ -0,0 +1,22 @@
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 Client = require('./src/Client.js');
21
+
22
+ Client.genCertFile();
package/README.md CHANGED
@@ -94,6 +94,10 @@ You can see more examples in the [examples](./examples) directory. However, sinc
94
94
 
95
95
  ## How to build
96
96
 
97
+ > **Note**
98
+ >
99
+ > Build from source code requires the Node.js version greater than 16.18
100
+
97
101
  First, clone the repository.
98
102
 
99
103
  ```shell
@@ -106,7 +110,7 @@ Since this client is a [C++ addon](https://nodejs.org/api/addons.html#c-addons)
106
110
  - Install C++ client on Linux:
107
111
 
108
112
  ```shell
109
- build-support/install-cpp-client.sh
113
+ pkg/linux/download-cpp-client.sh
110
114
  ```
111
115
 
112
116
  - Install C++ client on Windows:
package/binding.gyp CHANGED
@@ -20,7 +20,7 @@
20
20
  {
21
21
  "targets": [
22
22
  {
23
- "target_name": "Pulsar",
23
+ "target_name": "pulsar",
24
24
  "cflags_cc": ["-std=gnu++11"],
25
25
  "cflags!": ["-fno-exceptions"],
26
26
  "cflags_cc!": ["-fno-exceptions", "-std=gnu++14", "-std=gnu++17"],
@@ -60,6 +60,9 @@
60
60
  "include_dirs": [
61
61
  "pkg/mac/build-pulsar/install/include"
62
62
  ],
63
+ "libraries": [
64
+ "../pkg/mac/build-pulsar/install/lib/libpulsarwithdeps.a"
65
+ ],
63
66
  }],
64
67
  ['OS=="win"', {
65
68
  "defines": [
@@ -80,12 +83,16 @@
80
83
  "dependencies": [
81
84
  "<!(node -p \"require('node-addon-api').gyp\")"
82
85
  ]
83
- }, { # 'OS!="win"'
86
+ }],
87
+ ['OS=="linux"', {
84
88
  "dependencies": [
85
89
  "<!@(node -p \"require('node-addon-api').gyp\")"
86
90
  ],
91
+ "include_dirs": [
92
+ "pkg/linux/pulsar-cpp/include"
93
+ ],
87
94
  "libraries": [
88
- "../pkg/lib/libpulsarwithdeps.a"
95
+ "../pkg/linux/pulsar-cpp/lib/libpulsarwithdeps.a"
89
96
  ],
90
97
  }]
91
98
  ]
@@ -28,10 +28,10 @@ The steps for releasing are as follows:
28
28
  3. Update package version and tag
29
29
  4. Sign and stage the artifacts
30
30
  5. Move master branch to next version
31
- 6. Write release notes
31
+ 6. Publish the release candidate to the npm
32
32
  7. Run the vote
33
33
  8. Promote the release
34
- 9. Update release notes
34
+ 9. Add release notes
35
35
  10. Announce the release
36
36
 
37
37
  ## Requirements
@@ -112,16 +112,17 @@ where` <key fingerprint>` should be replaced with the private key fingerprint fo
112
112
  $ svn co https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node pulsar-dist-dev
113
113
  $ cd pulsar-dist-dev
114
114
 
115
- # '-candidate-1' needs to be incremented in case of multiple iterations in getting
115
+ # '-rc.1' needs to be incremented in case of multiple iterations in getting
116
116
  # to the final release)
117
- $ svn mkdir pulsar-client-node-1.X.0-candidate-1
117
+ $ svn mkdir pulsar-client-node-1.X.0-rc.1
118
+ $ cd pulsar-client-node-1.X.0-rc.1
118
119
 
119
120
  # Generate token from here: https://github.com/settings/tokens
120
121
  $ export GITHUB_TOKEN=${Your github token}
121
122
  $ $PULSAR_PATH/build-support/stage-release.sh . $WORKFLOW_ID
122
123
 
123
124
  $ svn add *
124
- $ svn ci -m 'Staging artifacts and signature for Pulsar Node.js client release 1.X.0-candidate-1'
125
+ $ svn ci -m 'Staging artifacts and signature for Pulsar Node.js client release 1.X.0-rc.1'
125
126
  ```
126
127
 
127
128
  #### 5. Move master branch to next version
@@ -136,14 +137,25 @@ $ npm version preminor --preid=rc
136
137
  Since this needs to be merged in `master`, we need to follow the regular process
137
138
  and create a Pull Request on GitHub.
138
139
 
139
- #### 6. Write release notes
140
+ #### 6. Publish the release candidate to the npm
140
141
 
141
- Check the milestone in GitHub associated with the release.
142
- https://github.com/apache/pulsar-client-node/milestones?closed=1
142
+ If you don't have permission to publish `pulsar-client` to the npm registry, ask other committers to grant that permission.
143
143
 
144
- In the release item, add the list of most important changes that happened in the release
145
- and a link to the associated milestone, with the complete list of all the changes.
146
- https://github.com/apache/pulsar-client-node/releases
144
+ ```sh
145
+ # Set the npm version for the release candidate
146
+ npm version 1.x.0-rc.1 --no-git-tag-version
147
+
148
+ # Create or verify a user account in the npm registry
149
+ $ npm adduser
150
+
151
+ Username: foobar
152
+ Password: ********
153
+ Email: (this IS public) foobar@apache.org
154
+
155
+ # Publish the rc version package to the npm registry
156
+ # We use the `rc` tag to distinguish the release candidate from the official release.
157
+ $ npm publish --tag rc
158
+ ```
147
159
 
148
160
  #### 7. Run the vote
149
161
 
@@ -154,9 +166,6 @@ To: dev@pulsar.apache.org
154
166
  Subject: [VOTE] Pulsar Node.js Client Release 1.X.0 Candidate 1
155
167
 
156
168
  Hi everyone,
157
- Please review and vote on the release candidate #1 for the version 1.X.0, as follows:
158
- [ ] +1, Approve the release
159
- [ ] -1, Do not approve the release (please provide specific comments)
160
169
 
161
170
  This is the first release candidate for Apache Pulsar Node.js client, version 1.X.0.
162
171
 
@@ -164,23 +173,31 @@ It fixes the following issues:
164
173
  https://github.com/apache/pulsar-client-node/milestone/1?closed=1
165
174
 
166
175
  Please download the source files and review this release candidate:
167
- - Review release notes
168
- - Download the source package (verify shasum and asc) and follow the README.md to build and run the Pulsar Node.js client.
176
+ - Download the source package, verify shasum and asc
177
+ - Follow the README.md to build and run the Pulsar Node.js client.
178
+
179
+ The release candidate package has been published to the npm registry:
180
+ https://www.npmjs.com/package/pulsar-client/v/1.X.0-rc.1
181
+ You can install it by `npm i pulsar-client@1.X.0-rc.1 --pulsar_binary_host_mirror=https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/` and verify the package.
169
182
 
170
183
  The vote will be open for at least 72 hours. It is adopted by majority approval, with at least 3 PMC affirmative votes.
171
184
 
172
185
  Source files:
173
- https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/pulsar-client-node-1.X.0-candidate-1/
186
+ https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/pulsar-client-node-1.X.0-rc.1/
174
187
 
175
188
  Pulsar's KEYS file containing PGP keys we use to sign the release:
176
189
  https://dist.apache.org/repos/dist/dev/pulsar/KEYS
177
190
 
178
191
  SHA-512 checksum:
179
- 5f6c7e1a096a3ae66eee71c552af89532ed86bf94da3f3d49836c080426ee5dcaabeda440a989d51772d2e67e2dca953eeee9ea83cfbc7c2a0847a0ec04b310f pulsar-client-node-1.X.0.tar.gz
192
+ 5f6c7e1a096a3ae66eee71c552af89532ed86bf94da3f3d49836c080426ee5dcaabeda440a989d51772d2e67e2dca953eeee9ea83cfbc7c2a0847a0ec04b310f apache-pulsar-client-node-1.X.0.tar.gz
180
193
 
181
194
  The tag to be voted upon:
182
195
  v1.X.0-rc.1
183
196
  https://github.com/apache/pulsar-client-node/releases/tag/v1.X.0-rc.1
197
+
198
+ Please review and vote on the release candidate #1 for the version 1.X.0, as follows:
199
+ [ ] +1, Approve the release
200
+ [ ] -1, Do not approve the release (please provide specific comments)
184
201
  ```
185
202
 
186
203
  The vote should be open for at least 72 hours (3 days). Votes from Pulsar PMC members
@@ -201,24 +218,15 @@ $ git push origin v1.X.0
201
218
 
202
219
  Publish the release package:
203
220
  ```sh
204
- # Create or verify a user account in the npm registry
205
- $ npm adduser
206
-
207
- Username: foobar
208
- Password: ********
209
- Email: (this IS public) foobar@apache.org
210
-
211
- # Publish the package to the npm registry
221
+ # You can use `npm pack` and test the package before publishing.
222
+ # If there are no problems, then use `npm publish` to publish to the npm.
212
223
  $ npm publish
213
-
214
- # If you don't have permission to publish `pulsar-client` to the npm registry,
215
- # ask other committers to grant that permission.
216
224
  ```
217
225
 
218
226
  Promote the artifacts on the release location (need PMC permissions):
219
227
  ```sh
220
228
  $ svn mv -m 'Release Pulsar Node.js client 1.X.0' \
221
- https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/pulsar-client-node-1.X.0-candidate-1 \
229
+ https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/pulsar-client-node-1.X.0-rc.1 \
222
230
  https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-node/pulsar-client-node-1.X.0
223
231
 
224
232
  # Remove the old releases (if any)
@@ -227,10 +235,12 @@ $ svn rm -m 'Remove the old release' \
227
235
  https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-node/pulsar-client-node-1.Y.0
228
236
  ```
229
237
 
230
- #### 9. Update release notes
238
+ #### 9. Add release notes
231
239
 
232
- Add the release notes there:
233
- https://github.com/apache/pulsar-client-node/releases
240
+ Create a PR to add release notes to the pulsar site. Here is the example: https://github.com/apache/pulsar-site/pull/360
241
+ If there are any new contributors for this release, please add a `New Contributors` section in the release note.
242
+
243
+ Once the PR has been approved, add release notes to the Github release page (https://github.com/apache/pulsar-client-node/releases)
234
244
 
235
245
  #### 10. Announce the release
236
246
 
package/index.js CHANGED
@@ -22,6 +22,7 @@ const AuthenticationTls = require('./src/AuthenticationTls.js');
22
22
  const AuthenticationAthenz = require('./src/AuthenticationAthenz.js');
23
23
  const AuthenticationToken = require('./src/AuthenticationToken.js');
24
24
  const AuthenticationOauth2 = require('./src/AuthenticationOauth2.js');
25
+ const Client = require('./src/Client.js');
25
26
 
26
27
  const LogLevel = {
27
28
  DEBUG: 0,
@@ -32,7 +33,7 @@ const LogLevel = {
32
33
  };
33
34
 
34
35
  const Pulsar = {
35
- Client: PulsarBinding.Client,
36
+ Client,
36
37
  Message: PulsarBinding.Message,
37
38
  MessageId: PulsarBinding.MessageId,
38
39
  AuthenticationTls,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulsar-client",
3
- "version": "1.8.0",
3
+ "version": "1.8.1-rc.2",
4
4
  "description": "Pulsar Node.js client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -9,7 +9,7 @@
9
9
  "example": "examples"
10
10
  },
11
11
  "scripts": {
12
- "install": "node-pre-gyp install --fallback-to-build",
12
+ "install": "node-pre-gyp install --fallback-to-build && node GenCertFile.js",
13
13
  "configure": "node-pre-gyp configure",
14
14
  "build": "npm run format && node-pre-gyp build",
15
15
  "build:debug": "npm run format && node-pre-gyp rebuild --debug",
@@ -57,9 +57,9 @@
57
57
  "node-addon-api": "^4.3.0"
58
58
  },
59
59
  "binary": {
60
- "module_name": "Pulsar",
60
+ "module_name": "pulsar",
61
61
  "module_path": "./lib/binding/",
62
- "host": "https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-node/",
62
+ "host": "https://archive.apache.org/dist/pulsar/pulsar-client-node/",
63
63
  "remote_path": "pulsar-client-node-{version}",
64
64
  "package_name": "napi-{platform}-{libc}-{arch}.tar.gz"
65
65
  },
@@ -17,17 +17,19 @@
17
17
  # under the License.
18
18
  #
19
19
 
20
- ARG NODE_VERSION
20
+ FROM centos:7
21
21
 
22
- FROM node:${NODE_VERSION}-bullseye
22
+ RUN yum update -y
23
+ RUN yum install -y gcc gcc-c++ make python3
23
24
 
24
- ARG NODE_VERSION
25
+ WORKDIR /app
26
+ ARG PLATFORM
27
+ RUN SUFFIX=$(echo ${PLATFORM} | sed 's/86_//') && \
28
+ echo $SUFFIX && \
29
+ curl -O -L https://nodejs.org/download/release/v16.19.0/node-v16.19.0-linux-$SUFFIX.tar.gz && \
30
+ tar zxf node-v16.19.0-linux-$SUFFIX.tar.gz && \
31
+ mv node-v16.19.0-linux-$SUFFIX node-v16.19.0
25
32
 
26
- RUN apt-get update -y && \
27
- apt-get install -y \
28
- curl \
29
- g++ \
30
- make \
31
- python3
33
+ ENV PATH="/app/node-v16.19.0/bin:$PATH"
32
34
 
33
35
  CMD ["sh"]
@@ -22,7 +22,7 @@ set -e -x
22
22
 
23
23
  cd /pulsar-client-node
24
24
 
25
- build-support/install-cpp-client.sh
25
+ pkg/linux/download-cpp-client.sh
26
26
 
27
27
  npm install --ignore-scripts
28
28
  npx node-pre-gyp configure
@@ -20,7 +20,7 @@
20
20
 
21
21
  set -e -x
22
22
 
23
- ROOT_DIR=`cd $(dirname $0) && cd .. && pwd`
23
+ ROOT_DIR=`cd $(dirname $0) && cd ../../ && pwd`
24
24
  source $ROOT_DIR/pulsar-client-cpp.txt
25
25
 
26
26
  if [ $USER != "root" ]; then
@@ -29,9 +29,6 @@ fi
29
29
 
30
30
  # Get the flavor of Linux
31
31
  export $(cat /etc/*-release | grep "^ID=")
32
-
33
- cd /tmp
34
-
35
32
  UNAME_ARCH=$(uname -m)
36
33
  if [ $UNAME_ARCH == 'aarch64' ]; then
37
34
  PLATFORM=arm64
@@ -39,28 +36,30 @@ else
39
36
  PLATFORM=x86_64
40
37
  fi
41
38
 
39
+ rm -rf $ROOT_DIR/pkg/linux/pulsar-cpp
40
+ mkdir $ROOT_DIR/pkg/linux/pulsar-cpp
41
+ rm -rf $ROOT_DIR/pkg/linux/tmp
42
+ mkdir $ROOT_DIR/pkg/linux/tmp
43
+ cd $ROOT_DIR/pkg/linux/tmp
44
+
42
45
  if [ $ID == 'ubuntu' -o $ID == 'debian' ]; then
43
- curl -L -O ${CPP_CLIENT_BASE_URL}/deb-${PLATFORM}/apache-pulsar-client.deb
44
46
  curl -L -O ${CPP_CLIENT_BASE_URL}/deb-${PLATFORM}/apache-pulsar-client-dev.deb
45
- $SUDO apt install -y /tmp/*.deb
47
+ $SUDO ar x apache-pulsar-client-dev.deb
48
+ $SUDO tar -xvf data.tar.xz
49
+ cp -r usr/* $ROOT_DIR/pkg/linux/pulsar-cpp/
46
50
 
47
51
  elif [ $ID == 'alpine' ]; then
48
- curl -L -O ${CPP_CLIENT_BASE_URL}/apk-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-${CPP_CLIENT_VERSION}-r0.apk
49
52
  curl -L -O ${CPP_CLIENT_BASE_URL}/apk-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-dev-${CPP_CLIENT_VERSION}-r0.apk
50
- $SUDO apk add --allow-untrusted /tmp/*.apk
53
+ $SUDO tar -xvf apache-pulsar-client-dev-${CPP_CLIENT_VERSION}-r0.apk
54
+ cp -r usr/* $ROOT_DIR/pkg/linux/pulsar-cpp/
51
55
 
52
- elif [ $ID == '"centos"' ]; then
53
- curl -L -O ${CPP_CLIENT_BASE_URL}/rpm-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm
56
+ elif [ $ID == '"centos"' -o $ID == '"rocky"' ]; then
54
57
  curl -L -O ${CPP_CLIENT_BASE_URL}/rpm-${PLATFORM}/${UNAME_ARCH}/apache-pulsar-client-devel-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm
55
- $SUDO rpm -i /tmp/*.rpm
58
+ $SUDO rpm -i --prefix=$ROOT_DIR/pkg/linux/pulsar-cpp apache-pulsar-client-devel-${CPP_CLIENT_VERSION}-1.${UNAME_ARCH}.rpm --nodeps --force
56
59
 
57
60
  else
58
61
  echo "Unknown Linux distribution: '$ID'"
59
62
  exit 1
60
63
  fi
61
64
 
62
- mkdir -p $ROOT_DIR/pkg/lib/
63
- cp /usr/lib/libpulsarwithdeps.a $ROOT_DIR/pkg/lib/
64
-
65
-
66
-
65
+ $SUDO rm -rf $ROOT_DIR/pkg/linux/tmp
package/pkg/load_test.js CHANGED
@@ -20,6 +20,10 @@
20
20
  const Pulsar = require('../index.js');
21
21
 
22
22
  (async () => {
23
+ Pulsar.Client.setLogHandler((level, file, line, message) => {
24
+ console.log('[%s][%s:%d] %s', Pulsar.LogLevel.toString(level), file, line, message);
25
+ });
26
+
23
27
  // Create a client
24
28
  const clientConfig = {
25
29
  serviceUrl: 'pulsar://localhost:6650',
@@ -43,9 +43,6 @@ pushd apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}
43
43
  -DBUILD_DYNAMIC_LIB=OFF \
44
44
  -DPROTOC_PATH=$PREFIX/bin/protoc
45
45
  make -j16 install
46
- mkdir -p $ROOT_DIR/pkg/lib/
47
- cp -r lib/libpulsarwithdeps.a $ROOT_DIR/pkg/lib/
48
46
  popd
49
47
 
50
48
  rm -rf apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}.tar.gz apache-pulsar-client-cpp-${CPP_CLIENT_VERSION}
51
-
@@ -1,2 +1,2 @@
1
- CPP_CLIENT_BASE_URL=https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.1.0/
2
- CPP_CLIENT_VERSION=3.1.0
1
+ CPP_CLIENT_BASE_URL=https://archive.apache.org/dist/pulsar/pulsar-client-cpp-3.1.2
2
+ CPP_CLIENT_VERSION=3.1.2
package/src/Client.js ADDED
@@ -0,0 +1,68 @@
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 fs = require('fs');
20
+ const tls = require('tls');
21
+ const os = require('os');
22
+ const PulsarBinding = require('./pulsar-binding');
23
+
24
+ const certsFilePath = `${__dirname}/cert.pem`;
25
+
26
+ class Client {
27
+ constructor(params) {
28
+ if (!params.tlsTrustCertsFilePath) {
29
+ // eslint-disable-next-line no-param-reassign
30
+ params.tlsTrustCertsFilePath = certsFilePath;
31
+ }
32
+ this.client = new PulsarBinding.Client(params);
33
+ }
34
+
35
+ createProducer(params) {
36
+ return this.client.createProducer(params);
37
+ }
38
+
39
+ subscribe(params) {
40
+ return this.client.subscribe(params);
41
+ }
42
+
43
+ createReader(params) {
44
+ return this.client.createReader(params);
45
+ }
46
+
47
+ close() {
48
+ this.client.close();
49
+ }
50
+
51
+ static setLogHandler(params) {
52
+ PulsarBinding.Client.setLogHandler(params);
53
+ }
54
+
55
+ static genCertFile() {
56
+ fs.rmSync(certsFilePath, { force: true });
57
+ const fd = fs.openSync(certsFilePath, 'a');
58
+ try {
59
+ tls.rootCertificates.forEach((cert) => {
60
+ fs.appendFileSync(fd, cert + os.EOL);
61
+ });
62
+ } finally {
63
+ fs.closeSync(fd);
64
+ }
65
+ }
66
+ }
67
+
68
+ module.exports = Client;
@@ -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
@@ -0,0 +1,43 @@
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
+ /bin/bash /pulsar-client-node/tests/docker-load-test.sh
42
+
43
+ rm pulsar-client-node.tar.gz
@@ -23,8 +23,8 @@ set -e
23
23
  ROOT_DIR=${ROOT_DIR:-$(git rev-parse --show-toplevel)}
24
24
  cd $ROOT_DIR
25
25
 
26
- # install pulsar cpp client pkg
27
- build-support/install-cpp-client.sh
26
+ # download pulsar cpp client
27
+ pkg/linux/download-cpp-client.sh
28
28
 
29
29
  cd $ROOT_DIR
30
30
  build-support/pulsar-test-service-start.sh