-
-
Save bts/1255003 to your computer and use it in GitHub Desktop.
Theoretical plugin API for Qu
This file contains hidden or 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
| Qu.plugin(:autoretry) do |*errors| | |
| options = {:limit => 3}.merge!(errors.extract_options!) | |
| errors << Exception if errors.empty? | |
| before :failure do |job, e| | |
| if errors.any? {|error| error === e } | |
| job.data[:retries] += 1 | |
| Qu.requeue job unless job.config[:retries] >= limit | |
| halt # don't report the error yet | |
| end | |
| end | |
| end | |
| class ProcessPresentation < Qu::Job | |
| autoretry Timeout::Error, :times => 5 | |
| attr_reader :presentation | |
| def initialize(presentation_id) | |
| @presentation = Presentation.find(presentation) | |
| end | |
| def perform | |
| # … | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment