diff --git a/client/client.go b/client/client.go index 0894f0e..ff573e5 100644 --- a/client/client.go +++ b/client/client.go @@ -96,6 +96,7 @@ func (c *Client) Dial(ctx context.Context, prm PrmDial) error { client.WithDialTimeout(prm.DialTimeout), client.WithRWTimeout(prm.StreamTimeout), client.WithGRPCDialOptions(prm.GRPCDialOptions), + client.WithGRPCCallOptions(prm.GRPCCallOptions), )...) c.setFrostFSAPIServer((*coreServer)(&c.c)) @@ -105,26 +106,28 @@ func (c *Client) Dial(ctx context.Context, prm PrmDial) error { _, err := rpc.Balance(&c.c, new(v2accounting.BalanceRequest), client.WithContext(ctx), ) - if err != nil { - var ctxErr error - // return context errors since they signal about dial problem - if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { - ctxErr = err - } else if st, ok := status.FromError(err); ok && st.Code() == codes.Canceled { - ctxErr = context.Canceled - } else if ok && st.Code() == codes.DeadlineExceeded { - ctxErr = context.DeadlineExceeded - } - if ctxErr != nil { - if conn := c.c.Conn(); conn != nil { - _ = conn.Close() - } - return ctxErr - } + if err == nil { + return nil } - return nil + var ctxErr error + + switch st, ok := status.FromError(err); { + case errors.Is(err, context.Canceled) || (ok && st.Code() == codes.Canceled): + ctxErr = context.Canceled + case errors.Is(err, context.DeadlineExceeded) || (ok && st.Code() == codes.DeadlineExceeded): + ctxErr = context.DeadlineExceeded + default: + } + + if ctxErr == nil { + return err + } + if conn := c.c.Conn(); conn != nil { + _ = conn.Close() + } + return ctxErr } // sets underlying provider of frostFSAPIServer. The method is used for testing as an approach @@ -213,6 +216,7 @@ type PrmDial struct { StreamTimeout time.Duration GRPCDialOptions []grpc.DialOption + GRPCCallOptions []grpc.CallOption } // SetServerURI sets server URI in the FrostFS network. diff --git a/go.mod b/go.mod index 7c46916..a8f2304 100644 --- a/go.mod +++ b/go.mod @@ -2,6 +2,9 @@ module git.frostfs.info/TrueCloudLab/frostfs-sdk-go go 1.22 +// Just for testing +replace git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 => git.frostfs.info/a-savchuk/frostfs-api-go/v2 v2.16.1-0.20241016150118-3893ca67ac0c + require ( git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20241011114054-f0fc40e116d1 git.frostfs.info/TrueCloudLab/frostfs-contract v0.19.3-0.20240621131249-49e5270f673e diff --git a/go.sum b/go.sum index 20c14ae..a72b167 100644 Binary files a/go.sum and b/go.sum differ