Class: DaemonKit::AMQP
- Inherits:
-
Object
- Object
- DaemonKit::AMQP
- Defined in:
- lib/daemon_kit/amqp.rb
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
13 14 15 |
# File 'lib/daemon_kit/amqp.rb', line 13 def instance @instance ||= new end |
.run(&block) ⇒ Object
19 20 21 |
# File 'lib/daemon_kit/amqp.rb', line 19 def run(&block) instance.run(&block) end |
Instance Method Details
#run(&block) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/daemon_kit/amqp.rb', line 28 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 ::AMQP.start(@config, &block) end |