未验证 提交 5eb1a449 编写于 作者: G godchen 提交者: GitHub

Make retry config private (#8613)

Signed-off-by: Ngodchen <qingxiang.chen@zilliz.com>
上级 b4427d5a
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册