Class: Acheron::Exec

Inherits:
Struct
  • Object
show all
Defined in:
lib/acheron/exec.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#configObject

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



10
11
12
# File 'lib/acheron/exec.rb', line 10

def config
  @config
end

Instance Method Details

#runObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/acheron/exec.rb', line 12

def run
  check
  reconnect
  x_name = config.rabbitmq.exchange
  exchange = @channel.fanout(x_name)
  queue = @channel.queue('', exclusive: true)
  queue.bind(exchange)

  queue.subscribe(block: true) do |info, prop, body|
    slack JSON.parse(body)['msg']
  end
rescue Bunny::ConnectionClosedError => e
  # if the connection is closed make it reconnect and try again
  reconnect
  retry
end