forked from TrueCloudLab/frostfs-sdk-go
[#218] client: Decode status at io.EOF in the client-side stream
Object service of NeoFS API contains one client-side stream method: object.Put. In client-side streams, server can return an error after processing stream message. In this case write method returns `io.EOF` and actual error reason is encoded in response status, which is obtained after `Close()`. Client library should process such case. Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
1ed426b8a6
commit
6e81e13e1b
1 changed files with 6 additions and 1 deletions
|
@ -3,7 +3,9 @@ package client
|
|||
import (
|
||||
"context"
|
||||
"crypto/ecdsa"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||
v2object "github.com/nspcc-dev/neofs-api-go/v2/object"
|
||||
|
@ -171,7 +173,10 @@ func (x *ObjectWriter) WritePayloadChunk(chunk []byte) bool {
|
|||
func (x *ObjectWriter) Close() (*ResObjectPut, error) {
|
||||
defer x.cancelCtxStream()
|
||||
|
||||
if x.ctxCall.err != nil {
|
||||
// Ignore io.EOF error, because it is expected error for client-side
|
||||
// stream termination by the server. E.g. when stream contains invalid
|
||||
// message. Server returns an error in response message (in status).
|
||||
if x.ctxCall.err != nil && !errors.Is(x.ctxCall.err, io.EOF) {
|
||||
return nil, x.ctxCall.err
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue