Sha256: 976cf8b0539c14738653bb49eb3fcd96ff719969511f1369dbc9d896fd7e5b9e

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

-- NOTE: We store the job as the last argument passed to this script because it
--       is more efficient to pop in Lua than shift
local job = table.remove(ARGV)
-- Remove job from reliability queue
redis.call("LREM", KEYS[3], 0, job)
redis.call("ZREM", KEYS[4], job)

-- Update context hash with buffer
if #ARGV > 0 then
  redis.call("HMSET", KEYS[5], unpack(ARGV))
end

-- Decrement jobs from the sorted set by applying a jobmask
redis.call("ZUNIONSTORE", KEYS[1], 2, KEYS[1], KEYS[7])
redis.call("DEL", KEYS[7])

-- Queue jobs that are ready to be processed (their score is 0) and
-- remove queued jobs from sorted set
local work = redis.call("ZRANGEBYSCORE", KEYS[1], 0, 0)
if #work > 0 then
  redis.call("LPUSH", KEYS[2], unpack(work))
  redis.call("ZREM", KEYS[1], unpack(work))
end

-- Decrement ETA and remove it together with the context and jobmasks if all
-- tasks have been processed (ETA is 0) or if workflow has been given up (ETA is -1)
local remaining = redis.call("DECR", KEYS[6])
if remaining <= 0 then
  redis.call("DEL", KEYS[5], KEYS[6], KEYS[8])
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pallets-0.11.0 lib/pallets/backends/scripts/save.lua
pallets-0.10.0 lib/pallets/backends/scripts/save.lua
pallets-0.9.0 lib/pallets/backends/scripts/save.lua