Skip to content

Instantly share code, notes, and snippets.

@bts
Forked from bkeepers/plugin.rb
Created September 30, 2011 21:20
Show Gist options
  • Select an option

  • Save bts/1255003 to your computer and use it in GitHub Desktop.

Select an option

Save bts/1255003 to your computer and use it in GitHub Desktop.
Theoretical plugin API for Qu
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