Skip to content

[Python] Return MessageId in producer's synchronous send method - #9287

Merged
sijie merged 2 commits into
apache:masterfrom
BewareMyPower:bewaremypower/fix-cpp-send-api
Jan 25, 2021
Merged

sijie merged 2 commits into
apache:masterfrom
BewareMyPower:bewaremypower/fix-cpp-send-api

Conversation

@BewareMyPower

@BewareMyPower BewareMyPower commented Jan 22, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #9176

Motivation

Currently Python producer's send method returns nothing. However, it should returns a MessageId at least.

Modifications

  • Add a new Producer#send API with an extra argument as the output argument of MessageId.
  • Improve the Producer#send related documents to ensure these methods can link to each other in Doxygen-generated websites.
  • Let Python client's Producer#send return a MessageId.
  • Add related tests.

It should be noted that the current C++ Producer::send's API design is strange and weird that it returns no MessageId explicitly. However it will set the input Message's internal MessageId field and there're no document about it, as well as the tests.

This API design is extremely terrible. I think without looking into the source code, no one could guess that the input const Message argument will modify its internal field after send is completed. So I add a new send method as a substitute and mark the old send method deprecated.

Verifying this change

  • Make sure that the change passes the CI checks.

This change added tests and can be verified as follows:

  • C++: ProducerTest#testSynchronouslySend
  • Python: PulsarTest.test_producer_send

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (yes)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • Does this pull request introduce a new feature? (yes)
  • If yes, how is the feature documented? (JavaDocs)

@BewareMyPower
BewareMyPower force-pushed the bewaremypower/fix-cpp-send-api branch from d45c17a to 25e1b04 Compare January 23, 2021 04:54
@BewareMyPower

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

1 similar comment
@BewareMyPower

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@sijie sijie added the doc-required Your PR changes impact docs and you will update later. label Jan 25, 2021
@sijie
sijie merged commit 0e6bbc8 into apache:master Jan 25, 2021
@BewareMyPower
BewareMyPower deleted the bewaremypower/fix-cpp-send-api branch January 25, 2021 02:45
codelipenghui pushed a commit that referenced this pull request Feb 19, 2021
Fixes #9176 

### Motivation

Currently Python producer's send method returns nothing. However, it should returns a `MessageId` at least. 

### Modifications

- Add a new `Producer#send` API with an extra argument as the output argument of `MessageId`.
- Improve the `Producer#send` related documents to ensure these methods can link to each other in Doxygen-generated websites.
- Let Python client's `Producer#send` return a `MessageId`.
- Add related tests.

It should be noted that the current C++ `Producer::send`'s API design is strange and weird that it returns no `MessageId` explicitly. However it will set the input `Message`'s internal `MessageId` field and there're no document about it, as well as the tests.

This API design is extremely terrible. I think without looking into the source code, no one could guess that the input **const** `Message` argument will **modify** its internal field after `send` is completed. So I add a new `send` method as a substitute and mark the old `send` method deprecated.

(cherry picked from commit 0e6bbc8)
@Anonymitaet Anonymitaet removed the doc-required Your PR changes impact docs and you will update later. label Mar 1, 2021
@Anonymitaet

Anonymitaet commented Mar 1, 2021 •

Copy link
Copy Markdown
Member

Doc is added and avaliable at here.
image

@Anonymitaet Anonymitaet added the doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. label Mar 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.7 Archived: 2.7 is end of life doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. release/2.7.1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python Client Producer Synchronous Send Void Return Value

6 participants