This is an automated email from the ASF dual-hosted git repository. baodi pushed a commit to branch fix/issue-3505 in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git
commit db33dba8d4a35692bb1617d052d62f37eb2764e7 Author: Baodi Shi <[email protected]> AuthorDate: Wed Jan 28 19:41:32 2026 +0800 Fix issue #3505: Set client description to identify Node.js client 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 --- index.d.ts | 1 + src/Client.cc | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/index.d.ts b/index.d.ts index b85b623..6682b83 100644 --- a/index.d.ts +++ b/index.d.ts @@ -36,6 +36,7 @@ export interface ClientConfig { log?: (level: LogLevel, file: string, line: number, message: string) => void; logLevel?: LogLevel; connectionTimeoutMs?: number; + description?: string; } export class Client { diff --git a/src/Client.cc b/src/Client.cc index 29d542c..19f8bc0 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -46,6 +46,7 @@ static const std::string CFG_LOG = "log"; static const std::string CFG_LOG_LEVEL = "logLevel"; static const std::string CFG_LISTENER_NAME = "listenerName"; static const std::string CFG_CONNECTION_TIMEOUT = "connectionTimeoutMs"; +static const std::string CFG_DESCRIPTION = "description"; LogCallback *Client::logCallback = nullptr; @@ -232,6 +233,13 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(info) pulsar_client_configuration_set_listener_name(cClientConfig.get(), listenerName.Utf8Value().c_str()); } + // Set client description to identify this as the Node.js client + std::string description = "node"; + if (clientConfig.Has(CFG_DESCRIPTION) && clientConfig.Get(CFG_DESCRIPTION).IsString()) { + description = clientConfig.Get(CFG_DESCRIPTION).ToString().Utf8Value(); + } + cClientConfig.get()->conf.setDescription(description); + try { this->cClient = std::shared_ptr<pulsar_client_t>( pulsar_client_create(serviceUrl.Utf8Value().c_str(), cClientConfig.get()), pulsar_client_free);
