Sha256: cace68f4def297518f1675ac117f1f3615a932a80d0f3b702a24f2e550c0da4b

Contents?: true

Size: 855 Bytes

Versions: 1

Compression:

Stored size: 855 Bytes

Contents

require 'concurrent'
require 'concurrent-edge'
require 'consul_stockpile/bootstrap_consul_kv'
require 'consul_stockpile/logger'

module ConsulStockpile
  class BootstrapConsulKVActor < Concurrent::Actor::RestartingContext
    def initialize(backup_actor:, bucket:)
      @backup_actor = backup_actor
      @bucket = bucket
      tell :bootstrap
    end

    def on_message(message)
      if message == :bootstrap
        Logger.tagged('Bootstrap') do
          begin
            ran_bootstrap = BootstrapConsulKV.call!(bucket: @bucket).ran_bootstrap
            @backup_actor << :backup if ran_bootstrap
          rescue => e
            Logger.warn "Warning: #{e.message}; retrying in 5 seconds"
            Concurrent::ScheduledTask.execute(5){ tell :bootstrap }
          end
        end
        nil
      else
        pass
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
consul_stockpile-0.1.5 lib/consul_stockpile/bootstrap_consul_kv_actor.rb