-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix topic not shown correctly in the consumer string #329
Merged
BewareMyPower
merged 1 commit into
apache:main
from
BewareMyPower:bewaremypower/fix-consumer-str
Oct 16, 2023
Merged
Fix topic not shown correctly in the consumer string #329
BewareMyPower
merged 1 commit into
apache:main
from
BewareMyPower:bewaremypower/fix-consumer-str
Oct 16, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Motivation `ConsumerImpl::getName()` returns a string that is used in logs to represent the consumer. However, the topic part does not show correctly: ``` ConsumerImpl:283 | [0x6000001c88b8, consumer-1, 0] Created consumer on broker [127.0.0.1:60399 -> 127.0.0.1:6650] ``` It's because after apache#218, the `ConsumerImpl::topic_` field becomes `std::shared_ptr` rather than a `std::string` but it is still used to construct the `consumerStr_`. ### Modifications Construct the `consumerStr_` using the `topic` argument in the constructor and make `consumerStr_` const because it is never changed. Now the logs will be like: ``` ConsumerImpl:280 | [persistent://public/default/my-topic, consumer-1, 0] Created consumer on broker [127.0.0.1:60647 -> 127.0.0.1:6650] ```
shibd
approved these changes
Oct 16, 2023
Demogorgon314
approved these changes
Oct 16, 2023
BewareMyPower
added a commit
to BewareMyPower/pulsar-client-cpp
that referenced
this pull request
Oct 20, 2023
### Motivation This is an additional fix to apache#329 because I still observed logs like: ``` Closing consumer for topic 0x6000028e0648 Closing producer for topic 0x600001210b88 ``` It's because `HandlerBase::topic_` field is protected and could be accessed directly from the derived classes. ### Motivation In `HandlerBase`, make `topic_` private and add two methods `topic()` and `getTopicPtr()` to get the reference to the string and the shared pointer. `getTopicPtr()` should only be called when being passed to `MessageImpl::setTopicName`.
BewareMyPower
added a commit
to streamnative/pulsar-client-cpp
that referenced
this pull request
Oct 20, 2023
### Motivation `ConsumerImpl::getName()` returns a string that is used in logs to represent the consumer. However, the topic part does not show correctly: ``` ConsumerImpl:283 | [0x6000001c88b8, consumer-1, 0] Created consumer on broker [127.0.0.1:60399 -> 127.0.0.1:6650] ``` It's because after apache#218, the `ConsumerImpl::topic_` field becomes `std::shared_ptr` rather than a `std::string` but it is still used to construct the `consumerStr_`. ### Modifications Construct the `consumerStr_` using the `topic` argument in the constructor and make `consumerStr_` const because it is never changed. Now the logs will be like: ``` ConsumerImpl:280 | [persistent://public/default/my-topic, consumer-1, 0] Created consumer on broker [127.0.0.1:60647 -> 127.0.0.1:6650] ``` (cherry picked from commit 33085eb)
BewareMyPower
added a commit
that referenced
this pull request
Oct 20, 2023
### Motivation This is an additional fix to #329 because I still observed logs like: ``` Closing consumer for topic 0x6000028e0648 Closing producer for topic 0x600001210b88 ``` It's because `HandlerBase::topic_` field is protected and could be accessed directly from the derived classes. ### Motivation In `HandlerBase`, make `topic_` private and add two methods `topic()` and `getTopicPtr()` to get the reference to the string and the shared pointer. `getTopicPtr()` should only be called when being passed to `MessageImpl::setTopicName`.
BewareMyPower
added a commit
to streamnative/pulsar-client-cpp
that referenced
this pull request
Oct 20, 2023
### Motivation This is an additional fix to apache#329 because I still observed logs like: ``` Closing consumer for topic 0x6000028e0648 Closing producer for topic 0x600001210b88 ``` It's because `HandlerBase::topic_` field is protected and could be accessed directly from the derived classes. ### Motivation In `HandlerBase`, make `topic_` private and add two methods `topic()` and `getTopicPtr()` to get the reference to the string and the shared pointer. `getTopicPtr()` should only be called when being passed to `MessageImpl::setTopicName`. (cherry picked from commit 7cefe0e)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
ConsumerImpl::getName()
returns a string that is used in logs to represent the consumer. However, the topic part does not show correctly:It's because after #218, the
ConsumerImpl::topic_
field becomesstd::shared_ptr
rather than astd::string
but it is still used to construct theconsumerStr_
.Modifications
Construct the
consumerStr_
using thetopic
argument in the constructor and makeconsumerStr_
const because it is never changed.Now the logs will be like: