class Asynk::Broker

Public Class Methods

amqp_connection() click to toggle source
# File lib/asynk/broker.rb, line 30
def amqp_connection; @amqp_connection; end
connect() click to toggle source
# File lib/asynk/broker.rb, line 6
def connect
  @amqp_connection = Bunny.new(host: Asynk.config[:mq_host],
                               port: Asynk.config[:mq_port],
                           username: Asynk.config[:mq_username],
                           password: Asynk.config[:mq_password],
                              vhost: Asynk.config[:mq_vhost])
  Asynk.logger.info [ "Connection to Rabbit with params host: #{Asynk.config[:mq_host]}:#{Asynk.config[:mq_port]}",
                      "username: '#{Asynk.config[:mq_username]}' ", "vhost: '#{Asynk.config[:mq_vhost]}'"
                    ].join(' ')

  @amqp_connection.start

  @pool = ConnectionPool.new(size: 10, timeout: 5) do
    channel = @amqp_connection.create_channel(nil, nil)
    [channel, channel.topic(Asynk.config[:mq_exchange]), channel.queue('', exclusive: true)]
  end
end
disconnect() click to toggle source
# File lib/asynk/broker.rb, line 24
def disconnect
  @amqp_connection.close if @amqp_connection
  @amqp_connection = nil
end
pool() click to toggle source
# File lib/asynk/broker.rb, line 29
def pool; @pool; end