Sha256: 85259d88a8ef77c2467cf051d03bde1bfc2c1c7b1b705079bcb75b7fc64c4b6d

Contents?: true

Size: 1.08 KB

Versions: 6

Compression:

Stored size: 1.08 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 all jobs from the sorted set
local all_pending = redis.call("ZRANGE", KEYS[1], 0, -1)
for score, task in pairs(all_pending) do
  redis.call("ZINCRBY", KEYS[1], -1, task)
end

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

-- Decrement ETA and remove it together with the context if all tasks have
-- been processed (ETA is 0)
redis.call("DECR", KEYS[6])
if tonumber(redis.call("GET", KEYS[6])) == 0 then
  redis.call("DEL", KEYS[5], KEYS[6])
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pallets-0.7.0 lib/pallets/backends/scripts/save.lua
pallets-0.6.0 lib/pallets/backends/scripts/save.lua
pallets-0.5.1 lib/pallets/backends/scripts/save.lua
pallets-0.5.0 lib/pallets/backends/scripts/save.lua
pallets-0.4.0 lib/pallets/backends/scripts/save.lua
pallets-0.3.0 lib/pallets/backends/scripts/save.lua