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

Optional contexts feature #39

Closed
wants to merge 59 commits into from
Closed

Optional contexts feature #39

wants to merge 59 commits into from

Conversation

apurvis
Copy link
Contributor

@apurvis apurvis commented Apr 27, 2017

Replaces #33

Before we settled on using Retriable, we had our own gem for retries called Pester. We went with Retriable in the end but there was one killer feature of Pester that we have long wanted in Retriable so we added it.

The documentation should explain things but let me know if anything is unclear

@kamui / @slpsys

apurvis and others added 30 commits January 8, 2017 11:18
* Add environments option to retriable

* Make it reconfigurable

* README

* Move environment validation to Environment class

* Don't use method_missing in Environment; add reset! method

* README

* No shenanigans
…hods with environments (#3)

* Add validation for the :on param

* Disallow underloading any methods

* Rename validate\!

* README
@apurvis apurvis changed the title WIP: new contexts Optional contexts feature Apr 27, 2017
@apurvis
Copy link
Contributor Author

apurvis commented Apr 27, 2017

p.s. @kamui prolly a good case for "squash + merge" instead of regular merge

@apurvis
Copy link
Contributor Author

apurvis commented May 10, 2017

any thoughts, @kamui?

@apurvis
Copy link
Contributor Author

apurvis commented Jun 7, 2017

ping @kamui

@apurvis
Copy link
Contributor Author

apurvis commented Jun 20, 2017

ping

@apurvis
Copy link
Contributor Author

apurvis commented Jul 27, 2017

@kamui, are you still maintaining this or should we just fork the project?

@kamui kamui mentioned this pull request Jul 27, 2017
@kamui
Copy link
Owner

kamui commented Jul 27, 2017

I apologize for the long wait, I just haven't had a lot of free time.

I did look at this PR a few times and had a pending review. There were a few implementation choices that I had some issues with, but at the time I didn't have a better solution, so I put it off to think some more on it, I ended up spiking on some experimenting with the API and implementation myself to see if I could figure out a simpler implementation that didn't require patching config or subclassing Hash and I came up with:

#43

BTW, I like how you reformatted the README, I'd like to borrow that if you don't mind.

@apurvis
Copy link
Contributor Author

apurvis commented Jul 27, 2017

sure do whatever you want with the readme - cherry-pick or whatever you gotta do

@apurvis apurvis closed this Jul 28, 2017
@@ -6,15 +6,20 @@
module Retriable
module_function

def self.configure
def configure
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kamui i don't know if you want to grab this change.. the self is gratuitous because of the module_function

Copy link
Owner

Choose a reason for hiding this comment

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

It's already in my PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -40,7 +45,7 @@ def retriable(opts = {})
base_interval: base_interval,
multiplier: multiplier,
max_interval: max_interval,
rand_factor: rand_factor,
rand_factor: rand_factor
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this was also just some housekeeping

Copy link
Owner

Choose a reason for hiding this comment

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

Yep, I'll port it.

end

return intervals if rand_factor.zero?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the changes in this file are also just housekeeping changes - this line is unnecessary (i mean, it saves a single ruby call... but we are usually retrying operations that take at least seconds)

Copy link
Owner

Choose a reason for hiding this comment

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

I'm going to keep this line. The reason I like it is because if rand_factor is 0, basically, don't randomize. This line basically does that from a logical step point of view: if it's 0, don't call randomize. It skips some math, map allocates memory for a new Array. I know it's super minimal, but this logically makes sense to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you already have that line...

return interval if rand_factor.zero?

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 get what it does; feel free to keep it NBD i just find that less code = more readable code)

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, it makes sense in randomize, since it should exit early if rand_factor is 0, but I also think it makes sense in intervals too. If it can skip the map, randomize method invocation, allocating a new array, why not have it be more efficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@apurvis apurvis deleted the refactor_new_contexts branch July 28, 2017 05:38
@kamui
Copy link
Owner

kamui commented Jul 28, 2017

If you have the time and are inclined, a PR of the README reformatting would be awesome.

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.

2 participants