fix golint issues in core/fx (#486)

This commit is contained in:
Kevin Wan
2021-02-19 17:49:39 +08:00
committed by GitHub
parent c376ffc351
commit f238290dd3
6 changed files with 48 additions and 22 deletions

View File

@@ -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
}