thorneliu commented on code in PR #2137:
URL: https://github.com/apache/brpc/pull/2137#discussion_r1126454968
##########
src/brpc/server.cpp:
##########
@@ -2197,6 +2197,21 @@ int Server::MaxConcurrencyOf(google::protobuf::Service*
service,
return MaxConcurrencyOf(service->GetDescriptor()->full_name(),
method_name);
}
+bool Server::AcceptRequest(Controller* cntl) const {
+ const Interceptor* interceptor = _options.interceptor;
Review Comment:
Most LIKELY, the interceptor is NULL for a non-interception policy.
So I think we could firstly check the nullity of interceptor and hence
error_code and error_text will be in smaller scope iff interceptor is valid,
for better performance.
```
if (!interceptor) {
return true;
}
int error_code = 0;
std::string error_text;
if (!interceptor->Accept(cntl, error_code, error_text)) {
cntl->SetFailed(error_code, "Reject by Interceptor: %s",
error_text.c_str());
return false;
}
return true;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]