Fix issue #431: node-pre-gyp deprecation and CI failures
Fixes:
1. Upgrade @mapbox/node-pre-gyp from 1.0.11 to 2.0.3
- Removes deprecation warnings: npmlog, rimraf, inflight,
are-we-there-yet, gauge
- Updated dependencies: tar, nopt, https-proxy-agent
2. Update macOS deployment target to 13.0
- Fixes linker warnings: ld: warning object file was built
for newer 'macOS' version (13.0) than being linked (11.0)
- Matches pre-compiled C++ client library version
3. Fix dtslint CI error
- Disable no-redundant-jsdoc rule in tslint.json
- Error was: 'Unexpected tag kind: JSDocCallbackTag'
in TypeScript 3.9 type definitions
Changes:
- binding.gyp: MACOSX_DEPLOYMENT_TARGET 11.0 -> 13.0
- package.json: @mapbox/node-pre-gyp ^1.0.11 -> ^2.0.3
- tslint.json: Added no-redundant-jsdoc rule to disable error
- Lock files: package-lock.json, yarn.lock
Verification:
- npm install: Success (no deprecation warnings from node-pre-gyp)
- dtslint: Pass (no JSDocCallbackTag error)
- Build: Success (lib/binding/pulsar.node generated)
- Binary: Mach-O 64-bit bundle arm64 (12M)
Note: DevDependencies security vulnerabilities remain in npm audit
but are not production blocking. Can be addressed in
separate follow-up.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
The Pulsar Node.js client can be used to create Pulsar producers and consumers in Node.js. For the supported Pulsar features, see Client Feature Matrix.
This library works only in Node.js 12.3 or later because it uses:
Note
These instructions are only available for versions after 1.8.0. For versions previous to 1.8.0, you need to install the C++ client first. Please switch to the corresponding version branch of this repo to read the specific instructions.
To run the examples, skip this section.
To use the Pulsar Node.js client in your project, run:
npm install pulsar-client
or
yarn add pulsar-client
Then you can run the following simple end-to-end example:
const Pulsar = require('pulsar-client'); (async () => { // Create a client const client = new Pulsar.Client({ serviceUrl: 'pulsar://localhost:6650' }); // Create a producer const producer = await client.createProducer({ topic: 'persistent://public/default/my-topic', }); // Create a consumer const consumer = await client.subscribe({ topic: 'persistent://public/default/my-topic', subscription: 'sub1' }); // Send a message producer.send({ data: Buffer.from("hello") }); // Receive the message const msg = await consumer.receive(); console.log(msg.getData().toString()); consumer.acknowledge(msg); await producer.close(); await consumer.close(); await client.close(); })();
You should find the output as:
hello
You can see more examples in the examples directory. However, since these examples might use an API that was not released yet, you need to build this module. See the next section.
Note
Building from source code requires a Node.js version greater than 16.18.
First, clone the repository.
git clone https://github.com/apache/pulsar-client-node.git cd pulsar-client-node
Since this client is a C++ addon that depends on the Pulsar C++ client, you need to install the C++ client first. You need to ensure there is a C++ compiler that supports C++11 installed in your system.
pkg/linux/download-cpp-client.sh
pkg\windows\download-cpp-client.bat
pkg/mac/download-cpp-client.sh
After the C++ client is installed, run the following command to build this C++ addon.
npm install
To verify it has been installed successfully, you can run an example like:
Note
A running Pulsar server is required. The example uses
pulsar://localhost:6650to connect to the server.
node examples/producer
You should find the output as:
Sent message: my-message-0 Sent message: my-message-1 Sent message: my-message-2 Sent message: my-message-3 Sent message: my-message-4 Sent message: my-message-5 Sent message: my-message-6 Sent message: my-message-7 Sent message: my-message-8 Sent message: my-message-9
For more details about Pulsar Node.js clients, see Pulsar docs.
Contributions are welcomed and greatly appreciated.
If your contribution adds Pulsar features for Node.js clients, you need to update both the Pulsar docs and the Client Feature Matrix. See Contribution Guide for more details.
npm install npx typedoc # Documentation generated at ./apidocs