Skip to content

Set client description to identify Node.js client#454

Draft
shibd wants to merge 5 commits intomasterfrom
fix/issue-3505
Draft

Set client description to identify Node.js client#454
shibd wants to merge 5 commits intomasterfrom
fix/issue-3505

Conversation

@shibd
Copy link
Member

@shibd shibd commented Jan 28, 2026

Summary

This PR fixes automatically setting the client description to "node-client-vX.Y.Z" where X.Y.Z is the Node.js client version from package.json. After this fix, the clientVersion in topic statistics will display as "Pulsar-CPP-vA.B.C-node-client-vX.Y.Z" instead of just "Pulsar-CPP-vA.B.C".

Problem

The Node.js client wraps the C++ client library. When connecting to the broker, it uses the C++ client's version string, making it impossible to distinguish Node.js clients from C++ clients in topic statistics. This creates confusion for operators monitoring their Pulsar clusters.

Solution

Automatically set client description using the Node.js client version from package.json. The description is set to "node-client-vX.Y.Z" format during client initialization. This is done transparently without requiring any user configuration.

Changes

  • binding.gyp: Add PULSAR_CLIENT_NODE_VERSION define to read version from package.json at build time
  • src/Client.cc: Set client description to "node-client-v<version>" format in client constructor
  • index.d.ts: Remove description parameter from ClientConfig (not needed, automatic)

Result

After this fix, clientVersion in topic stats will display as:

  • Format: "Pulsar-CPP-v4.0.0-node-client-v1.17.0-rc.0"
  • First part (Pulsar-CPP-v4.0.0): C++ client version
  • Second part (-node-client-v1.17.0-rc.0): Node.js client identifier and version

Backward Compatibility

This change is fully backward compatible. Existing code will continue to work without any changes. The only visible change is that clientVersion in topic statistics will now include the Node.js client identifier.

shibd added 3 commits January 28, 2026 19:41
Add 'description' parameter to Client configuration and set default value to 'node'
so that clientVersion in topic stats displays as 'Pulsar-CPP-vX.Y.Z-node' instead of
just 'Pulsar-CPP-vX.Y.Z'.

This allows operators to distinguish Node.js clients from C++ clients in topic statistics.

Changes:
- Add CFG_DESCRIPTION constant for description configuration parameter
- Parse description from JavaScript client configuration
- Set default description to 'node' to identify as Node.js client
- Add 'description' to TypeScript ClientConfig interface
- Allow users to override description if needed

Fixes #3505
Automatically set client description to 'node-client-vX.Y.Z' using the
Node.js client version from package.json, so that clientVersion in topic
stats displays as 'Pulsar-CPP-vX.Y.Z-node-client-vA.B.C' instead
of just 'Pulsar-CPP-vX.Y.Z'.

This allows operators to distinguish Node.js clients from C++ clients in topic
statistics without requiring users to configure anything.

Changes:
- Add PULSAR_CLIENT_NODE_VERSION define in binding.gyp to read version from package.json
- Set client description to 'node-client-v<version>' in Client constructor
- Remove user-configurable description parameter (not needed, automatic)
- Add <sstream> header for string formatting
- Remove description from TypeScript ClientConfig interface

Fixes #3505
Automatically set client description to 'node-client-vX.Y.Z' using
Node.js client version from package.json, so that clientVersion in topic
stats displays as 'Pulsar-CPP-vX.Y.Z-node-client-vA.B.C' instead
of just 'Pulsar-CPP-vX.Y.Z'.

This allows operators to distinguish Node.js clients from C++ clients in topic
statistics without requiring users to configure anything.

Changes:
- Add PulsarWrapper class to access private setDescription method
- Add scripts/generate_version.py to read version from package.json
- Add binding.gyp action to generate version.h during build
- Add src/version.h to compile-time version definition
- Set client description to 'node-client-v<version>' in Client constructor

This approach uses a wrapper class to access the private setDescription method
in ClientConfiguration, following the pattern suggested in the C++ client
documentation.

Fixes #3505
@shibd shibd changed the title Fix issue #3505: Set client description to identify Node.js client Set client description to identify Node.js client Jan 28, 2026
shibd added 2 commits January 28, 2026 21:48
- Add PULSAR_CLIENT_NODE_VERSION define in binding.gyp with hardcoded version "1.17.0-rc.0"
- Set client description to "node-client-v<version>" in Client.cc using C++ ClientConfiguration
- Remove unnecessary files: scripts/generate_version.js, scripts/generate_version.py, src/PulsarWrapper.cc, src/PulsarWrapper.h, src/version.h
- Update README.md to document release process

This fix allows Node.js clients to identify themselves in broker topic statistics as
"node-client-vX.Y.Z" instead of just the C++ client version.

Changes in binding.gyp:
- Added PULSAR_CLIENT_NODE_VERSION define with value "1.17.0-rc.0"

Changes in src/Client.cc:
- Added ostringstream include
- Set client description to "node-client-v1.17.0-rc.0" in Client constructor

Files removed:
- scripts/generate_version.js (not needed with hardcoded version)
- scripts/generate_version.py (not needed with hardcoded version)
- src/PulsarWrapper.cc (not needed with hardcoded version)
- src/PulsarWrapper.h (not needed with hardcoded version)
- src/version.h (not needed with hardcoded version)

Files modified:
- README.md (documented release process)
- binding.gyp (updated version define)
- src/Client.cc (added client description)
- package.json (version update, done via npm version command)
@shibd shibd marked this pull request as draft January 29, 2026 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant