Set client description to identify Node.js client#454
Draft
Conversation
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
- 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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes automatically setting the client description to
"node-client-vX.Y.Z"whereX.Y.Zis the Node.js client version from package.json. After this fix, theclientVersionin 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
PULSAR_CLIENT_NODE_VERSIONdefine to read version from package.json at build time"node-client-v<version>"format in client constructordescriptionparameter fromClientConfig(not needed, automatic)Result
After this fix,
clientVersionin topic stats will display as:"Pulsar-CPP-v4.0.0-node-client-v1.17.0-rc.0"Pulsar-CPP-v4.0.0): C++ client version-node-client-v1.17.0-rc.0): Node.js client identifier and versionBackward Compatibility
This change is fully backward compatible. Existing code will continue to work without any changes. The only visible change is that
clientVersionin topic statistics will now include the Node.js client identifier.