Class: ConsulStockpile::WatchEventActor
- Inherits:
-
Concurrent::Actor::RestartingContext
- Object
- Concurrent::Actor::RestartingContext
- ConsulStockpile::WatchEventActor
- Defined in:
- lib/consul_stockpile/watch_event_actor.rb
Instance Method Summary collapse
-
#initialize(backup_actor:) ⇒ WatchEventActor
constructor
A new instance of WatchEventActor.
- #on_message(message) ⇒ Object
Constructor Details
#initialize(backup_actor:) ⇒ WatchEventActor
Returns a new instance of WatchEventActor.
7 8 9 10 |
# File 'lib/consul_stockpile/watch_event_actor.rb', line 7 def initialize(backup_actor:) @backup_actor = backup_actor tell :watch end |
Instance Method Details
#on_message(message) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/consul_stockpile/watch_event_actor.rb', line 12 def () if == :watch Logger.tagged('WatchEvent') do begin WatchEvent.call( handler: ->(event){ @backup_actor << :backup } ) rescue => e Logger.warn "Warning: #{e.}; retrying in 5 seconds" Logger.warn e.backtrace Concurrent::ScheduledTask.execute(5){ tell :watch } end end else pass end end |