1
0
Fork 0
mirror of synced 2024-10-03 19:53:33 +13: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 */ $pools = $register->get('pools'); /** @var \Utopia\Pools\Group $pools */
try { $dbAdapter = $pools
$dbAdapter = $pools ->get('console')
->get('console') ->pop()
->pop() ->getResource()
->getResource() ;
;
} catch (Throwable $error) {
$pools->fill();
$dbAdapter = $pools
->get('console')
->pop()
->getResource()
;
}
$database = new Database($dbAdapter, getCache()); $database = new Database($dbAdapter, getCache());
@ -80,20 +71,11 @@ function getProjectDB(Document $project): Database
return getConsoleDB(); return getConsoleDB();
} }
try { $dbAdapter = $pools
$dbAdapter = $pools ->get($project->getAttribute('database'))
->get($project->getAttribute('database')) ->pop()
->pop() ->getResource()
->getResource() ;
;
} catch (Throwable $error) {
$pools->fill();
$dbAdapter = $pools
->get($project->getAttribute('database'))
->pop()
->getResource()
;
}
$database = new Database($dbAdapter, getCache()); $database = new Database($dbAdapter, getCache());
$database->setNamespace('_' . $project->getInternalId()); $database->setNamespace('_' . $project->getInternalId());

View file

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