Class: Rjob::Scripts::RetryJob

Inherits:
RedisScript show all
Defined in:
lib/rjob/scripts/retry_job.rb

Instance Attribute Summary

Attributes inherited from RedisScript

#sha1

Instance Method Summary collapse

Methods inherited from RedisScript

#key_params

Instance Method Details

#arg_paramsObject



4
5
6
# File 'lib/rjob/scripts/retry_job.rb', line 4

def arg_params
  %i(next_retry_at retry_num bucket job_id job_payload prefix)
end

#lua_scriptObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/rjob/scripts/retry_job.rb', line 8

def lua_script
  <<~LUA
    local timestamp = ARGV[1]
    local retry_num = ARGV[2]
    local bucket = ARGV[3]
    local job_id = ARGV[4]
    local job_payload = ARGV[5]
    local prefix = ARGV[6]
    local r = redis

    local curr_job = job_id .. '!' .. retry_num .. '!' .. job_payload
    local new_job = job_id .. '!' .. (retry_num + 1) .. '!' .. job_payload

    r.call('lrem', prefix .. ':jobs:' .. bucket .. ':working', 1, curr_job)
    r.call('zadd', prefix .. ':scheduled:' .. bucket, timestamp, new_job)

    return job_id
  LUA
end