Module: Urabbit
- Defined in:
- lib/urabbit.rb,
lib/urabbit/version.rb
Defined Under Namespace
Modules: RPC
Classes: Error, Publisher
Constant Summary
collapse
- VERSION =
"0.3.2"
Class Method Summary
collapse
Class Method Details
.connection(cloudamqp_url = ENV["CLOUDAMQP_URL"]) ⇒ Object
A single connection shared between threads.
23
24
25
26
27
28
29
30
31
32
33
|
# 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 ⇒ Object
39
40
41
|
# File 'lib/urabbit.rb', line 39
def self.create_channel
connection.create_channel
end
|
.disconnect ⇒ Object
35
36
37
|
# File 'lib/urabbit.rb', line 35
def self.disconnect
@connection = nil
end
|
.logger ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/urabbit.rb', line 10
def self.logger
@logger ||= if defined?(Rails)
Rails.logger
else
Logger.new(STDOUT)
end
end
|
.logger=(logger) ⇒ Object
18
19
20
|
# File 'lib/urabbit.rb', line 18
def self.logger=(logger)
@logger = logger
end
|