class QPush::Server::Apis::Delay
The Delay
API will take a job and add it to the delay sorted set.
Public Class Methods
new(job, type)
click to toggle source
# File lib/qpush/server/apis/delay.rb, line 7 def initialize(job, type) @job = job @type = type end
Public Instance Methods
call()
click to toggle source
# File lib/qpush/server/apis/delay.rb, line 12 def call load_type delay_job end
Private Instance Methods
delay_job()
click to toggle source
# File lib/qpush/server/apis/delay.rb, line 19 def delay_job Server.redis do |conn| conn.hincrby(Server.keys[:stats], @stat, 1) conn.zadd(Server.keys[:delay], @time, @job.to_json) end end
load_type()
click to toggle source
# File lib/qpush/server/apis/delay.rb, line 26 def load_type case @type when :delay @stat = 'delayed' @time = @job.delay_until when :retry @stat = 'retries' @time = @job.retry_at end end