Skip to content

Commit

Permalink
[refactor] Not returning when calling handle_error_on_grpc_response
Browse files Browse the repository at this point in the history
Signed-off-by: dd di cesare <didi@posteo.net>
  • Loading branch information
didierofrivia committed Oct 7, 2024
1 parent f4c37ce commit 07211cf
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,28 +56,25 @@ impl GrpcService {

pub fn process_grpc_response(operation: Rc<Operation>, resp_size: usize) {
let failure_mode = operation.get_failure_mode();
let res_body_bytes =
match hostcalls::get_buffer(BufferType::GrpcReceiveBuffer, 0, resp_size).unwrap() {
Some(bytes) => bytes,
None => {
warn!("grpc response body is empty!");
if let Some(res_body_bytes) = hostcalls::get_buffer(BufferType::GrpcReceiveBuffer, 0, resp_size).unwrap() {
match GrpcMessageResponse::new(operation.get_extension_type(), &res_body_bytes) {
Ok(res) => {
match operation.get_extension_type() {
ExtensionType::Auth => AuthService::process_auth_grpc_response(res, failure_mode),
ExtensionType::RateLimit => {
RateLimitService::process_ratelimit_grpc_response(res, failure_mode)
}
}
}
Err(e) => {
warn!("failed to parse grpc response body into GrpcMessageResponse message: {e}");
GrpcService::handle_error_on_grpc_response(failure_mode);
return;
}
};
let res = match GrpcMessageResponse::new(operation.get_extension_type(), &res_body_bytes) {
Ok(res) => res,
Err(e) => {
warn!("failed to parse grpc response body into GrpcMessageResponse message: {e}");
}
else {
warn!("grpc response body is empty!");
GrpcService::handle_error_on_grpc_response(failure_mode);
return;
}
};
match operation.get_extension_type() {
ExtensionType::Auth => AuthService::process_auth_grpc_response(res, failure_mode),
ExtensionType::RateLimit => {
RateLimitService::process_ratelimit_grpc_response(res, failure_mode)
}
}
}

Expand Down

0 comments on commit 07211cf

Please sign in to comment.