1
0
Fork 0
mirror of synced 2024-10-02 02:07:04 +13:00

Set the queue name based on project DB

This commit is contained in:
Jake Barnby 2023-10-11 17:21:40 +13:00
parent ca5b7f5b16
commit 365630ff39
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 5 additions and 15 deletions

2
.env
View file

@ -4,7 +4,7 @@ _APP_WORKER_PER_CORE=6
_APP_CONSOLE_WHITELIST_ROOT=disabled
_APP_CONSOLE_WHITELIST_EMAILS=
_APP_CONSOLE_WHITELIST_IPS=
_APP_CONNECTIONS_DB_QUEUES=v1-database-0,v1-database-1
_APP_CONNECTIONS_QUEUE_PER_WORKER=enabled
_APP_SYSTEM_EMAIL_NAME=Appwrite
_APP_SYSTEM_EMAIL_ADDRESS=team@appwrite.io
_APP_SYSTEM_SECURITY_EMAIL_ADDRESS=security@appwrite.io

View file

@ -28,23 +28,13 @@ class DatabaseV1 extends Worker
{
global $table, $lock;
$dbQueues = App::getEnv('_APP_CONNECTIONS_DB_QUEUES');
$dbQueues = App::getEnv('_APP_CONNECTIONS_QUEUE_PER_WORKER', 'disabled');
if (empty($dbQueues)) {
if ($dbQueues !== 'enabled') {
$queue = 'v1-database';
} elseif (\str_contains($dbQueues, ',')) {
$dbQueues = \explode(',', $dbQueues);
$dbQueues = \array_map('trim', $dbQueues);
$dbQueues = \array_filter($dbQueues);
$dbQueues = \array_values($dbQueues);
$count = $table->get('databases', 'workerCount');
Console::log('Database worker count: ' . $count);
$queue = $dbQueues[$count];
} else {
$queue = \trim($dbQueues);
$project = new Document($this->args['project']);
$queue = $project->getAttribute('database');
}
\putenv('QUEUE=' . $queue);