Class: ConsulBridge::BootstrapConsulActor

Inherits:
Concurrent::Actor::RestartingContext
  • Object
show all
Defined in:
lib/consul_bridge/bootstrap_consul_actor.rb

Instance Method Summary collapse

Constructor Details

#initialize(bucket:, join_all: false) ⇒ BootstrapConsulActor

Returns a new instance of BootstrapConsulActor.



7
8
9
10
# File 'lib/consul_bridge/bootstrap_consul_actor.rb', line 7

def initialize(bucket:, join_all: false)
  @bucket = bucket
  @join_all = join_all
end

Instance Method Details

#on_message(message) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/consul_bridge/bootstrap_consul_actor.rb', line 12

def on_message(message)
  if message == :bootstrap
    begin
      BootstrapConsul.call!(bucket: @bucket, join_all: @join_all)
    rescue => e
      puts "Warning: #{e.message}; retrying in 5 seconds"
      Concurrent::ScheduledTask.execute(5){ tell :bootstrap }
    end

    nil
  else
    pass
  end
end