Sha256: dfd3fac03ce384c26f3e387a8ccf5042f2983e77baa5b0dbf7fbbd28984095a9

Contents?: true

Size: 649 Bytes

Versions: 1

Compression:

Stored size: 649 Bytes

Contents

require 'concurrent'
require 'concurrent-edge'
require 'consul_bridge/bootstrap_consul'

module ConsulBridge
  class BootstrapConsulActor < Concurrent::Actor::RestartingContext
    def initialize(bucket:, join_all: false)
      @bucket = bucket
      @join_all = join_all
    end

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
consul_bridge-0.1.5 lib/consul_bridge/bootstrap_consul_actor.rb