Skip to content

Improve the C APIs for batch receive policy and fix the wrong documents - #256

Merged
shibd merged 1 commit into
apache:mainfrom
BewareMyPower:bewaremypower/c-api-batch-receive-policy
Apr 21, 2023
Merged

Improve the C APIs for batch receive policy and fix the wrong documents#256
shibd merged 1 commit into
apache:mainfrom
BewareMyPower:bewaremypower/c-api-batch-receive-policy

Conversation

@BewareMyPower

Copy link
Copy Markdown
Contributor

Motivation

Currently, the pulsar_consumer_configuration_get_batch_receive_policy function returns a struct whose size is greater than 8, which is generally not acceptable in C API design because of the copy overhead.

And the API documents are wrong that they say if the value is less than 0, it means no limit. However, if the value is exactly 0, it also means no limit.

Modifications

Use the POSIX style for these C APIs. The setter returns -1 if it failed. The getter accepts an output argument to store the value to get.

Then test these changes in testCApiConfig. The docs are also fixed.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

### Motivation

Currently, the `pulsar_consumer_configuration_get_batch_receive_policy`
function returns a struct whose size is greater than 8, which is
generally not acceptable in C API design because of the copy overhead.

And the API documents are wrong that they say if the value is less than
0, it means no limit. However, if the value is exactly 0, it also means
no limit.

### Modifications

Use the POSIX style for these C APIs. The setter returns -1 if it
failed. The getter accepts an output argument to store the value to get.

Then test these changes in `testCApiConfig`. The docs are also fixed.
@BewareMyPower BewareMyPower added the enhancement New feature or request label Apr 20, 2023
@BewareMyPower BewareMyPower added this to the 3.2.0 milestone Apr 20, 2023
@BewareMyPower BewareMyPower self-assigned this Apr 20, 2023
Comment thread include/pulsar/c/consumer_configuration.h
shibd
shibd previously approved these changes Apr 20, 2023
@shibd
shibd self-requested a review April 20, 2023 14:20
@shibd
shibd dismissed their stale review April 20, 2023 14:20

oh, sorry, CI did not pass.

@BewareMyPower

Copy link
Copy Markdown
Contributor Author

It's weird there is no helpful error prompt. I reran the CI first.

@BewareMyPower

Copy link
Copy Markdown
Contributor Author

I reverted this PR and could still reproduce the build failure in my local env.

/home/xyz/pulsar-client-cpp/build/lib/libpulsar.so: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
make[2]: *** [tests/CMakeFiles/ConnectionFailTest.dir/build.make:129: tests/ConnectionFailTest] Error 1
make[1]: *** [CMakeFiles/Makefile2:734: tests/CMakeFiles/ConnectionFailTest.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
...
[ 87%] Linking CXX executable pulsar-tests
[ 87%] Built target pulsar-tests
make: *** [Makefile:136: all] Error 2

It seems related to compiling with 8 threads. Maybe we need some further improvements for the build process.

@shibd
shibd merged commit 8f96463 into apache:main Apr 21, 2023
@BewareMyPower
BewareMyPower deleted the bewaremypower/c-api-batch-receive-policy branch April 21, 2023 02:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants