You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/04/01 02:56:48 UTC

[GitHub] [pulsar-client-node] massakam commented on a change in pull request #200: convert worker threads to async functions

massakam commented on a change in pull request #200:
URL: https://github.com/apache/pulsar-client-node/pull/200#discussion_r840192801



##########
File path: src/Client.cc
##########
@@ -40,14 +41,43 @@ static const std::string CFG_TLS_ALLOW_INSECURE = "tlsAllowInsecureConnection";
 static const std::string CFG_STATS_INTERVAL = "statsIntervalInSeconds";
 static const std::string CFG_LOG = "log";
 
+LogCallback *Client::logCallback = nullptr;
+
+void Client::SetLogHandler(const Napi::CallbackInfo &info) {
+  Napi::Env env = info.Env();
+  Napi::HandleScope scope(env);
+  Napi::Value jsFunction = info[0];
+
+  if (jsFunction.IsNull()) {
+    if (Client::logCallback != nullptr) {
+      Client::logCallback->callback.Release();
+      delete Client::logCallback;
+      Client::logCallback = nullptr;
+    }
+  } else if (jsFunction.IsFunction()) {
+    Napi::ThreadSafeFunction logFunction =
+        Napi::ThreadSafeFunction::New(env, jsFunction.As<Napi::Function>(), "Pulsar Logging", 0, 1);
+    logFunction.Unref(env);

Review comment:
       [question] What is the reason for doing `Unref` here?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org