Class: DaemonKit::AMQP
Overview
Thin wrapper around the amqp gem, specifically designed to ease configuration of a AMQP consumer daemon and provide some added simplicity
Constant Summary collapse
- @@instance =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ AMQP
constructor
A new instance of AMQP.
- #run(&block) ⇒ Object
Constructor Details
Class Method Details
.instance ⇒ Object
14 15 16 |
# File 'lib/daemon_kit/dk_amqp.rb', line 14 def instance @instance ||= new end |
.run(&block) ⇒ Object
20 21 22 |
# File 'lib/daemon_kit/dk_amqp.rb', line 20 def run(&block) instance.run(&block) end |
Instance Method Details
#run(&block) ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/daemon_kit/dk_amqp.rb', line 29 def run(&block) # Ensure graceful shutdown of the connection to the broker DaemonKit.trap('INT') { ::AMQP.stop { ::EM.stop } } DaemonKit.trap('TERM') { ::AMQP.stop { ::EM.stop } } # Start our event loop and AMQP client DaemonKit.logger.debug("AMQP.connect(#{@config.inspect})") ::AMQP.connect(@config, &block) # ::AMQP.start(@config, &block) end |