module Urabbit
Constants
- VERSION
Public Class Methods
connection(cloudamqp_url = ENV["CLOUDAMQP_URL"])
click to toggle source
A single connection shared between threads.
# File lib/urabbit.rb, line 23 def self.connection(cloudamqp_url = ENV["CLOUDAMQP_URL"]) @mutex.synchronize do @connection ||= begin connection = Bunny.new(cloudamqp_url, logger: logger) connection.start connection rescue Bunny::Exception raise Error.new("Error connecting to RabbitMQ") end end end
create_channel()
click to toggle source
# File lib/urabbit.rb, line 39 def self.create_channel connection.create_channel end
disconnect()
click to toggle source
# File lib/urabbit.rb, line 35 def self.disconnect @connection = nil end
logger()
click to toggle source
# File lib/urabbit.rb, line 10 def self.logger @logger ||= if defined?(Rails) Rails.logger else Logger.new(STDOUT) end end
logger=(logger)
click to toggle source
# File lib/urabbit.rb, line 18 def self.logger=(logger) @logger = logger end