-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add engine configuration options for exponential backoff #8
Conversation
dependency/engine.go
Outdated
@@ -80,6 +88,14 @@ func (config *EngineConfig) Validate() error { | |||
if config.BounceDelay < 0 { | |||
return errors.New("BounceDelay is negative") | |||
} | |||
if config.BackoffFactor != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not consolidate into one line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no real reason
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me - only a couple of minor comments.
dependency/engine.go
Outdated
@@ -80,6 +88,14 @@ func (config *EngineConfig) Validate() error { | |||
if config.BounceDelay < 0 { | |||
return errors.New("BounceDelay is negative") | |||
} | |||
if config.BackoffFactor != 0 { | |||
if config.BackoffFactor < 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nicer as config.BackoffFactor != 0 && config.BackoffFactor < 1
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure
dependency/engine.go
Outdated
@@ -368,7 +389,17 @@ func (engine *Engine) requestStart(name string, delay time.Duration) { | |||
// Always fuzz the delay a bit to help randomise the order of workers starting, | |||
// which should make bugs more obvious | |||
if delay > time.Duration(0) { | |||
delay += time.Duration(rand.Int31n(60)) * time.Millisecond | |||
if engine.config.BackoffFactor > 0 { | |||
for i := 1; i < info.startAttempts; i++ { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not math.Pow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK then...
delay = engine.config.MaxDelay | ||
} | ||
} | ||
// Fuzz to ±10% of final duration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of ±! (I had to copy it because I couldn't be bothered to work out how to type one.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jameinel made me use it.
|
Add EngineConfig options to allow exponential backoff when determining worker restart delays.
Also tweaks some of the logging to make the default debug output for a restarting engine somewhat quieter.