Skip to content

Commit 92c3e52

Browse files
committed
add queue settings
The patch adds the ability to set the queue settings(by calling "queue.cfg(opts)"). Now only one setting is available - "ttr"(time to release). "ttr" in seconds - the time after which, if there is no active connection in the session, it will be released with all its tasks. Part of #85
1 parent 61105ec commit 92c3e52

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

queue/abstract.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,27 @@ local function build_stats(space)
628628
return stats
629629
end
630630

631+
--- Configure of the queue module.
632+
-- If an invalid value or an unknown option
633+
-- is used, an error will be thrown.
634+
local function cfg(self, opts)
635+
opts = opts or {}
636+
637+
-- Check all options before configuring so that
638+
-- the configuration is done transactionally.
639+
for key, val in pairs(opts) do
640+
if key ~= 'ttr' then
641+
error('Unknown option ' .. tostring(key))
642+
end
643+
end
644+
645+
for key, val in pairs(opts) do
646+
self[key] = val
647+
end
648+
end
649+
650+
queue.cfg = setmetatable({}, { __call = cfg })
651+
631652
queue.statistics = function(space)
632653
if space ~= nil then
633654
return build_stats(space)

0 commit comments

Comments
 (0)