Repository navigation
[feat][cpp] Add async receive function to C API - #17452
Conversation
7a975c8 to
66765af
Compare
|
/pulsarbot rerun-failure-checks |
BewareMyPower
left a comment
There was a problem hiding this comment.
Could you add a basic e2e test for demonstrate it works? I found currently there are nearly no C API related tests. But for new APIs, we should add some tests.
Okay. I'll address it. |
| pulsar_message_t *received_msg; | ||
| receive_promise.getFuture().get(received_msg); | ||
| ASSERT_STREQ(content, static_cast<const char *>(pulsar_message_get_data(received_msg))); | ||
| pulsar_message_free(received_msg); |
There was a problem hiding this comment.
I think we should release the received_msg after the callback is done. It's better to use pure C semantics here, i.e. use C functions instead of lambda, and do not use pulsar::Promise, we should define a C struct and pass it to ctx.
There was a problem hiding this comment.
I'll modify it.
However, I also use pulsar::Promise to wait for the callback completion in the test thread.
To achieve this process, I'll use std::future instead of conditional wait, etc.
Master Issue: #14452
Motivation
I want to rewrite the pulsar-client-node
receivemethod to rely exclusively on async operations rather than worker threads.However, an async receive function is not defined currently in C API.
Modifications
pulsar_consumer_receive_asyncandpulsar_receive_callbackto use async receive operation in C APIVerifying this change
(Please pick either of the following options)
This change is already covered by existing tests, such as C++ tests.
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changespulsar/pulsar-client-cpp/include/pulsar/c/consumer.h
Line 36 in 66765af
pulsar/pulsar-client-cpp/include/pulsar/c/consumer.h
Lines 100 to 108 in 66765af
Documentation
Check the box below or label this PR directly.
Need to update docs?
doc-not-needed