Class: ConsulKvBackup::Amqp

Inherits:
Object
  • Object
show all
Includes:
FlazmRubyHelpers::Class
Defined in:
lib/consul_kv_backup/amqp.rb

Overview

Send diff output to jq command line

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amqp_config) ⇒ Amqp

Returns a new instance of Amqp.



13
14
15
16
# File 'lib/consul_kv_backup/amqp.rb', line 13

def initialize(amqp_config)
  initialize_variables(amqp_config)
  setup_connection
end

Instance Attribute Details

#consulObject

Returns the value of attribute consul.



12
13
14
# File 'lib/consul_kv_backup/amqp.rb', line 12

def consul
  @consul
end

#gitObject

Returns the value of attribute git.



12
13
14
# File 'lib/consul_kv_backup/amqp.rb', line 12

def git
  @git
end

Instance Method Details

#consumeObject



30
31
32
33
# File 'lib/consul_kv_backup/amqp.rb', line 30

def consume
  @consumer ||= @queue.subscribe(block: true, &itself.method(:process_message))
  nil
end

#setup_connectionObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/consul_kv_backup/amqp.rb', line 18

def setup_connection
  @conn = Bunny.new(amqp_opts)
  @conn.start
  @ch = @conn.create_channel
  @ex = Bunny::Exchange.new(@ch,
                            :topic,
                            @amqp_exchange,
                            durable: true)
  @queue = @ch.queue(@amqp_queue, durable: true)
  @queue.bind(@ex, routing_key: @amqp_routing_key) if @amqp_bind
end