Sha256: f22d91bd1fa945620f9dfae38fd7d72e4873965df2955ffd2f8de056fa2ee614

Contents?: true

Size: 733 Bytes

Versions: 1

Compression:

Stored size: 733 Bytes

Contents

require 'concurrent'
require 'concurrent-edge'
require 'consul_stockpile/backup_consul_kv'

module ConsulStockpile
  class BackupConsulKVActor < Concurrent::Actor::RestartingContext
    def initialize(bucket:, name:)
      @bucket = bucket
      @name = name
    end

    def on_message(message)
      if message == :backup
        Logger.tagged('Backup') do
          begin
            BackupConsulKV.call!(bucket: @bucket, name: @name)
          rescue => e
            Logger.warn "Warning: #{e.message}; retrying in 5 seconds"
            Logger.warn e.backtrace.join("\n")
            Concurrent::ScheduledTask.execute(5){ tell :backup }
          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/backup_consul_kv_actor.rb