pulsar-client 1.6.2 → 1.8.0-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.
Files changed (74) hide show
  1. package/.asf.yaml +8 -1
  2. package/.github/PULL_REQUEST_TEMPLATE.md +85 -0
  3. package/.github/workflows/ci-build-release-napi.yml +213 -0
  4. package/.github/workflows/ci-pr-validation.yml +225 -0
  5. package/README.md +87 -68
  6. package/binding.gyp +41 -39
  7. package/{pulsar-test-service-stop.sh → build-support/dep-version.py} +4 -6
  8. package/build-support/download-release-artifacts.py +74 -0
  9. package/build-support/generate-source-archive.sh +28 -0
  10. package/build-support/install-cpp-client.sh +66 -0
  11. package/{pulsar-test-service-start.sh → build-support/pulsar-test-container-start.sh} +11 -21
  12. package/build-support/pulsar-test-service-start.sh +37 -0
  13. package/build-support/pulsar-test-service-stop.sh +32 -0
  14. package/{.github/workflows/nodejs.yml → build-support/sign-files.sh} +13 -12
  15. package/build-support/stage-release.sh +44 -0
  16. package/dependencies.yaml +28 -0
  17. package/docs/release-process.md +262 -0
  18. package/examples/consumer.js +1 -1
  19. package/examples/consumer_listener.js +1 -1
  20. package/examples/consumer_tls_auth.js +1 -1
  21. package/examples/custom_logger.js +60 -0
  22. package/examples/encryption-consumer.js +1 -1
  23. package/examples/encryption-producer.js +1 -1
  24. package/examples/producer.js +1 -1
  25. package/examples/producer_tls_auth.js +1 -1
  26. package/examples/reader.js +1 -1
  27. package/examples/reader_listener.js +1 -1
  28. package/index.d.ts +12 -4
  29. package/index.js +2 -1
  30. package/package.json +16 -13
  31. package/pkg/build-napi-inside-docker.sh +31 -0
  32. package/pkg/linux_glibc/Dockerfile +33 -0
  33. package/pkg/linux_musl/Dockerfile +32 -0
  34. package/pkg/load_test.js +30 -0
  35. package/pkg/mac/build-cpp-deps-lib.sh +186 -0
  36. package/pkg/mac/build-cpp-lib.sh +51 -0
  37. package/{docker-tests.sh → pkg/mac/common.sh} +13 -13
  38. package/pkg/windows/download-cpp-client.bat +12 -0
  39. package/pulsar-client-cpp.txt +2 -0
  40. package/src/AuthenticationAthenz.js +1 -1
  41. package/src/AuthenticationOauth2.js +1 -1
  42. package/src/AuthenticationTls.js +1 -1
  43. package/src/AuthenticationToken.js +1 -1
  44. package/src/Client.cc +84 -58
  45. package/src/Client.h +6 -4
  46. package/src/Consumer.cc +331 -234
  47. package/src/Consumer.h +11 -9
  48. package/src/ConsumerConfig.cc +54 -32
  49. package/src/ConsumerConfig.h +5 -6
  50. package/src/Message.cc +26 -29
  51. package/src/Message.h +4 -4
  52. package/src/MessageId.cc +19 -22
  53. package/src/MessageId.h +5 -6
  54. package/src/MessageListener.h +3 -8
  55. package/src/Producer.cc +116 -133
  56. package/src/Producer.h +3 -3
  57. package/src/ProducerConfig.cc +39 -22
  58. package/src/ProducerConfig.h +2 -2
  59. package/src/Reader.cc +147 -128
  60. package/src/Reader.h +5 -3
  61. package/src/ReaderConfig.cc +14 -20
  62. package/src/ReaderConfig.h +5 -6
  63. package/src/ReaderListener.h +2 -7
  64. package/src/SchemaInfo.cc +78 -0
  65. package/src/SchemaInfo.h +41 -0
  66. package/src/ThreadSafeDeferred.cc +98 -0
  67. package/src/ThreadSafeDeferred.h +85 -0
  68. package/src/pulsar-binding.js +26 -0
  69. package/tests/conf/standalone.conf +6 -0
  70. package/tests/consumer.test.js +2 -2
  71. package/tests/end_to_end.test.js +214 -2
  72. package/tests/producer.test.js +2 -2
  73. package/{run-unit-tests.sh → tests/run-unit-tests.sh} +5 -14
  74. package/pulsar-version.txt +0 -1
