Skip to content

Conversation

TrevinTeacutter
Copy link

I know this repo hasn't changed in the past 6 years, but just putting this out there for posterity's sake

List of changes with some minor details around the reason for them:

  • Changed attempts to not be exported as Reset() seems to be the intended modifier for that within the Backoff interface
  • Guarded against unnecessary usage of math.Pow as if MaxAttempts is not set, this could cause increasing CPU intensive calls that are unnecessary. This is done by maintaining state of the last value this was set to.
  • Guarded against overflow of attempts, again if MaxAttempts is not set, attempts could overflow causing weird behavior as the backoff would essentially reset.
  • JitterBackoff uses an embedded struct to extend behavior of the SimpleBackoff
  • After ensures that channels are closed when done with them (was unsure if the channel is GC'd without that closure).
  • Removed fragile assert.WithinDurations for After/Wait tests as they depend on the goroutine scheduler and code to be executed without any delays making it fragile and failing depending on the environment.
  • Uplifted the tests to be table driven which is a bit more common in golang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant