You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by hr...@apache.org on 2020/02/20 07:13:03 UTC
[pulsar-client-node] branch master updated: Add read compacted
option to consumer options. (#73)
This is an automated email from the ASF dual-hosted git repository.
hrsakai 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 36219b9 Add read compacted option to consumer options. (#73)
36219b9 is described below
commit 36219b97e7203a4ef44341e337144c961e1f4d41
Author: Michael Kaufman <20...@users.noreply.github.com>
AuthorDate: Thu Feb 20 02:12:54 2020 -0500
Add read compacted option to consumer options. (#73)
* 1.1.0-rc.1
* Add read compacted option to consumer options.
* Adds read compacted to reader.
Co-authored-by: hrsakai <hs...@yahoo-corp.jp>
---
src/ConsumerConfig.cc | 8 ++++++++
src/ReaderConfig.cc | 8 ++++++++
2 files changed, 16 insertions(+)
diff --git a/src/ConsumerConfig.cc b/src/ConsumerConfig.cc
index 10963bd..1f734df 100644
--- a/src/ConsumerConfig.cc
+++ b/src/ConsumerConfig.cc
@@ -35,6 +35,7 @@ static const std::string CFG_RECV_QUEUE_ACROSS_PARTITIONS = "receiverQueueSizeAc
static const std::string CFG_CONSUMER_NAME = "consumerName";
static const std::string CFG_PROPS = "properties";
static const std::string CFG_LISTENER = "listener";
+static const std::string CFG_READ_COMPACTED = "readCompacted";
static const std::map<std::string, pulsar_consumer_type> SUBSCRIPTION_TYPE = {
{"Exclusive", pulsar_ConsumerExclusive},
@@ -163,6 +164,13 @@ ConsumerConfig::ConsumerConfig(const Napi::Object &consumerConfig,
pulsar_consumer_configuration_set_message_listener(this->cConsumerConfig, &MessageListener,
this->listener);
}
+
+ if (consumerConfig.Has(CFG_READ_COMPACTED) && consumerConfig.Get(CFG_READ_COMPACTED).IsBoolean()) {
+ bool readCompacted = consumerConfig.Get(CFG_READ_COMPACTED).ToBoolean();
+ if (readCompacted) {
+ pulsar_consumer_set_read_compacted(this->cConsumerConfig, 1);
+ }
+ }
}
ConsumerConfig::~ConsumerConfig() {
diff --git a/src/ReaderConfig.cc b/src/ReaderConfig.cc
index 7e15807..040d98f 100644
--- a/src/ReaderConfig.cc
+++ b/src/ReaderConfig.cc
@@ -26,6 +26,7 @@ static const std::string CFG_START_MESSAGE_ID = "startMessageId";
static const std::string CFG_RECV_QUEUE = "receiverQueueSize";
static const std::string CFG_READER_NAME = "readerName";
static const std::string CFG_SUBSCRIPTION_ROLE_PREFIX = "subscriptionRolePrefix";
+static const std::string CFG_READ_COMPACTED = "readCompacted";
ReaderConfig::ReaderConfig(const Napi::Object &readerConfig) : topic(""), cStartMessageId(NULL) {
this->cReaderConfig = pulsar_reader_configuration_create();
@@ -59,6 +60,13 @@ ReaderConfig::ReaderConfig(const Napi::Object &readerConfig) : topic(""), cStart
if (!subscriptionRolePrefix.empty())
pulsar_reader_configuration_set_reader_name(this->cReaderConfig, subscriptionRolePrefix.c_str());
}
+
+ if (readerConfig.Has(CFG_READ_COMPACTED) && readerConfig.Get(CFG_READ_COMPACTED).IsBoolean()) {
+ bool readCompacted = readerConfig.Get(CFG_READ_COMPACTED).ToBoolean();
+ if (readCompacted) {
+ pulsar_reader_configuration_set_read_compacted(this->cReaderConfig, 1);
+ }
+ }
}
ReaderConfig::~ReaderConfig() { pulsar_reader_configuration_free(this->cReaderConfig); }