1
0
Fork 0
mirror of synced 2024-06-30 04:00:34 +12:00
This commit is contained in:
shimon 2022-11-06 16:40:08 +02:00
parent ed505fba7c
commit 0e99198fa8

View file

@ -13,6 +13,7 @@ use Swoole\Timer;
const FUNCTION_VALIDATION_TIMER = 180; //seconds
const FUNCTION_ENQUEUE_TIMER = 60; //seconds
const ENQUEUE_TIME_FRAME = 60 * 5; // 5 min
sleep(4); // Todo prevent PDOException
$cli
->task('schedule-new')
@ -35,6 +36,17 @@ $cli
}
};
$removeFromQueue = function ($scheduleId) use (&$queue) {
foreach ($queue as $slot => $schedule) {
foreach ($schedule as $function) {
if ($scheduleId === $function['scheduleId']) {
unset($queue[$slot][$function['scheduleId']]);
}
}
}
};
$dbForConsole = getConsoleDB();
$count = 0;
$limit = 50;
@ -64,8 +76,8 @@ $cli
$lastUpdate = DateTime::addSeconds(new \DateTime(), -FUNCTION_VALIDATION_TIMER);
Co\run(
function () use ($createQueue, $dbForConsole, &$functions, &$queue, &$lastUpdate) {
Timer::tick(FUNCTION_VALIDATION_TIMER * 1000, function () use ($createQueue, $dbForConsole, &$functions, &$queue, &$lastUpdate) {
function () use ($removeFromQueue, $createQueue, $dbForConsole, &$functions, &$queue, &$lastUpdate) {
Timer::tick(FUNCTION_VALIDATION_TIMER * 1000, function () use ($removeFromQueue, $createQueue, $dbForConsole, &$functions, &$queue, &$lastUpdate) {
$time = DateTime::now();
$count = 0;
$limit = 50;
@ -93,6 +105,7 @@ $cli
Console::error("Updating: {$document['scheduleId']}");
$functions[$document['scheduleId']] = $document;
}
$removeFromQueue($document['scheduleId']);
$count++;
}
}