Created
April 8, 2011 20:43
-
-
Save rafamvc/910698 to your computer and use it in GitHub Desktop.
Revisions
-
Rafael Cardoso revised this gist
Apr 13, 2011 . 1 changed file with 39 additions and 22 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,20 +1,21 @@ class TestObj # All requests coming for #long_background_processing_method will be handled in the background handle_async :method1 # This needs access to be a class method schedule :method2, :every => :day, :at => '12:55am' # The multiple will not allow two #method3 to run at the same time schedule :method3, :every => 30.minutes, :overlap => false # The retroactive will process the summary from every 10 minutes since it ran last time. schedule :method4, :every => 10.minutes, :retroactive => true # Same as above, but it will run the the retroactive one after the other, # rather than all at the same time. schedule :method5, :every => 30.minutes, :retroactive => true, :overlap => false @@ -27,35 +28,51 @@ class TestObj # This will use threads instead of forking. daemon :another_daemon, :style => :threaded def method1 TestObj.mockable_method end def method2(*args) TestObj.mockable_method end def method3 TestObj.mockable_method end def method4 TestObj.mockable_method end def method5 TestObj.mockable_method end def my_awesome_daemon TestObj.mockable_method end def another_daemon TestObj.mockable_method end def self.mockable_method end end # ## You can also run: # # a = TestObj.new # # a.delay.method2 # a.delay(:for => 5.minutes).method2 # # # # using run_async # # a = TestObj.new # # Method 2 will not be executed in the current server, but it will push # # this request to the queue and will be processed in the background # a.method1 # # # This will create 4 jobs in the queue # a.method1 # a.method1 # a.method1 # a.method2 -
Rafael Cardoso revised this gist
Apr 10, 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 @@ -23,10 +23,10 @@ class TestObj # The daemons support some signaling to stop and pause # The interval is the time between every execution of the method. # dameons are ran as a forked and detached process, while a run is only a forked process. daemon :my_awesome_daemon, :number_of_instances => 2, :interval => 5.seconds # This will use threads instead of forking. daemon :another_daemon, :style => :threaded def method1 -
Rafael Cardoso revised this gist
Apr 8, 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 @@ -57,5 +57,5 @@ def another_daemon a = TestObj.new a.delay.method1 a.delay(:in => 5.minutes).method1 -
Rafael Cardoso revised this gist
Apr 8, 2011 . 1 changed file with 14 additions and 17 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,4 @@ class TestObj # All requests coming for #long_background_processing_method will be handled in the background run_async :method1 @@ -30,29 +29,27 @@ class TestObj run :as => :daemon, :another_daemon, :style => :threaded def method1 puts "Something" end def method2 puts "Something" end def method3 puts "Something" end def method4 puts "Something" end def method5 puts "Something" end def my_awesome_daemon puts "Something" end def another_daemon puts "Something" end end -
Rafael Cardoso revised this gist
Apr 8, 2011 . 1 changed file with 1 addition and 1 deletion.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 @@ -17,7 +17,7 @@ class TestObj # rather than all at the same time. run :method5, :every => 30.minutes, :retroactive => true, :overlap => false # It will spawn the method my_awesome_daemon as a daemon. # As default, daemons are set not run overlap, but it can be override by setting the number_of_instances of the deamons to run. -
Rafael Cardoso revised this gist
Apr 8, 2011 . 1 changed file with 12 additions and 11 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 @@ -2,31 +2,32 @@ class TestObj attr_accessor :meaninful_variable # All requests coming for #long_background_processing_method will be handled in the background run_async :method1 # This needs access to be a class method run :method2, :every => :day, :at => '12:55am' # The multiple will not allow two #method3 to run at the same time run :method3, :every => 30.minutes, :overlap => false # The retroactive will process the summary from every 10 minutes since it ran last time. run :method4, :every => 10.minutes, :retroactive => true # Same as above, but it will run the the retroactive one after the other, # rather than all at the same time. run :method5, :every => 30.minutes, :retroactive => true, :multiple => false # It will spawn the method my_awesome_daemon as a daemon. # As default, daemons are set not run overlap, but it can be override by setting the number_of_instances of the deamons to run. # The daemons support some signaling to stop and pause # The interval is the time between every execution of the method. # dameons are ran as a forked and detached process, while a run is only a forked process. run :as => :daemon, :my_awesome_daemon, :number_of_instances => 2, :interval => 5.seconds # This will use threads instead of forking. run :as => :daemon, :another_daemon, :style => :threaded def initialize -
Rafael Cardoso revised this gist
Apr 8, 2011 . 1 changed file with 8 additions and 0 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 @@ -53,3 +53,11 @@ def self.mockable_method(bool_arg = true) def my_awesome_daemon end end ## You can also run: a = TestObj.new a.delay.slow_method a.delay(:in => 5.minutes).slow_method -
Rafael Cardoso revised this gist
Apr 8, 2011 . 1 changed file with 2 additions and 0 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,7 +1,9 @@ class TestObj attr_accessor :meaninful_variable # All requests coming for #long_background_processing_method will be handled in the background run_async :long_background_processing_method # This needs access to be a class method run :long_consistency_check, :every => :day, :at => '12:55am' -
Rafael Cardoso renamed this gist
Apr 8, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Rafael Cardoso renamed this gist
Apr 8, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Rafael Cardoso renamed this gist
Apr 8, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Rafael Cardoso created this gist
Apr 8, 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,53 @@ class TestObj attr_accessor :meaninful_variable run_async :long_background_processing_method # This needs access to be a class method run :long_consistency_check, :every => :day, :at => '12:55am' # The multiple will not allow two methods to run at the same time run :download_updated_tests, :every => 30.minutes, :multiple => false # The retroactive will process the summary from every 10 minutes since it ran last time. run :calculate_summary_for_every_10_min, :every => 10.minutes, :retroactive => true # Same as above, but it will run the the retroactive one after the other, # rather than all at the same time. run :calculate_summary_of_summary_for_every_30_min, :every => 30.minutes, :retroactive => true, :multiple => false # It will spawn the method my_awesome_daemon as a daemon. # As default, daemons are set not run multiples, but it can be override. # The daemons support some signaling to stop and pause # The interval is the time between every execution of the method. # dameons are ran as a forked and detached process, while a run is only a forked process. daemon :my_awesome_daemon, :multiple => true, :interval => 5.seconds daemon :another_daemon, :style => (:forked || :threaded) def initialize self.meaninful_variable = "something" end def slow_method TestObj.mockable_method end def slow_method_with_args(bool_arg) TestObj.mockable_method(bool_arg) end def long_background_processing_method end def self.long_consistency_check end def self.mockable_method(bool_arg = true) end def my_awesome_daemon end end