BewareMyPower commented on code in PR #357:
URL:
https://github.com/apache/pulsar-client-node/pull/357#discussion_r1441262640
##########
src/Consumer.cc:
##########
@@ -192,36 +193,17 @@ struct ConsumerNewInstanceContext {
Napi::Value Consumer::NewInstance(const Napi::CallbackInfo &info,
std::shared_ptr<pulsar_client_t> cClient) {
auto deferred = ThreadSafeDeferred::New(info.Env());
auto config = info[0].As<Napi::Object>();
- std::shared_ptr<ConsumerConfig> consumerConfig =
std::make_shared<ConsumerConfig>(config, &MessageListener);
+ std::shared_ptr<ConsumerConfig> consumerConfig =
std::make_shared<ConsumerConfig>();
+
+ consumerConfig->InitConfig(deferred, config, &MessageListener);
+ if (deferred->IsDone()) {
+ return deferred->Promise();
+ }
const std::string &topic = consumerConfig->GetTopic();
const std::vector<std::string> &topics = consumerConfig->GetTopics();
const std::string &topicsPattern = consumerConfig->GetTopicsPattern();
- if (topic.empty() && topics.size() == 0 && topicsPattern.empty()) {
- deferred->Reject(
- std::string("Topic, topics or topicsPattern is required and must be
specified as a string when "
- "creating consumer"));
- return deferred->Promise();
- }
const std::string &subscription = consumerConfig->GetSubscription();
- if (subscription.empty()) {
- deferred->Reject(
- std::string("Subscription is required and must be specified as a
string when creating consumer"));
- return deferred->Promise();
- }
- int32_t ackTimeoutMs = consumerConfig->GetAckTimeoutMs();
- if (ackTimeoutMs != 0 && ackTimeoutMs < MIN_ACK_TIMEOUT_MILLIS) {
- std::string msg("Ack timeout should be 0 or greater than or equal to " +
- std::to_string(MIN_ACK_TIMEOUT_MILLIS));
- deferred->Reject(msg);
- return deferred->Promise();
- }
- int32_t nAckRedeliverTimeoutMs = consumerConfig->GetNAckRedeliverTimeoutMs();
- if (nAckRedeliverTimeoutMs < 0) {
- std::string msg("NAck timeout should be greater than or equal to zero");
- deferred->Reject(msg);
- return deferred->Promise();
Review Comment:
Why did you remove the checks 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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]