Module: AMQP
- Includes:
- EventedSpec::AMQPBackports
- Defined in:
- lib/evented-spec/ext/amqp.rb
Overview
module EventedSpec
Class Method Summary collapse
- .amqp_pre_08? ⇒ Boolean
-
.cleanup_state ⇒ Object
Cleans up AMQP state after AMQP connection closes.
-
.start_connection(opts = {}, &block) ⇒ Object
Initializes new AMQP client/connection without starting another EM loop.
-
.stop_connection ⇒ Object
Closes AMQP connection gracefully.
Methods included from EventedSpec::AMQPBackports
Class Method Details
.amqp_pre_08? ⇒ Boolean
51 52 53 |
# File 'lib/evented-spec/ext/amqp.rb', line 51 def self.amqp_pre_08? AMQP::VERSION < "0.8" end |
.cleanup_state ⇒ Object
Cleans up AMQP state after AMQP connection closes
44 45 46 47 48 49 |
# File 'lib/evented-spec/ext/amqp.rb', line 44 def self.cleanup_state Thread.list.each { |thread| thread[:mq] = nil } Thread.list.each { |thread| thread[:mq_id] = nil } self.connection = nil @closing = false end |
.start_connection(opts = {}, &block) ⇒ Object
Initializes new AMQP client/connection without starting another EM loop
22 23 24 25 26 27 28 29 |
# File 'lib/evented-spec/ext/amqp.rb', line 22 def self.start_connection(opts={}, &block) if amqp_pre_08? self.connection = connect opts self.connection.callback &block else self.connection = connect opts, &block end end |
.stop_connection ⇒ Object
Closes AMQP connection gracefully
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/evented-spec/ext/amqp.rb', line 32 def self.stop_connection if AMQP.connection and not AMQP.connection.closing? @closing = true self.connection.close { yield if block_given? self.connection = nil cleanup_state } end end |