-
Notifications
You must be signed in to change notification settings - Fork 48
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 a simple context plugin #43
Changes from all commits
94b1def
4e35ddc
43da6cd
ea5b10f
aeb16a7
de3fcb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
## HEAD | ||
|
||
* Added contexts feature. Thanks to @apurvis. | ||
|
||
## 3.0.2 | ||
|
||
* Add configuration and options validation. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,14 +6,22 @@ | |
module Retriable | ||
module_function | ||
|
||
def self.configure | ||
def configure | ||
yield(config) | ||
end | ||
|
||
def config | ||
@config ||= Config.new | ||
end | ||
|
||
def with_context(context_key, options = {}, &block) | ||
if !config.contexts.key?(context_key) | ||
raise ArgumentError, "#{context_key} not found in Retriable.config.contexts. Here the available contexts: #{config.contexts.keys}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Here are the...." ;) or just say "Available contexts: " There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Damn, I'm getting sleepy and wanted to cut a new version. I'll bundle the typo fix in with the next patch version! |
||
end | ||
|
||
retriable(config.contexts[context_key].merge(options), &block) if block | ||
end | ||
|
||
def retriable(opts = {}) | ||
local_config = opts.empty? ? config : Config.new(config.to_h.merge(opts)) | ||
|
||
|
@@ -40,7 +48,7 @@ def retriable(opts = {}) | |
base_interval: base_interval, | ||
multiplier: multiplier, | ||
max_interval: max_interval, | ||
rand_factor: rand_factor, | ||
rand_factor: rand_factor | ||
).intervals | ||
end | ||
|
||
|
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.
you're missing a version number here?
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.
Oh what I usually do is put new feature/bug fixes in HEAD, and then when I cut a new version, I'll move the new stuff into that version. Since sometimes I collect a few features or bug fixes before doing a version.
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.
whatever you prefer; i'm just used to always having the next version being the first line of the changelog
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 don't always know if the next version will be major, minor, or patch until I know everything going into it. So I keep it HEAD until I cut the version.