Parent

DaemonKit::AMQP

Thin wrapper around the amqp gem, specifically designed to ease configuration of a AMQP consumer daemon and provide some added simplicity

Public Class Methods

instance() click to toggle source
# File lib/daemon_kit/amqp.rb, line 13
def instance
  @instance ||= new
end
new( config = {} ) click to toggle source
# File lib/daemon_kit/amqp.rb, line 24
def initialize( config = {} )
  @config = DaemonKit::Config.load('amqp').to_h( true )
end
run(&block) click to toggle source
# File lib/daemon_kit/amqp.rb, line 19
def run(&block)
  instance.run(&block)
end

Public Instance Methods

run(&block) click to toggle source
# 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 and AMQP client
  DaemonKit.logger.debug("AMQP.start(#{@config.inspect})")
  ::AMQP.start(@config, &block)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.