Reputation: 69
I want to fail a grpc call based on a condition, ideally the interceptor returns an http error to the client before the rpc implementation on the server is reached. The interceptor is on the server side. I know my interceptor gets called since I get log output, but no matter which function from the reference I try the rpc functions on the server get normally.
I am also a little confused about the Interception Hooks. If I understand correctly the PRE_SEND_MESSAGE hook is called right after the metadata is sent where I have access to the message that was sent from the client.
void RejectInteceptor::Intercept(InteceptionHookPoints methods) {
if (methods->QueryInterceptionHookPoint(InterceptionHookPoints::PRE_SEND_MESSAGE)) {
if (checkBackendTask()) {
std::cout << "Fail the rpc call" << std::endl;
Status status(StatusCode::UNAVAILABLE, "Service unavailable");
methods->ModifySendStatus(status);
methods->FailHijackedRecvMessage();
return;
}
methods->Proceed();
}
}
Upvotes: 0
Views: 38