Repository URL to install this package:
|
Version:
0.2.10 ▾
|
local queue_name = ARGV[1];
local message = nil;
if queue_name ~= false then
local active_partitions_key = 'rrq:queue:' .. queue_name .. ':active_partitions';
local next_partition = redis.call('rpoplpush', active_partitions_key, active_partitions_key);
if next_partition ~= false then
local partition_key = 'rrq:queue:' .. queue_name .. ':' .. next_partition;
local working_key = partition_key .. ':working';
message = redis.call('rpoplpush', partition_key, working_key);
if message == false then
redis.call('lrem', active_partitions_key, 0, next_partition)
local partition_for_queue_key = 'rrq:queue:' .. queue_name .. ':all_partitions';
redis.call('srem', partition_for_queue_key, next_partition);
end
end
end
return message;