mirror of https://github.com/milvus-io/milvus.git
parent
b4427d5ac4
commit
5eb1a449d2
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue