@@ -43,7 +43,9 @@ local constants = {
43
43
-- assumed size of vinyl space (in the first iteration)
44
44
default_vinyl_assumed_space_len = math.pow (10 , 7 ),
45
45
-- factor for recalculation of vinyl space size
46
- default_vinyl_assumed_space_len_factor = 2
46
+ default_vinyl_assumed_space_len_factor = 2 ,
47
+ -- default function on full scan
48
+ default_on_full_scan = function (...) end
47
49
}
48
50
49
51
-- ========================================================================= --
@@ -160,7 +162,18 @@ local function worker_loop(task)
160
162
161
163
while true do
162
164
if (box .cfg .replication_source == nil and box .cfg .replication == nil ) or task .force then
163
- task .do_worker_iteration (task )
165
+ task .on_full_scan_start (task )
166
+ local state , err = pcall (task .do_worker_iteration , task )
167
+ if state then
168
+ task .on_full_scan_success (task )
169
+ else
170
+ task .on_full_scan_error (task , err )
171
+ end
172
+
173
+ task .on_full_scan_complete (task )
174
+ if not state then
175
+ error (err )
176
+ end
164
177
end
165
178
166
179
-- Full scan iteration is complete, yield
@@ -253,6 +266,10 @@ local function create_task(name)
253
266
full_scan_time = constants .default_full_scan_time ,
254
267
vinyl_assumed_space_len = constants .default_vinyl_assumed_space_len ,
255
268
vinyl_assumed_space_len_factor = constants .default_vinyl_assumed_space_len_factor ,
269
+ on_full_scan_error = constants .default_on_full_scan ,
270
+ on_full_scan_success = constants .default_on_full_scan ,
271
+ on_full_scan_start = constants .default_on_full_scan ,
272
+ on_full_scan_complete = constants .default_on_full_scan
256
273
}, { __index = Task_methods })
257
274
return task
258
275
end
291
308
-- options = { -- (table with named options)
292
309
-- * process_expired_tuple -- applied to expired tuples, receives
293
310
-- (space_id, args, tuple) as arguments
311
+ -- * on_full_scan_start -- call function on starting full scan iteration
312
+ -- * on_full_scan_complete -- call function on complete full scan iteration
313
+ -- * on_full_scan_success -- call function on success full scan iteration
314
+ -- * on_full_scan_error -- call function on error full scan iteration
294
315
-- * args -- passed to is_tuple_expired and
295
316
-- process_expired_tuple() as additional context
296
317
-- * tuples_per_iteration -- number of tuples will be checked by one iteration
@@ -398,6 +419,34 @@ local function expirationd_run_task(name, space_id, is_tuple_expired, options)
398
419
task .full_scan_delay = options .full_scan_delay
399
420
end
400
421
422
+ if options .on_full_scan_start ~= nil then
423
+ if type (options .on_full_scan_start ) ~= ' function' then
424
+ error (" invalid type of on_full_scan_start is not function" )
425
+ end
426
+ task .on_full_scan_start = options .on_full_scan_start
427
+ end
428
+
429
+ if options .on_full_scan_success ~= nil then
430
+ if type (options .on_full_scan_success ) ~= ' function' then
431
+ error (" invalid type of on_full_scan_success is not function" )
432
+ end
433
+ task .on_full_scan_success = options .on_full_scan_success
434
+ end
435
+
436
+ if options .on_full_scan_complete ~= nil then
437
+ if type (options .on_full_scan_complete ) ~= ' function' then
438
+ error (" invalid type of on_full_scan_complete is not function" )
439
+ end
440
+ task .on_full_scan_complete = options .on_full_scan_complete
441
+ end
442
+
443
+ if options .on_full_scan_error ~= nil then
444
+ if type (options .on_full_scan_error ) ~= ' function' then
445
+ error (" invalid type of on_full_scan_error is not function" )
446
+ end
447
+ task .on_full_scan_error = options .on_full_scan_error
448
+ end
449
+
401
450
-- put the task to table
402
451
task_list [name ] = task
403
452
-- run
0 commit comments