Skip to content
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

support handle on_received_messages failure of streaming rpc #1804

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/brpc/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,12 @@ class MessageBatcher {
~MessageBatcher() { flush(); }
void flush() {
if (_size > 0 && _s->_options.handler != NULL) {
_s->_options.handler->on_received_messages(
int ret = _s->_options.handler->on_received_messages(
_s->id(), _storage, _size);
if (BAIDU_UNLIKELY(ret != 0)) {
LOG(WARNING) << "Fail to receive message for stream: " << _s->id();
_s->_options.handler->on_failure(_s->id());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's unnecessary to call on_failure here. Since user knows what will return from on_received_messages, they can call on_failure in on_received_messages.

}
}
for (size_t i = 0; i < _size; ++i) {
delete _storage[i];
Expand Down
1 change: 1 addition & 0 deletions src/brpc/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class StreamInputHandler {
size_t size) = 0;
virtual void on_idle_timeout(StreamId id) = 0;
virtual void on_closed(StreamId id) = 0;
virtual void on_failure(StreamId id) {}
};

struct StreamOptions {
Expand Down