Class: Promiscuous::Publisher::Worker
- Inherits:
-
Object
- Object
- Promiscuous::Publisher::Worker
- Defined in:
- lib/promiscuous/publisher/worker.rb
Instance Method Summary collapse
-
#initialize ⇒ Worker
constructor
A new instance of Worker.
- #start ⇒ Object
- #stop ⇒ Object
- #try_recover ⇒ Object
Constructor Details
#initialize ⇒ Worker
Returns a new instance of Worker.
2 3 4 |
# File 'lib/promiscuous/publisher/worker.rb', line 2 def initialize @recovery_timer = Promiscuous::Timer.new("recovery", Promiscuous::Config.recovery_timeout) { try_recover } end |
Instance Method Details
#start ⇒ Object
6 7 8 |
# File 'lib/promiscuous/publisher/worker.rb', line 6 def start @recovery_timer.start(:run_immediately => true) end |
#stop ⇒ Object
10 11 12 |
# File 'lib/promiscuous/publisher/worker.rb', line 10 def stop @recovery_timer.reset end |
#try_recover ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/promiscuous/publisher/worker.rb', line 14 def try_recover Promiscuous::Publisher::Operation::Base.run_recovery_mechanisms rescue Exception => e Promiscuous.warn "[recovery] #{e}\n#{e.backtrace.join("\n")}" Promiscuous::Config.error_notifier.call(e) ensure ActiveRecord::Base.clear_active_connections! if defined?(ActiveRecord::Base) end |