-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
Lines 691 to 698 in c3b86c8
-- check start_key | |
if options.start_key ~= nil or options.start_key == box.NULL then | |
if type(options.start_key) == "function" then | |
task.start_key = function() return options.start_key() end | |
else | |
task.start_key = function() return options.start_key end | |
end | |
end |
Lines 382 to 390 in c3b86c8
-- default iterate_with function | |
local function default_iterate_with(task) | |
return task.index:pairs(task.start_key(), { iterator = task.iterator_type }) | |
:take_while( | |
function() | |
return task:process_while() | |
end | |
) | |
end |
Should be rewritten to:
-- check start_key
if options.start_key ~= nil or options.start_key == box.NULL then
if type(options.start_key) == "function" then
task.start_key = function(...) return options.start_key(...) end
else
task.start_key = function() return options.start_key end
end
end
-- default iterate_with function
local function default_iterate_with(task)
return task.index:pairs(task.start_key(task.args), { iterator = task.iterator_type })
:take_while(
function()
return task:process_while()
end
)
end
Or should we pass task as it says in README?
Lines 94 to 129 in c3b86c8
```lua | |
expirationd.start(job_name, space.id, is_expired, { | |
-- name or id of the index in the specified space to iterate over | |
index = "exp", | |
-- one transaction per batch | |
-- default is false | |
atomic_iteration = true, | |
-- delete data that was added a year ago | |
-- default is nil | |
start_key = function( task ) | |
return clock.time() - (365*24*60*60) | |
end, | |
-- delete it from the oldest to the newest | |
-- default is ALL | |
iterator_type = "GE", | |
-- stop full_scan if delete a lot | |
-- returns true by default | |
process_while = function( task ) | |
if task.args.max_expired_tuples >= task.expired_tuples_count then | |
task.expired_tuples_count = 0 | |
return false | |
end | |
return true | |
end, | |
-- this function must return an iterator over the tuples | |
iterate_with = function( task ) | |
return task.index:pairs({ task.start_key() }, { iterator = task.iterator_type }) | |
:take_while( function( tuple ) | |
return task:process_while() | |
end ) | |
end, | |
args = { | |
max_expired_tuples = 1000 | |
} | |
}) | |
``` |