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.
7 8 9 |
# File 'lib/rabbitmq_service_util.rb', line 7 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
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rabbitmq_service_util.rb', line 12 def self.cf_amqp_connection_url services_env = ENV['VCAP_SERVICES'] if services_env services = JSON.parse(services_env, :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 end |
.heroku_amqp_connection_url ⇒ Object
Obtain the AMQP connection URL on Heroku
29 30 31 |
# File 'lib/rabbitmq_service_util.rb', line 29 def self.heroku_amqp_connection_url ENV['RABBITMQ_URL'] end |