lib/qpush/server/delay.rb in qpush-0.1.4 vs lib/qpush/server/delay.rb in qpush-0.1.6
- old
+ new
@@ -12,11 +12,11 @@
# Starts our delay process. This will run until instructed to stop.
#
def start
until @done
- QPush.redis.with do |conn|
+ Server.redis do |conn|
@conn = conn
watch_delay { retrieve_delays }
end
sleep 2
end
@@ -32,19 +32,19 @@
# 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.keys.delay, 0, Time.now.to_i)
+ delays = @conn.zrangebyscore(Server.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.keys.delay, delays)
+ multi.zrem(Server.keys.delay, delays)
delays.each { |job| perform_job(job) }
end
end
# Add a delayed job to the appropriate perform list.
@@ -57,10 +57,10 @@
end
# Performs a watch on our delay list
#
def watch_delay
- @conn.watch(QPush.keys.delay) do
+ @conn.watch(Server.keys.delay) do
yield if block_given?
end
end
end
end