Skip to content

Commit 1e1d395

Browse files
committed
add queue settings
The patch added the ability to set the queue settings(by calling "queue.set_settings(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 3322188 commit 1e1d395

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

queue/abstract.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ local queue = {
2828
return not (self[tube_name] == nil)
2929
end
3030
}),
31-
stat = {}
31+
stat = {},
32+
settings = {}
3233
}
3334
local MAX_TIMEOUT = 365 * 86400 * 100 -- MAX_TIMEOUT == 100 years
3435
local TIMEOUT_INFINITY = 18446744073709551615ULL -- Set to TIMEOUT_INFINITY
@@ -532,6 +533,22 @@ function method.create_tube(tube_name, tube_type, opts)
532533
return self
533534
end
534535

536+
function method.set_settings(opts)
537+
opts = opts or {}
538+
539+
for key, val in pairs(opts) do
540+
if key == 'ttr' then
541+
if val < 0 then
542+
error('Invalid value of ttr: ' .. val)
543+
end
544+
else
545+
error('Unknown option ' .. key)
546+
end
547+
end
548+
549+
queue.settings = opts
550+
end
551+
535552
--- Create everything that's needed to work with "shared" sessions.
536553
local function identification_init()
537554
local queue_session_ids = box.space._queue_session_ids

0 commit comments

Comments
 (0)