-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Async call for broker stats #305
Conversation
@merlimat @saandrews @msb-at-yahoo - Can you please give me a +1 on this - need to get it into production |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but try to get more @msb-at-yahoo or @saandrews to check it as well
can you rebase this to one commit? |
@msb-at-yahoo Merging the PR will anyway force a squash. I've configured github to only leave that option ;) |
private: | ||
boost::shared_ptr<BrokerConsumerStatsImplBase> impl_; | ||
public: | ||
BrokerConsumerStats(boost::shared_ptr<BrokerConsumerStatsImplBase> impl); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this constructor should be explicit
|
||
friend std::ostream& operator<<(std::ostream &os, const BrokerConsumerStats &obj); | ||
}; | ||
typedef boost::shared_ptr<BrokerConsumerStats> BrokerConsumerStatsPtr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need a shared_ptr here if BrokerConsumerStats is already basically a shared_ptr and is allowed to be invalid?
} | ||
|
||
double BrokerConsumerStats::getMsgRateOut() const { | ||
if (impl_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be more idiomatic to just document that no getXXX is allowed on an invalid BrokerConsumerStats object and get rid of the check. that avoids hiding bugs.
f4933c8
to
c5a2404
Compare
…ageID for ReaderOptions (apache#305) ### Motivation User of the client's client's [CreateReader](https://github.com/apache/pulsar-client-go/blob/master/pulsar/client.go#L109) API can use a custom type satisfying the [MessageID](https://github.com/apache/pulsar-client-go/blob/master/pulsar/message.go#L108) interface, when using it as a value for `StartMessageID` in [ReaderOptions](https://github.com/apache/pulsar-client-go/blob/master/pulsar/reader.go#L48) argument for the mentioned API. The current reader creation does an untested type assertion here, when preparing the `consumerOptions` needed for creating a `partitionConsumer`. https://github.com/apache/pulsar-client-go/blob/master/pulsar/reader_impl.go#L64 This assertion of `MessageID` as `*messageID` will fail unless an instance of `MessageID` is created from one of these exported APIs because `messageID` is unexported https://github.com/apache/pulsar-client-go/blob/master/pulsar/message.go#L114-#L126 Note: `newMessageID` returns `*messageID` which satisfies `MessageID` interface as well. ### Modifications Test the type assertion of `MessageID` as `*messageID`, if it fails, re-create a new `MessageID` using this https://github.com/apache/pulsar-client-go/blob/975eb3781644ebe588fc142e53eadf39fe50341a/pulsar/impl_message.go#L97 This will ensure that the custom type can be re-created as a `*messageID` which can be used by `partitionConsumerOpts`
Fixes apache#299 PulsarEntryFormatter doesn't handle null value correctly now. If a message with null value was sent by a producer, the consumer will receive a message with an empty string. This PR fixes the bug and adds to tests to verify KoP could handle the null value no matter what the entry format is.
Motivation
Added async call for getBrokerConsumerStats and refactored the code to keep partitions abstract.
Modifications
Almost all Consumer* files modified to support BrokerConsumerStats
Result