Add config support for max HH retry interval

pull/4284/head
Philip O'Toole 2015-09-30 21:10:03 -07:00
parent 5574c61cdf
commit 4eba2c1725
2 changed files with 26 additions and 13 deletions

View File

@ -19,26 +19,34 @@ const (
// value of 0 disables the rate limit.
DefaultRetryRateLimit = 0
// DefaultRetryInterval is the default amout of time the system waits before
// attempting to flush hinted handoff queues.
// DefaultRetryInterval is the default amount of time the system waits before
// attempting to flush hinted handoff queues. With each failure of a hinted
// handoff write, this retry interval increases exponentially until it reaches
// the maximum
DefaultRetryInterval = time.Second
// DefaultRetryMaxInterval is the maximum the hinted handoff retry interval
// will ever be.
DefaultRetryMaxInterval = time.Minute
)
type Config struct {
Enabled bool `toml:"enabled"`
Dir string `toml:"dir"`
MaxSize int64 `toml:"max-size"`
MaxAge toml.Duration `toml:"max-age"`
RetryRateLimit int64 `toml:"retry-rate-limit"`
RetryInterval toml.Duration `toml:"retry-interval"`
Enabled bool `toml:"enabled"`
Dir string `toml:"dir"`
MaxSize int64 `toml:"max-size"`
MaxAge toml.Duration `toml:"max-age"`
RetryRateLimit int64 `toml:"retry-rate-limit"`
RetryInterval toml.Duration `toml:"retry-interval"`
RetryMaxInterval toml.Duration `toml:"retry-max-interval"`
}
func NewConfig() Config {
return Config{
Enabled: true,
MaxSize: DefaultMaxSize,
MaxAge: toml.Duration(DefaultMaxAge),
RetryRateLimit: DefaultRetryRateLimit,
RetryInterval: toml.Duration(DefaultRetryInterval),
Enabled: true,
MaxSize: DefaultMaxSize,
MaxAge: toml.Duration(DefaultMaxAge),
RetryRateLimit: DefaultRetryRateLimit,
RetryInterval: toml.Duration(DefaultRetryInterval),
RetryMaxInterval: toml.Duration(DefaultRetryMaxInterval),
}
}

View File

@ -14,6 +14,7 @@ func TestConfigParse(t *testing.T) {
if _, err := toml.Decode(`
enabled = false
retry-interval = "10m"
retry-max-interval = "100m"
max-size=2048
max-age="20m"
retry-rate-limit=1000
@ -30,6 +31,10 @@ retry-rate-limit=1000
t.Fatalf("unexpected retry interval: got %v, exp %v", c.RetryInterval, exp)
}
if exp := 100 * time.Minute; c.RetryMaxInterval.String() != exp.String() {
t.Fatalf("unexpected retry max interval: got %v, exp %v", c.RetryMaxInterval, exp)
}
if exp := 20 * time.Minute; c.MaxAge.String() != exp.String() {
t.Fatalf("unexpected max age: got %v, exp %v", c.MaxAge, exp)
}