Job call cleanup

pull/527/head
Rick Carlino 2017-11-05 12:51:16 -06:00
parent 9cfe254f33
commit 78f240f262
2 changed files with 6 additions and 14 deletions

View File

@ -4,10 +4,7 @@ class AutoSyncJob < ApplicationJob
def perform(broadcast_payload, id, channel, created_at_utc_integer)
wayback = Time.at(created_at_utc_integer).utc
mins = ((wayback - Time.now.utc) / 1.minute).round
if (mins < 2)
Transport
.topic
.publish(message, routing_key: "bot.device_#{id}.#{channel}")
end
Transport.send(broadcast_payload, id, channel) if (mins < 2)
end
end

View File

@ -1,17 +1,12 @@
# 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"
AMQP_OPTIONS = { read_timeout: 10,
heartbeat: 10,
log_level: 'info' }
LOCAL = "amqp://guest:guest@localhost:5672"
AMQP_URL = ENV['CLOUDAMQP_URL'] || ENV['RABBITMQ_URL'] || LOCAL
OPTS = { read_timeout: 10, heartbeat: 10, log_level: 'info' }
def self.connection
@connection ||= Bunny.new(AMQP_URL, AMQP_OPTIONS).start
@connection ||= Bunny.new(AMQP_URL, OPTS).start
end
def self.topic