diff --git a/client/retry.go b/client/retry.go index cdae7a6b..06e2d40c 100644 --- a/client/retry.go +++ b/client/retry.go @@ -2,9 +2,10 @@ package client import "golang.org/x/net/context" +// note that returning either true or a non-nil error will result in the call not being retried type RetryFunc func(ctx context.Context, req Request, retryCount int, err error) (bool, error) // always retry on error func alwaysRetry(ctx context.Context, req Request, retryCount int, err error) (bool, error) { - return true, err + return true, nil } diff --git a/client/rpc_client.go b/client/rpc_client.go index ede9e899..1d6b743f 100644 --- a/client/rpc_client.go +++ b/client/rpc_client.go @@ -300,10 +300,16 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac return nil } - if retry, err := callOpts.Retry(ctx, request, i, err); !retry { + retry, rerr := callOpts.Retry(ctx, request, i, err) + if rerr != nil { + return rerr + } + + if !retry { return err } + gerr = err } } @@ -406,8 +412,13 @@ func (r *rpcClient) Stream(ctx context.Context, request Request, opts ...CallOpt return rsp.stream, nil } - if retry, err := callOpts.Retry(ctx, request, i, rsp.err); !retry { - return nil, err + retry, rerr := callOpts.Retry(ctx, request, i, rsp.err) + if rerr != nil { + return nil, rerr + } + + if !retry { + return nil, rsp.err } grr = err