This is an automated email from the ASF dual-hosted git repository.

nkurihar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar-client-node.git


The following commit(s) were added to refs/heads/master by this push:
     new 1343f7a  support disable replication (#149)
1343f7a is described below

commit 1343f7a86e48ed04d2df0f446568b038af5082ed
Author: k2la <[email protected]>
AuthorDate: Wed Apr 7 09:54:10 2021 +0900

    support disable replication (#149)
    
    Co-authored-by: yfuruta <[email protected]>
---
 src/Message.cc | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/Message.cc b/src/Message.cc
index d93264e..fc0e82c 100644
--- a/src/Message.cc
+++ b/src/Message.cc
@@ -29,6 +29,7 @@ static const std::string CFG_PARTITION_KEY = "partitionKey";
 static const std::string CFG_REPL_CLUSTERS = "replicationClusters";
 static const std::string CFG_DELIVER_AFTER = "deliverAfter";
 static const std::string CFG_DELIVER_AT = "deliverAt";
+static const std::string CFG_DISABLE_REPLICATION = "disableReplication";
 
 Napi::FunctionReference Message::constructor;
 
@@ -206,6 +207,13 @@ pulsar_message_t *Message::BuildMessage(Napi::Object conf) 
{
     Napi::Number deliverAt = conf.Get(CFG_DELIVER_AT).ToNumber();
     pulsar_message_set_deliver_at(cMessage, deliverAt.Int64Value());
   }
+
+  if (conf.Has(CFG_DISABLE_REPLICATION) && 
conf.Get(CFG_DISABLE_REPLICATION).IsBoolean()) {
+    Napi::Boolean disableReplication = 
conf.Get(CFG_DISABLE_REPLICATION).ToBoolean();
+    if (disableReplication.Value()) {
+      pulsar_message_disable_replication(cMessage, 1);
+    }
+  }
   return cMessage;
 }
 

Reply via email to