-
Notifications
You must be signed in to change notification settings - Fork 47
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
Minor: Better ruby style & remove unnecessary short circuit check #48
Conversation
lib/retriable/exponential_backoff.rb
Outdated
@@ -25,18 +26,19 @@ def initialize(opts = {}) | |||
|
|||
def intervals | |||
intervals = Array.new(tries) do |iteration| | |||
[base_interval * multiplier**iteration, max_interval].min | |||
[base_interval * (multiplier ** iteration), max_interval].min |
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.
Space around operator ** detected.
lib/retriable/exponential_backoff.rb
Outdated
@@ -1,5 +1,6 @@ | |||
module Retriable | |||
class ExponentialBackoff | |||
|
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.
Extra empty line detected at class body beginning.
Merge master
lib/retriable/exponential_backoff.rb
Outdated
return intervals if rand_factor.zero? | ||
|
||
intervals.map { |i| randomize(i) } | ||
if rand_factor.zero? |
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.
Removing the interval check in randomize makes sense, but in this change, I prefer my guard/return/fall-through style rather than if/else. Can you just revert this change, it looks good otherwise.
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 problem
@@ -37,6 +37,7 @@ def retriable(opts = {}) | |||
on_retry = local_config.on_retry | |||
sleep_disabled = local_config.sleep_disabled | |||
|
|||
exception_list = on.is_a?(Hash) ? on.keys : on |
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.
(i moved this because i felt like it was hanging out in an awkward place way underneath all the other instantiation variables)
Minor: Better ruby style & remove unnecessary short circuit check (kamui#48)
Just noticed this was redundant;
randomize
is a private method that is never called ifrand_factor.zero?
i also made a couple v. small style tweaks; if you don't like them i can change them back but i thought they made it slightly more readable.