Skip to content

Commit

Permalink
Allow passing listenerName to client config
Browse files Browse the repository at this point in the history
  • Loading branch information
roryschadler committed Apr 4, 2024
1 parent f0f16f4 commit 87fc65c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 6 additions & 0 deletions src/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -186,6 +187,11 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(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_t>(
pulsar_client_create(serviceUrl.Utf8Value().c_str(), cClientConfig.get()), pulsar_client_free);
Expand Down

0 comments on commit 87fc65c

Please sign in to comment.