shibd commented on code in PR #169:
URL: https://github.com/apache/pulsar-client-cpp/pull/169#discussion_r1066668816


##########
include/pulsar/ProducerConfiguration.h:
##########
@@ -532,6 +533,10 @@ class PULSAR_PUBLIC ProducerConfiguration {
      */
     ProducerAccessMode getAccessMode() const;
 
+    ProducerConfiguration& intercept(const 
std::initializer_list<ProducerInterceptorPtr> interceptors);

Review Comment:
   Is it better to pass a reference here?



##########
include/pulsar/Producer.h:
##########
@@ -23,13 +23,16 @@
 #include <pulsar/defines.h>
 #include <stdint.h>
 
+#include <functional>
 #include <memory>
 
 namespace pulsar {
 class ProducerImplBase;
 class PulsarWrapper;
 class PulsarFriend;
 
+typedef std::function<void(Result, const MessageId& messageId)> SendCallback;

Review Comment:
   You don't need to redefine these here. Remove the import of `Producer.h` 
from `ProducerInterceptor.h` and the compilation will succeed
   



##########
include/pulsar/ProducerInterceptor.h:
##########
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef PULSAR_PRODUCER_INTERCEPTOR_H
+#define PULSAR_PRODUCER_INTERCEPTOR_H
+
+#include <pulsar/Message.h>
+#include <pulsar/Producer.h>

Review Comment:
   Line 40 `Producer` has been declared. There is no need to import 
`Producer.h` here. 



##########
include/pulsar/ProducerInterceptor.h:
##########
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef PULSAR_PRODUCER_INTERCEPTOR_H
+#define PULSAR_PRODUCER_INTERCEPTOR_H
+
+#include <pulsar/Message.h>
+#include <pulsar/Producer.h>
+#include <pulsar/defines.h>
+
+/**
+ * An interface that allows you to intercept (and possibly mutate) the
+ * messages received by the producer before they are published to the Pulsar
+ * brokers.
+ *
+ * <p>Exceptions thrown by ProducerInterceptor methods will be caught, logged, 
but
+ * not propagated further.
+ *
+ * <p>ProducerInterceptor callbacks may be called from multiple threads. 
Interceptor
+ * implementation must ensure thread-safety, if needed.
+ */
+namespace pulsar {
+
+class Producer;
+
+class PULSAR_PUBLIC ProducerInterceptor {
+   public:
+    virtual ~ProducerInterceptor() {}
+
+    /**
+     * Close the interceptor
+     */
+    virtual void close() {}

Review Comment:
   When the producer close, do we need to invoke this close()? I see this is 
not invoked in Java Client, maybe it a bug?
   
   



##########
include/pulsar/ProducerConfiguration.h:
##########
@@ -532,6 +533,10 @@ class PULSAR_PUBLIC ProducerConfiguration {
      */
     ProducerAccessMode getAccessMode() const;
 
+    ProducerConfiguration& intercept(const 
std::initializer_list<ProducerInterceptorPtr> interceptors);
+
+    std::vector<ProducerInterceptorPtr> getInterceptors() const;

Review Comment:
   return `const std::vector<ProducerInterceptorPtr>&`?



##########
include/pulsar/ProducerInterceptor.h:
##########
@@ -0,0 +1,114 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+#ifndef PULSAR_PRODUCER_INTERCEPTOR_H
+#define PULSAR_PRODUCER_INTERCEPTOR_H
+
+#include <pulsar/Message.h>
+#include <pulsar/Producer.h>

Review Comment:
   ProducerInterceptor.h  -> Producer.h -> ProducerConfiguration.h -> 
ProducerInterceptor.h
   
   



-- 
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: commits-unsubscr...@pulsar.apache.org

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

Reply via email to