Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from seomoz/retry_exceptions
Add support for retryable errors through Qless::RetryExceptions mixin.
- Loading branch information
Showing
5 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
module Qless | |||
module RetryExceptions | |||
def retryable_exception_classes | |||
@retryable_exception_classes ||= [] | |||
end | |||
|
|||
def retry_on(*exception_classes) | |||
self.retryable_exception_classes.push(*exception_classes) | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
require 'qless/retry_exceptions' | |||
|
|||
module Qless | |||
describe RetryExceptions do | |||
let(:job_class) { Class.new } | |||
let(:exception_class) { Class.new(StandardError) } | |||
|
|||
before do | |||
job_class.extend(RetryExceptions) | |||
end | |||
|
|||
it 'defines a retryable_exceptions method that returns an empty array by default' do | |||
job_class.retryable_exception_classes.should be_empty | |||
end | |||
|
|||
it 'defines a retry_on method that makes exception types retryable' do | |||
job_class.retry_on(exception_class) | |||
|
|||
job_class.retryable_exception_classes.should eq([exception_class]) | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters