class Mumukit::Nuntius::Connection

Public Class Methods

config() click to toggle source
# File lib/mumukit/nuntius/connection.rb, line 4
def config
  @config ||= YAML.load_interpolated(File.expand_path '../../../../config/rabbit.yml', __FILE__).
      with_indifferent_access[ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development']
end
connected?() click to toggle source
# File lib/mumukit/nuntius/connection.rb, line 21
def connected?
  @connection.present?
end
establish_connection() click to toggle source
# File lib/mumukit/nuntius/connection.rb, line 16
def establish_connection
  raise 'Nuntius connection already established' if connected?
  @connection = Bunny.new(host: config[:host], user: config[:user], password: config[:password])
end
start_channel(exchange_name) click to toggle source
# File lib/mumukit/nuntius/connection.rb, line 9
def start_channel(exchange_name)
  raise 'Nuntius connection isn\'t established' unless connected?
  channel = @connection.start.create_channel
  exchange = channel.fanout(exchange_name)
  [channel, exchange]
end