Adjusting the logic around the returned error from the retry function
This commit is contained in:
parent
c6737ac64c
commit
a6812ba332
@ -2,9 +2,10 @@ package client
|
|||||||
|
|
||||||
import "golang.org/x/net/context"
|
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)
|
type RetryFunc func(ctx context.Context, req Request, retryCount int, err error) (bool, error)
|
||||||
|
|
||||||
// always retry on error
|
// always retry on error
|
||||||
func alwaysRetry(ctx context.Context, req Request, retryCount int, err error) (bool, error) {
|
func alwaysRetry(ctx context.Context, req Request, retryCount int, err error) (bool, error) {
|
||||||
return true, err
|
return true, nil
|
||||||
}
|
}
|
||||||
|
@ -300,10 +300,16 @@ func (r *rpcClient) Call(ctx context.Context, request Request, response interfac
|
|||||||
return nil
|
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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gerr = err
|
gerr = err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,8 +412,13 @@ func (r *rpcClient) Stream(ctx context.Context, request Request, opts ...CallOpt
|
|||||||
return rsp.stream, nil
|
return rsp.stream, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if retry, err := callOpts.Retry(ctx, request, i, rsp.err); !retry {
|
retry, rerr := callOpts.Retry(ctx, request, i, rsp.err)
|
||||||
return nil, err
|
if rerr != nil {
|
||||||
|
return nil, rerr
|
||||||
|
}
|
||||||
|
|
||||||
|
if !retry {
|
||||||
|
return nil, rsp.err
|
||||||
}
|
}
|
||||||
|
|
||||||
grr = err
|
grr = err
|
||||||
|
Loading…
Reference in New Issue
Block a user