1
0
Fork 0
mirror of synced 2024-07-04 14:10:33 +12:00

pool reclaim

This commit is contained in:
Damodar Lohani 2022-10-24 01:34:12 +00:00
parent adf3f74ef2
commit 70afd1efed
2 changed files with 12 additions and 29 deletions

View file

@ -47,20 +47,11 @@ function getConsoleDB(): Database
$pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */
try {
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
} catch (Throwable $error) {
$pools->fill();
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
}
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
$database = new Database($dbAdapter, getCache());
@ -80,20 +71,11 @@ function getProjectDB(Document $project): Database
return getConsoleDB();
}
try {
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
} catch (Throwable $error) {
$pools->fill();
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
}
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
$database = new Database($dbAdapter, getCache());
$database->setNamespace('_' . $project->getInternalId());

View file

@ -92,7 +92,7 @@ $cli
->task('usage')
->param('type', 'timeseries', new WhiteList(['timeseries', 'database']))
->desc('Schedules syncing data from influxdb to Appwrite console db')
->action(function (string $type) use ($logError) {
->action(function (string $type) use ($logError, $register) {
Console::title('Usage Aggregation V1');
Console::success(APP_NAME . ' usage aggregation process v1 has started');
@ -110,4 +110,5 @@ $cli
default:
Console::error("Unsupported usage aggregation type");
}
$register->get('pools')->reclaim();
});