Add AMQP URL inference mechanism

pull/527/head
Rick Carlino 2017-10-30 10:21:55 -05:00
parent 0e84253825
commit 28685dcfd6
2 changed files with 11 additions and 4 deletions

View File

@ -1,10 +1,18 @@
# A wrapper around AMQP to stay DRY. Will make life easier if we ever need to
# change protocols
module Transport
AMQP_URL = ENV['CLOUDAMQP_URL'] ||
ENV['RABBITMQ_URL'] ||
"amqp://guest:guest@localhost:5672"
def self.connection
@connection ||= Bunny.new(AMQP_URL, read_timeout: 10, heartbeat: 10).start
end
def self.topic
@topic ||= Bunny
.new(read_timeout: 10, heartbeat: 10)
.start
@topic ||= self
.connection
.create_channel
.topic("amq.topic", auto_delete: true)
end

View File

@ -138,7 +138,6 @@ result.push(enum_type :LegalArgString, HASH[:args].map{ |x| x[:name] }.sort.uniq
result.push(enum_type :LegalKindString, HASH[:nodes].map{ |x| x[:name] }.sort.uniq)
result.push(enum_type :LegalSequenceKind, CeleryScriptSettingsBag::STEPS.sort)
result.push(enum_type :DataChangeType, CeleryScriptSettingsBag::ALLOWED_CHAGES)
result.push(enum_type :ResourceName, CeleryScriptSettingsBag::RESOURCE_NAME)
result.push(enum_type :PointType, CeleryScriptSettingsBag::ALLOWED_POINTER_TYPE)
puts result.join.gsub("\n\n\n", "\n")