Improve reclaim of pools in schedule

This commit is contained in:
Matej Baco
2022-11-15 11:39:24 +01:00
parent 22effdd88a
commit b031e13997
2 changed files with 9 additions and 6 deletions
+5 -5
View File
@@ -61,16 +61,16 @@ CLI::setResource('getProjectDB', function (Group $pools, Database $dbForConsole,
return $dbForConsole;
}
$dbAdapter = $pools
$connection = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
->pop();
$dbAdapter = $connection->getResource();
$database = new Database($dbAdapter, $cache);
$database->setNamespace('_' . $project->getInternalId());
return $database;
return [ $database, fn() => $connection->claim() ];
};
return $getProjectDB;
+4 -1
View File
@@ -49,7 +49,10 @@ class Schedule extends Action
*/
$getSchedule = function (Document $schedule) use ($dbForConsole, $getProjectDB): array {
$project = $dbForConsole->getDocument('projects', $schedule->getAttribute('projectId'));
$function = $getProjectDB($project)->getDocument('functions', $schedule->getAttribute('resourceId'));
[ $database, $reclaim ] = $getProjectDB($project);
$function = $database->getDocument('functions', $schedule->getAttribute('resourceId'));
$reclaim();
return [
'resourceId' => $schedule->getAttribute('resourceId'),