Module: RabbitMQ
- Defined in:
- lib/rabbitmq_service_util.rb
Class Method Summary collapse
-
.amqp_connection_url ⇒ Object
Obtain the AMQP connection URL for the RabbitMQ service instance for this app.
-
.cf_amqp_connection_url ⇒ Object
Obtain the AMQP connection URL on Cloud Foundry.
-
.heroku_amqp_connection_url ⇒ Object
Obtain the AMQP connection URL on Heroku.
Class Method Details
.amqp_connection_url ⇒ Object
Obtain the AMQP connection URL for the RabbitMQ service instance for this app. This URL can be passed directly to recent versions onf the amqp and bunny gems.
5 6 7 |
# File 'lib/rabbitmq_service_util.rb', line 5 def self.amqp_connection_url cf_amqp_connection_url || heroku_amqp_connection_url end |
.cf_amqp_connection_url ⇒ Object
Obtain the AMQP connection URL on Cloud Foundry
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rabbitmq_service_util.rb', line 10 def self.cf_amqp_connection_url services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true) url = services.values.map do |srvs| srvs.map do |srv| if srv[:label] =~ /^rabbitmq-/ srv[:credentials][:url] else [] end end end.flatten!.first end |
.heroku_amqp_connection_url ⇒ Object
Obtain the AMQP connection URL on Heroku
24 25 26 |
# File 'lib/rabbitmq_service_util.rb', line 24 def self.heroku_amqp_connection_url ENV['RABBITMQ_URL'] end |