2626#include < pulsar/c/client.h>
2727#include < pulsar/c/client_configuration.h>
2828#include < pulsar/c/result.h>
29+ #include " pulsar/ClientConfiguration.h"
2930
3031static const std::string CFG_SERVICE_URL = " serviceUrl" ;
3132static const std::string CFG_AUTH = " authentication" ;
@@ -42,9 +43,14 @@ static const std::string CFG_STATS_INTERVAL = "statsIntervalInSeconds";
4243static const std::string CFG_LOG = " log" ;
4344static const std::string CFG_LOG_LEVEL = " logLevel" ;
4445static const std::string CFG_LISTENER_NAME = " listenerName" ;
46+ static const std::string CFG_CONNECTION_TIMEOUT = " connectionTimeoutMs" ;
4547
4648LogCallback *Client::logCallback = nullptr ;
4749
50+ struct _pulsar_client_configuration {
51+ pulsar::ClientConfiguration conf;
52+ };
53+
4854void Client::SetLogHandler (const Napi::CallbackInfo &info) {
4955 Napi::Env env = info.Env ();
5056 Napi::HandleScope scope (env);
@@ -157,6 +163,13 @@ Client::Client(const Napi::CallbackInfo &info) : Napi::ObjectWrap<Client>(info)
157163 }
158164 }
159165
166+ if (clientConfig.Has (CFG_CONNECTION_TIMEOUT ) && clientConfig.Get (CFG_CONNECTION_TIMEOUT ).IsNumber ()) {
167+ int32_t connectionTimeoutMs = clientConfig.Get (CFG_CONNECTION_TIMEOUT ).ToNumber ().Int32Value ();
168+ if (connectionTimeoutMs > 0 ) {
169+ cClientConfig.get ()->conf .setConnectionTimeout (connectionTimeoutMs);
170+ }
171+ }
172+
160173 if (clientConfig.Has (CFG_LISTENER_THREADS ) && clientConfig.Get (CFG_LISTENER_THREADS ).IsNumber ()) {
161174 int32_t messageListenerThreads = clientConfig.Get (CFG_LISTENER_THREADS ).ToNumber ().Int32Value ();
162175 if (messageListenerThreads > 0 ) {
0 commit comments