You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/05 08:33:44 UTC

[GitHub] [pulsar] shibd commented on a diff in pull request #17209: [feature][client-cpp] Support inclusive seek for cpp client

shibd commented on code in PR #17209:
URL: https://github.com/apache/pulsar/pull/17209#discussion_r962612803


##########
pulsar-client-cpp/python/pulsar_test.py:
##########
@@ -543,7 +543,7 @@ def test_reader_on_specific_message(self):
         # The reset would be effectively done on the next position relative to reset.

Review Comment:
   Why need to change the python unit test? This PR does not change the previous behavior, right?



##########
pulsar-client-cpp/lib/ConsumerImpl.cc:
##########
@@ -1380,4 +1365,51 @@ bool ConsumerImpl::isConnected() const { return !getCnx().expired() && state_ ==
 
 uint64_t ConsumerImpl::getNumberOfConnectedConsumer() { return isConnected() ? 1 : 0; }
 
+void ConsumerImpl::seekAsyncInternal(long requestId, SharedBuffer seek, const MessageId& seekId,
+                                     long timestamp, ResultCallback callback) {
+    ClientConnectionPtr cnx = getCnx().lock();
+    if (!cnx) {
+        LOG_ERROR(getName() << " Client Connection not ready for Consumer");
+        callback(ResultNotConnected);
+        return;
+    }
+
+    const auto originalSeekMessageId = seekMessageId_.get();
+    seekMessageId_ = seekId;
+    duringSeek_ = true;
+    if (timestamp > 0) {
+        LOG_INFO(getName() << " Seeking subscription to " << timestamp);
+    } else {
+        LOG_INFO(getName() << " Seeking subscription to " << seekId);
+    }
+
+    auto self = shared_from_this();

Review Comment:
   It is recommended to use `weak_ptr`, which can be avoided circular references.
   
   when using it.
   ```c++
   auto self = weakSelf.lock();
   if(self) {
   // do something.
   }
   ```



-- 
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-unsubscribe@pulsar.apache.org

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