-
-
Save bts/1255003 to your computer and use it in GitHub Desktop.
Revisions
-
bts revised this gist
Sep 30, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ # bts: If I'm writing a plugin, I'd typically like to have a namespace to add # my own classes, so I would skip this option: # Qu.plugin(:autoretry) do |*errors| # options = {:limit => 3}.merge!(errors.extract_options!) -
bts revised this gist
Sep 30, 2011 . 3 changed files with 32 additions and 15 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,15 @@ # If I'm writing a plugin, I'd typically like to have a namespace to add my # own classes, so I would skip this option: # 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 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 charactersOriginal file line number Diff line number Diff line change @@ -1,16 +1,25 @@ class Qu::Plugin::AutoRetry < Qu::Plugin # bts: forego the following line, and introspect plugin name from class via # underscoring the class' name # # plugin :autoretry # bts: use "acts" class methods instead of registering callbacks in # #initialize before_failure :retry before :failure, :retry attr_reader :errors, :options def initialize(*errors) @options = {:limit => 3}.merge!(errors.extract_options!) @errors << Exception if errors.empty? # bts: use class methods instead # # before :failure, :retry end def retry(job, e) if errors.any? {|error| error === e } job.data[:retries] += 1 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,10 @@ class ProcessPresentation < Qu::Job # bts: use convention of underscored class name, so we don't have to # declare the plugin name twice in the Plugin (via class' name and also via # the "plugin :autoretry" declaration) # auto_retry Timeout::Error, :times => 5 # autoretry Timeout::Error, :times => 5 attr_reader :presentation -
bkeepers renamed this gist
Sep 30, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
bkeepers revised this gist
Sep 30, 2011 . 3 changed files with 35 additions and 16 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,19 +9,4 @@ halt # don't report the error yet end end end 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ class Qu::Plugin::AutoRetry < Qu::Plugin plugin :autoretry attr_reader :errors, :options def initialize(*errors) @options = {:limit => 3}.merge!(errors.extract_options!) @errors << Exception if errors.empty? before :failure, :retry end def retry(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 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ 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 -
bkeepers created this gist
Sep 30, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,27 @@ 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