fix golint issues in core/fx (#486)
This commit is contained in:
@@ -5,6 +5,7 @@ import "github.com/tal-tech/go-zero/core/errorx"
|
||||
const defaultRetryTimes = 3
|
||||
|
||||
type (
|
||||
// RetryOption defines the method to customize DoWithRetry.
|
||||
RetryOption func(*retryOptions)
|
||||
|
||||
retryOptions struct {
|
||||
@@ -12,7 +13,8 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
func DoWithRetries(fn func() error, opts ...RetryOption) error {
|
||||
// DoWithRetry runs fn, and retries if failed. Default to retry 3 times.
|
||||
func DoWithRetry(fn func() error, opts ...RetryOption) error {
|
||||
var options = newRetryOptions()
|
||||
for _, opt := range opts {
|
||||
opt(options)
|
||||
@@ -30,7 +32,8 @@ func DoWithRetries(fn func() error, opts ...RetryOption) error {
|
||||
return berr.Err()
|
||||
}
|
||||
|
||||
func WithRetries(times int) RetryOption {
|
||||
// WithRetry customize a DoWithRetry call with given retry times.
|
||||
func WithRetry(times int) RetryOption {
|
||||
return func(options *retryOptions) {
|
||||
options.times = times
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user