lib/qpush/server/delay.rb in qpush-0.1.2 vs lib/qpush/server/delay.rb in qpush-0.1.4
- old
+ new
@@ -20,11 +20,11 @@
end
sleep 2
end
end
- # Shutsdown our dleay process.
+ # Shutsdown our delay process.
#
def shutdown
@done = true
end
@@ -32,35 +32,35 @@
# Retrieves delayed jobs based on the time they should be performed.
# If any are found, begin to update them.
#
def retrieve_delays
- delays = @conn.zrangebyscore(QPush.config.delay_namespace, 0, Time.now.to_i)
+ delays = @conn.zrangebyscore(QPush.keys.delay, 0, Time.now.to_i)
delays.any? ? update_delays(delays) : @conn.unwatch
end
# Removes jobs that have been retrieved and sets them up to be performed.
#
def update_delays(delays)
@conn.multi do |multi|
- multi.zrem(QPush.config.delay_namespace, delays)
+ multi.zrem(QPush.keys.delay, delays)
delays.each { |job| perform_job(job) }
end
end
# Add a delayed job to the appropriate perform list.
#
def perform_job(json)
job = Job.new(JSON.parse(json))
- job.api.perform
+ job.perform
rescue => e
raise ServerError, e.message
end
# Performs a watch on our delay list
#
def watch_delay
- @conn.watch(QPush.config.delay_namespace) do
+ @conn.watch(QPush.keys.delay) do
yield if block_given?
end
end
end
end