Comparison

plugins/mod_muc_mam.lua @ 10585:2d8535338099

mod_muc_mam: Measure how long a cleanup run takes (like mod_mam)
author Kim Alvefur <zash@zash.se>
date Sat, 04 Jan 2020 14:05:10 +0100
parent 10568:b6f93babebe8
child 10671:5e1384298e97
comparison
equal deleted inserted replaced
10584:0c464bb7eb03 10585:2d8535338099
479 if ok then 479 if ok then
480 last_date:set(roomname, date); 480 last_date:set(roomname, date);
481 end 481 end
482 end 482 end
483 483
484 local cleanup_time = module:measure("cleanup", "times");
485
484 cleanup_runner = require "util.async".runner(function () 486 cleanup_runner = require "util.async".runner(function ()
487 local cleanup_done = cleanup_time();
485 local rooms = {}; 488 local rooms = {};
486 local cut_off = datestamp(os.time() - cleanup_after); 489 local cut_off = datestamp(os.time() - cleanup_after);
487 for date in cleanup_storage:users() do 490 for date in cleanup_storage:users() do
488 if date <= cut_off then 491 if date <= cut_off then
489 module:log("debug", "Messages from %q should be expired", date); 492 module:log("debug", "Messages from %q should be expired", date);
510 cleanup_map:set(cut_off, room, true); 513 cleanup_map:set(cut_off, room, true);
511 module:log("error", "Could not delete messages for room '%s': %s", room, err); 514 module:log("error", "Could not delete messages for room '%s': %s", room, err);
512 end 515 end
513 end 516 end
514 module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms); 517 module:log("info", "Deleted %d expired messages for %d rooms", sum, num_rooms);
518 cleanup_done();
515 end); 519 end);
516 520
517 cleanup_task = module:add_timer(1, function () 521 cleanup_task = module:add_timer(1, function ()
518 cleanup_runner:run(true); 522 cleanup_runner:run(true);
519 return cleanup_interval; 523 return cleanup_interval;