From 87fc65c5fc6704d0168314cf505f7707ac24b1b6 Mon Sep 17 00:00:00 2001 From: Rory Schadler <48921090+roryschadler@users.noreply.github.com> Date: Fri, 8 Dec 2023 11:45:36 -0500 Subject: [PATCH] Allow passing listenerName to client config --- index.d.ts | 1 + src/Client.cc | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/index.d.ts b/index.d.ts index c416ee2a..4680d81a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -30,6 +30,7 @@ export interface ClientConfig { tlsValidateHostname?: boolean; tlsAllowInsecureConnection?: boolean; statsIntervalInSeconds?: number; + listenerName?: string; log?: (level: LogLevel, file: string, line: number, message: string) => void; } diff --git a/src/Client.cc b/src/Client.cc index f557a089..e3cbb729 100644 --- a/src/Client.cc +++ b/src/Client.cc @@ -40,6 +40,7 @@ static const std::string CFG_TLS_VALIDATE_HOSTNAME = "tlsValidateHostname"; static const std::string CFG_TLS_ALLOW_INSECURE = "tlsAllowInsecureConnection"; static const std::string CFG_STATS_INTERVAL = "statsIntervalInSeconds"; static const std::string CFG_LOG = "log"; +static const std::string CFG_LISTENER_NAME = "listenerName"; LogCallback *Client::logCallback = nullptr; @@ -186,6 +187,11 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap(info) pulsar_client_configuration_set_stats_interval_in_seconds(cClientConfig.get(), statsIntervalInSeconds); } + if (clientConfig.Has(CFG_LISTENER_NAME) && clientConfig.Get(CFG_LISTENER_NAME).IsString()) { + Napi::String listenerName = clientConfig.Get(CFG_LISTENER_NAME).ToString(); + pulsar_client_configuration_set_listener_name(cClientConfig.get(), listenerName.Utf8Value().c_str()); + } + try { this->cClient = std::shared_ptr( pulsar_client_create(serviceUrl.Utf8Value().c_str(), cClientConfig.get()), pulsar_client_free);