Skip to content
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

Merged
merged 13 commits into from
Sep 29, 2017

Conversation

apurvis
Copy link
Contributor

@apurvis apurvis commented Aug 6, 2017

Just noticed this was redundant; randomize is a private method that is never called if rand_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.

@@ -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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space around operator ** detected.

@@ -1,5 +1,6 @@
module Retriable
class ExponentialBackoff

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.

apurvis@lumoslabs.com and others added 2 commits August 6, 2017 04:02
return intervals if rand_factor.zero?

intervals.map { |i| randomize(i) }
if rand_factor.zero?
Copy link
Owner

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.

Copy link
Contributor Author

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
Copy link
Contributor Author

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)

@kamui kamui merged commit 154f865 into kamui:master Sep 29, 2017
@apurvis apurvis deleted the ruby_style branch September 30, 2017 01:15
apurvis added a commit to apurvis/retriable that referenced this pull request Oct 6, 2017
Minor: Better ruby style & remove unnecessary short circuit check (kamui#48)
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.

3 participants