[#13] object/grpc: Fix Put call implementation

Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
Leonard Lyubich 2020-08-25 18:42:57 +03:00 committed by Alex Vanin
parent 5caabf4208
commit d03b153e09

View file

@ -57,22 +57,22 @@ func (s *Server) Put(gStream objectGRPC.ObjectService_PutServer) error {
for { for {
req, err := gStream.Recv() req, err := gStream.Recv()
if err == nil { if err != nil {
if err := stream.Send(object.PutRequestFromGRPCMessage(req)); err != nil { if errors.Is(errors.Cause(err), io.EOF) {
return err resp, err := stream.CloseAndRecv()
} if err != nil {
} return err
}
if errors.Is(errors.Cause(err), io.EOF) { return gStream.SendAndClose(object.PutResponseToGRPCMessage(resp))
resp, err := stream.CloseAndRecv()
if err != nil {
return err
} }
return gStream.SendAndClose(object.PutResponseToGRPCMessage(resp)) return err
} }
return err if err := stream.Send(object.PutRequestFromGRPCMessage(req)); err != nil {
return err
}
} }
} }