WIP: client: Pass grpc.CallOption options on dial #287

Closed
a-savchuk wants to merge 3 commits from a-savchuk/frostfs-sdk-go:correct-deadline-with-wait-for-ready into master
Showing only changes of commit 7404838a83 - Show all commits

View file

@ -106,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