@@ -0,0 +1,44 @@
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
+ set -e -x
22
+
23
+ if [ $# -neq 2 ]; then
24
+ echo "Usage: $0 \$DEST_PATH \$WORKFLOW_ID"
25
+ exit 1
26
+ fi
27
+
28
+ DEST_PATH=$(readlink -f $1)
29
+ WORKFLOW_ID=$2
30
+
31
+ pushd $(dirname "$0")
32
+ PULSAR_NODE_PATH=$(git rev-parse --show-toplevel)
33
+ popd
34
+
35
+ mkdir -p $DEST_PATH
36
+
37
+ cd $PULSAR_NODE_PATH
38
+
39
+ build-support/download-release-artifacts.py $WORKFLOW_ID $DEST_PATH
40
+ build-support/generate-source-archive.sh $DEST_PATH
41
+
42
+ # Sign all files
43
+ cd $DEST_PATH
44
+ find . -type f | xargs $PULSAR_NODE_PATH/build-support/sign-files.sh
@@ -0,0 +1,28 @@
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
+ # Only used for MacOS builds
21
+ boost: 1.80.0
22
+ cmake: 3.24.2
23
+ protobuf: 3.20.0
24
+ zlib: 1.2.13
25
+ zstd: 1.5.2
26
+ snappy: 1.1.9
27
+ openssl: 1.1.1s
28
+ curl: 7.85.0
@@ -0,0 +1,262 @@
1
+ <!--
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
+ This page contains instructions for Pulsar committers on how to perform a release.
22
+
23
+ ## Making the release
24
+
25
+ The steps for releasing are as follows:
26
+ 1. Check and Add TypeScript Types
27
+ 2. Create the release branch
28
+ 3. Update package version and tag
29
+ 4. Sign and stage the artifacts
30
+ 5. Move master branch to next version
31
+ 6. Write release notes
32
+ 7. Run the vote
33
+ 8. Promote the release
34
+ 9. Update release notes
35
+ 10. Announce the release
36
+
37
+ ## Requirements
38
+ If you haven't already done it, [create and publish the GPG key](https://pulsar.apache.org/contribute/releasing/create-gpg-keys) to sign the release artifacts.
39
+
40
+ ## Steps in detail
41
+
42
+ #### 1. Check and Add TypeScript Types
43
+
44
+ In order to use added features and options in TypeScript code, we need to add their type definitions.
45
+
46
+ Check if there are any Pull Requests with the `types-required` label or not.
47
+ If yes, add their type definitions (e.g. https://github.com/apache/pulsar-client-node/pull/157).
48
+ If no, we can then proceed to next step.
49
+
50
+ #### 2. Create the release branch
51
+
52
+ We are going to create a branch from `master` to `branch-1.X` where the tag will be generated
53
+ and where new fixes will be applied as part of the maintenance for the release.
54
+
55
+ The branch needs only to be created when creating minor releases, and not for patch releases.
56
+
57
+ Eg: When creating `v1.1.0` release, will be creating the branch `branch-1.1`,
58
+ but for `v1.1.1` we would keep using the old `branch-1.1`.
59
+
60
+ In these instructions, I'm referring to an fictitious release `1.X.0`.
61
+ Change the release version in the examples accordingly with the real version.
62
+
63
+ It is recommended to create a fresh clone of the repository to avoid any local files to interfere
64
+ in the process:
65
+
66
+ ```sh
67
+ $ git clone git@github.com:apache/pulsar-client-node.git
68
+ $ cd pulsar-client-node
69
+ $ git checkout -b branch-1.X origin/master
70
+ ```
71
+
72
+ #### 3. Update package version and tag
73
+
74
+ During the release process, we are going to initially create "candidate" tags:
75
+ ```sh
76
+ # Bump to the release version (the suffix "-rc.0" is removed)
77
+ $ npm version patch --no-git-tag-version
78
+ $ git add .
79
+ $ git commit -m 'Release v1.x.0'
80
+
81
+ # Create a "candidate" tag
82
+ $ export GPG_TTY=$(tty)
83
+ $ git tag -u $USER@apache.org v1.X.0-rc.1 -m 'Release v1.X.0-rc.1'
84
+
85
+ # Push both the branch and the tag to GitHub repo
86
+ $ git push origin branch-1.X
87
+ $ git push origin v1.X.0-rc.1
88
+ ```
89
+
90
+ #### 4. Sign and stage the artifacts
91
+ The src artifact need to be signed and uploaded to the dist SVN repository for staging. See [here](https://github.com/apache/pulsar/wiki/Create-GPG-keys-to-sign-release-artifacts) for how to setup gpg.
92
+
93
+ When the build is pushed to the Apache repo, a Github action job will run and build all the binary artifacts.
94
+
95
+ The build will be available at `https://github.com/apache/pulsar-client-node/actions`
96
+
97
+ Once the workflow is completed (ETA ~20 min), the artifacts will be available for download.
98
+
99
+ Record the id of the workflow as `WORKFLOW_ID`.
100
+
101
+ All the artifacts need to be signed and uploaded to the dist SVN repository for staging.
102
+
103
+ Before running the script, make sure that the `user@apache.org` code signing key is the default gpg signing key. One way to ensure this is to create/edit file `~/.gnupg/gpg.conf` and add a line
104
+
105
+ ```sh
106
+ default-key <key fingerprint>
107
+ ```
108
+
109
+ where` <key fingerprint>` should be replaced with the private key fingerprint for the `user@apache.org` key. The key fingerprint can be found in `gpg -K` output.
110
+
111
+ ```sh
112
+ $ svn co https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node pulsar-dist-dev
113
+ $ cd pulsar-dist-dev
114
+
115
+ # '-candidate-1' needs to be incremented in case of multiple iterations in getting
116
+ # to the final release)
117
+ $ svn mkdir pulsar-client-node-1.X.0-candidate-1
118
+
119
+ # Generate token from here: https://github.com/settings/tokens
120
+ $ export GITHUB_TOKEN=${Your github token}
121
+ $ $PULSAR_PATH/build-support/stage-release.sh . $WORKFLOW_ID
122
+
123
+ $ svn add *
124
+ $ svn ci -m 'Staging artifacts and signature for Pulsar Node.js client release 1.X.0-candidate-1'
125
+ ```
126
+
127
+ #### 5. Move master branch to next version
128
+
129
+ We need to move master version to next iteration `X + 1`.
130
+
131
+ ```sh
132
+ $ git checkout master
133
+ $ npm version preminor --preid=rc
134
+ ```
135
+
136
+ Since this needs to be merged in `master`, we need to follow the regular process
137
+ and create a Pull Request on GitHub.
138
+
139
+ #### 6. Write release notes
140
+
141
+ Check the milestone in GitHub associated with the release.
142
+ https://github.com/apache/pulsar-client-node/milestones?closed=1
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
147
+
148
+ #### 7. Run the vote
149
+
150
+ Send an email on the Pulsar Dev mailing list:
151
+
152
+ ```
153
+ To: dev@pulsar.apache.org
154
+ Subject: [VOTE] Pulsar Node.js Client Release 1.X.0 Candidate 1
155
+
156
+ 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
+
161
+ This is the first release candidate for Apache Pulsar Node.js client, version 1.X.0.
162
+
163
+ It fixes the following issues:
164
+ https://github.com/apache/pulsar-client-node/milestone/1?closed=1
165
+
166
+ 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.
169
+
170
+ The vote will be open for at least 72 hours. It is adopted by majority approval, with at least 3 PMC affirmative votes.
171
+
172
+ Source files:
173
+ https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/pulsar-client-node-1.X.0-candidate-1/
174
+
175
+ Pulsar's KEYS file containing PGP keys we use to sign the release:
176
+ https://dist.apache.org/repos/dist/dev/pulsar/KEYS
177
+
178
+ SHA-512 checksum:
179
+ 5f6c7e1a096a3ae66eee71c552af89532ed86bf94da3f3d49836c080426ee5dcaabeda440a989d51772d2e67e2dca953eeee9ea83cfbc7c2a0847a0ec04b310f pulsar-client-node-1.X.0.tar.gz
180
+
181
+ The tag to be voted upon:
182
+ v1.X.0-rc.1
183
+ https://github.com/apache/pulsar-client-node/releases/tag/v1.X.0-rc.1
184
+ ```
185
+
186
+ The vote should be open for at least 72 hours (3 days). Votes from Pulsar PMC members
187
+ will be considered binding, while anyone else is encouraged to verify the release and
188
+ vote as well.
189
+
190
+ If the release is approved here, we can then proceed to next step.
191
+
192
+ #### 8. Promote the release
193
+
194
+ Create the final git tag:
195
+ ```sh
196
+ $ git checkout branch-1.X
197
+ $ export GPG_TTY=$(tty)
198
+ $ git tag -u $USER@apache.org v1.X.0 -m 'Release v1.X.0'
199
+ $ git push origin v1.X.0
200
+ ```
201
+
202
+ Publish the release package:
203
+ ```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
212
+ $ 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
+ ```
217
+
218
+ Promote the artifacts on the release location (need PMC permissions):
219
+ ```sh
220
+ $ 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 \
222
+ https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-node/pulsar-client-node-1.X.0
223
+
224
+ # Remove the old releases (if any)
225
+ # We only need the latest release there, older releases are available through the Apache archive
226
+ $ svn rm -m 'Remove the old release' \
227
+ https://dist.apache.org/repos/dist/release/pulsar/pulsar-client-node/pulsar-client-node-1.Y.0
228
+ ```
229
+
230
+ #### 9. Update release notes
231
+
232
+ Add the release notes there:
233
+ https://github.com/apache/pulsar-client-node/releases
234
+
235
+ #### 10. Announce the release
236
+
237
+ Once the release artifact is available in the npm registry, we need to announce the release.
238
+
239
+ Send an email on these lines:
240
+ ```
241
+ To: dev@pulsar.apache.org, users@pulsar.apache.org, announce@apache.org
242
+ Subject: [ANNOUNCE] Apache Pulsar Node.js client 1.X.0 released
243
+
244
+ The Apache Pulsar team is proud to announce Apache Pulsar Node.js client version 1.X.0.
245
+
246
+ Pulsar is a highly scalable, low latency messaging platform running on
247
+ commodity hardware. It provides simple pub-sub semantics over topics,
248
+ guaranteed at-least-once delivery of messages, automatic cursor management for
249
+ subscribers, and cross-datacenter replication.
250
+
251
+ For Pulsar Node.js client release details and downloads, visit:
252
+ https://www.npmjs.com/package/pulsar-client
253
+
254
+ Release Notes are at:
255
+ https://github.com/apache/pulsar-client-node/releases
256
+
257
+ We would like to thank the contributors that made the release possible.
258
+
259
+ Regards,
260
+
261
+ The Pulsar Team
262
+ ```
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  const auth = new Pulsar.AuthenticationTls({
@@ -0,0 +1,60 @@
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('..');
21
+
22
+ (async () => {
23
+ // Create a client
24
+ const client = new Pulsar.Client({
25
+ serviceUrl: 'pulsar://localhost:6650',
26
+ operationTimeoutSeconds: 30,
27
+ });
28
+
29
+ Pulsar.Client.setLogHandler((level, file, line, message) => {
30
+ console.log('[%s][%s:%d] %s', Pulsar.LogLevel.toString(level), file, line, message);
31
+ });
32
+
33
+ // Create a producer
34
+ const producer = await client.createProducer({
35
+ topic: 'persistent://public/default/my-topic',
36
+ sendTimeoutMs: 30000,
37
+ batchingEnabled: true,
38
+ });
39
+
40
+ // Create a consumer
41
+ const consumer = await client.subscribe({
42
+ topic: 'persistent://public/default/my-topic',
43
+ subscription: 'sub1',
44
+ subscriptionType: 'Shared',
45
+ ackTimeoutMs: 10000,
46
+ });
47
+
48
+ const msg = `my-message`;
49
+ await producer.send({
50
+ data: Buffer.from(msg),
51
+ });
52
+
53
+ const receivedMsg = await consumer.receive();
54
+ console.log(receivedMsg.getData().toString());
55
+ await consumer.acknowledge(receivedMsg);
56
+
57
+ await producer.close();
58
+ await consumer.close();
59
+ await client.close();
60
+ })();
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  const auth = new Pulsar.AuthenticationTls({
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const Pulsar = require('pulsar-client');
20
+ const Pulsar = require('../');
21
21
 
22
22
  (async () => {
23
23
  // Create a client
package/index.d.ts CHANGED
@@ -34,6 +34,7 @@ export interface ClientConfig {
34
34
  }
35
35
 
36
36
  export class Client {
37
+ static setLogHandler(logHandler: (level: LogLevel, file: string, line: number, message: string) => void): void;
37
38
  constructor(config: ClientConfig);
38
39
  createProducer(config: ProducerConfig): Promise<Producer>;
39
40
  subscribe(config: ConsumerConfig): Promise<Consumer>;
@@ -59,6 +60,7 @@ export interface ProducerConfig {
59
60
  publicKeyPath?: string;
60
61
  encryptionKey?: string;
61
62
  cryptoFailureAction?: ProducerCryptoFailureAction;
63
+ chunkingEnabled?: boolean;
62
64
  }
63
65
 
64
66
  export class Producer {
@@ -87,16 +89,20 @@ export interface ConsumerConfig {
87
89
  readCompacted?: boolean;
88
90
  privateKeyPath?: string;
89
91
  cryptoFailureAction?: ConsumerCryptoFailureAction;
92
+ maxPendingChunkedMessage?: number;
93
+ autoAckOldestChunkedMessageOnQueueFull?: number;
90
94
  }
91
95
 
92
96
  export class Consumer {
93
97
  receive(timeout?: number): Promise<Message>;
94
- acknowledge(message: Message): void;
95
- acknowledgeId(messageId: MessageId): void;
98
+ acknowledge(message: Message): Promise<null>;
99
+ acknowledgeId(messageId: MessageId): Promise<null>;
96
100
  negativeAcknowledge(message: Message): void;
97
101
  negativeAcknowledgeId(messageId: MessageId): void;
98
- acknowledgeCumulative(message: Message): void;
99
- acknowledgeCumulativeId(messageId: MessageId): void;
102
+ acknowledgeCumulative(message: Message): Promise<null>;
103
+ acknowledgeCumulativeId(messageId: MessageId): Promise<null>;
104
+ seek(messageId: MessageId): Promise<null>;
105
+ seekTimestamp(timestamp: number): Promise<null>;
100
106
  isConnected(): boolean;
101
107
  close(): Promise<null>;
102
108
  unsubscribe(): Promise<null>;
@@ -116,6 +122,8 @@ export class Reader {
116
122
  readNext(timeout?: number): Promise<Message>;
117
123
  hasNext(): boolean;
118
124
  isConnected(): boolean;
125
+ seek(messageId: MessageId): Promise<null>;
126
+ seekTimestamp(timestamp: number): Promise<null>;
119
127
  close(): Promise<null>;
120
128
  }
121
129
 
package/index.js CHANGED
@@ -17,7 +17,7 @@
17
17
  * under the License.
18
18
  */
19
19
 
20
- const PulsarBinding = require('bindings')('Pulsar');
20
+ const PulsarBinding = require('./src/pulsar-binding');
21
21
  const AuthenticationTls = require('./src/AuthenticationTls.js');
22
22
  const AuthenticationAthenz = require('./src/AuthenticationAthenz.js');
23
23
  const AuthenticationToken = require('./src/AuthenticationToken.js');
@@ -28,6 +28,7 @@ const LogLevel = {
28
28
  INFO: 1,
29
29
  WARN: 2,
30
30
  ERROR: 3,
31
+ toString: (level) => Object.keys(LogLevel).find((key) => LogLevel[key] === level),
31
32
  };
32
33
 
33
34
  const Pulsar = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulsar-client",
3
- "version": "1.6.2",
3
+ "version": "1.8.0-rc.2",
4
4
  "description": "Pulsar Node.js client",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,21 +10,22 @@
10
10
  },
11
11
  "scripts": {
12
12
  "install": "node-pre-gyp install --fallback-to-build",
13
- "clean": "node-gyp clean",
14
- "configure": "node-gyp configure",
13
+ "configure": "node-pre-gyp configure",
14
+ "build": "npm run format && node-pre-gyp build",
15
+ "build:debug": "npm run format && node-pre-gyp rebuild --debug",
16
+ "clean": "node-pre-gyp clean",
15
17
  "lint": "clang-format-lint src/*.cc src/*.h && eslint --ext .js .",
16
18
  "format": "clang-format-lint --fix src/*.cc src/*.h && eslint --fix --ext .js .",
17
19
  "dtslint": "dtslint .",
18
- "build": "npm run format && node-gyp rebuild",
19
- "build:debug": "npm run format && node-gyp rebuild --debug",
20
20
  "license:report": "mkdir -p report && grunt grunt-license-report",
21
21
  "license:addheader": "license-check-and-add",
22
- "test": "jest --verbose"
22
+ "test": "jest --verbose --detectOpenHandles"
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
26
26
  "url": "https://github.com/apache/pulsar-client-node.git"
27
27
  },
28
+ "homepage": "https://pulsar.apache.org/docs/en/client-libraries-node",
28
29
  "author": "Apache Software Foundation",
29
30
  "license": "Apache-2.0",
30
31
  "gypfile": true,
@@ -51,15 +52,16 @@
51
52
  "typescript": "^4.1.3"
52
53
  },
53
54
  "dependencies": {
54
- "@mapbox/node-pre-gyp": "^1.0.7",
55
+ "@mapbox/node-pre-gyp": "^1.0.9",
55
56
  "bindings": "^1.5.0",
56
- "node-addon-api": "^3.2.1",
57
- "node-gyp": "^8.4.1"
57
+ "node-addon-api": "^4.3.0"
58
58
  },
59
59
  "binary": {
60
- "module_name": "libpulsar",
61
- "module_path": "./build/Release",
62
- "host": "https://pulsar.apache.org/docs/en/client-libraries-cpp/"
60
+ "module_name": "Pulsar",
61
+ "module_path": "./lib/binding/",
62
+ "host": "https://dist.apache.org/repos/dist/dev/pulsar/pulsar-client-node/",
63
+ "remote_path": "pulsar-client-node-1.8.0-candidate-2",
64
+ "package_name": "napi-{platform}-{libc}-{arch}.tar.gz"
63
65
  },
64
66
  "license-check-and-add-config": {
65
67
  "folder": ".",
@@ -77,7 +79,8 @@
77
79
  ".json",
78
80
  ".pem",
79
81
  ".txt",
80
- ".gz"
82
+ ".gz",
83
+ ".bat"
81
84
  ],
82
85
  "trailing_whitespace": "TRIM",
83
86
  "insert_license": true,
@@ -0,0 +1,31 @@
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
+ set -e -x
22
+
23
+ cd /pulsar-client-node
24
+
25
+ build-support/install-cpp-client.sh
26
+
27
+ npm install --ignore-scripts
28
+ npx node-pre-gyp configure
29
+ npx node-pre-gyp build
30
+ npx node-pre-gyp package
31
+ node pkg/load_test.js