Module: Netfira::WebConnect::AMQP
- Defined in:
- lib/netfira/web_connect/amqp.rb
Class Method Summary collapse
- .connect! ⇒ Object
- .connected? ⇒ Boolean
- .disconnect! ⇒ Object
- .exchange_for_shop(shop) ⇒ Object
- .queue_name_for_shop(shop) ⇒ Object
Class Method Details
.connect! ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/netfira/web_connect/amqp.rb', line 7 def connect! disconnect! @connection = Bunny.new(Netfira::WebConnect.amqp_uri) @connection.start @channel = @connection.create_channel @exchanges = {} end |
.connected? ⇒ Boolean
15 16 17 |
# File 'lib/netfira/web_connect/amqp.rb', line 15 def connected? !!@connection end |
.disconnect! ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/netfira/web_connect/amqp.rb', line 19 def disconnect! return unless connected? @connection.stop @connection = nil @channel = nil @exchanges = nil end |
.exchange_for_shop(shop) ⇒ Object
27 28 29 |
# File 'lib/netfira/web_connect/amqp.rb', line 27 def exchange_for_shop(shop) @exchanges && @exchanges[shop.id || 0] ||= make_exchange_for_shop(shop) end |
.queue_name_for_shop(shop) ⇒ Object
31 32 33 |
# File 'lib/netfira/web_connect/amqp.rb', line 31 def queue_name_for_shop(shop) "shops.#{shop.id || 0}" end |