Make retry config private (#8613)

Signed-off-by: godchen <qingxiang.chen@zilliz.com>
pull/8617/head
godchen 2021-09-26 20:13:58 +08:00 committed by GitHub
parent b4427d5ac4
commit 5eb1a449d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -13,30 +13,30 @@ package retry
import "time"
type Config struct {
type config struct {
attempts uint
sleep time.Duration
maxSleepTime time.Duration
}
func newDefaultConfig() *Config {
return &Config{
func newDefaultConfig() *config {
return &config{
attempts: uint(10),
sleep: 200 * time.Millisecond,
maxSleepTime: 3 * time.Second,
}
}
type Option func(*Config)
type Option func(*config)
func Attempts(attempts uint) Option {
return func(c *Config) {
return func(c *config) {
c.attempts = attempts
}
}
func Sleep(sleep time.Duration) Option {
return func(c *Config) {
return func(c *config) {
c.sleep = sleep
// ensure max retry interval is always larger than retry interval
if c.sleep*2 > c.maxSleepTime {
@ -46,7 +46,7 @@ func Sleep(sleep time.Duration) Option {
}
func MaxSleepTime(maxSleepTime time.Duration) Option {
return func(c *Config) {
return func(c *config) {
// ensure max retry interval is always larger than retry interval
if c.sleep*2 > maxSleepTime {
c.maxSleepTime = 2 * c.sleep