diff --git a/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs b/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs --- a/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs +++ b/native/cpp/CommonCpp/grpc/grpc_client/src/lib.rs @@ -338,11 +338,7 @@ })?, )), }; - if let Err(e) = tx.send(registration_request).await { - error!("Response was dropped: {}", e); - return Err(Status::aborted("Dropped response")); - } - Ok(()) + send_to_mpsc(tx, registration_request).await } else { Err(handle_unexpected_registration_response(message)) } @@ -378,3 +374,14 @@ Registration(RegistrationResponseAndSender), Login(LoginResponseAndSender), } + +async fn send_to_mpsc( + tx: mpsc::Sender, + request: T, +) -> Result<(), Status> { + if let Err(e) = tx.send(request).await { + error!("Response was dropped: {}", e); + return Err(Status::aborted("Dropped response")); + } + Ok(()) +}