Merge remote-tracking branch 'origin/1.8.x' into feat-txn

This commit is contained in:
Jake Barnby 2025-09-16 12:58:09 +12:00
commit a7cff1b53d
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
6 changed files with 32 additions and 20 deletions

View file

@ -538,7 +538,7 @@ App::get('/v1/health/queue/databases')
->inject('response')
->action(function (string $name, int|string $threshold, Database $queueForDatabase, Response $response) {
$threshold = \intval($threshold);
$size = $queueForDatabase->getSize();
$size = $queueForDatabase->setQueue($name)->getSize();
if ($size >= $threshold) {
throw new Exception(Exception::HEALTH_QUEUE_SIZE_EXCEEDED, "Queue size threshold hit. Current size is {$size} and threshold is {$threshold}.");

View file

@ -246,10 +246,11 @@ App::init()
$role = $apiKey->getRole();
$scopes = $apiKey->getScopes();
// Disable authorization checks for API keys
Authorization::setDefaultStatus(false);
if ($apiKey->getRole() === Auth::USER_ROLE_APPS) {
// Disable authorization checks for API keys
Authorization::setDefaultStatus(false);
$user = new Document([
'$id' => '',
'status' => true,

View file

@ -10,6 +10,7 @@ use Swoole\Http\Response as SwooleResponse;
use Swoole\Http\Server;
use Swoole\Process;
use Swoole\Table;
use Swoole\Timer;
use Utopia\App;
use Utopia\Audit\Audit;
use Utopia\CLI\Console;
@ -156,11 +157,16 @@ $http->on(Constant::EVENT_WORKER_START, function ($server, $workerId) {
Console::success('Worker ' . ++$workerId . ' started successfully');
});
$http->on(Constant::EVENT_BEFORE_RELOAD, function ($server, $workerId) {
$http->on(Constant::EVENT_WORKER_STOP, function ($server, $workerId) {
Timer::clearAll();
Console::success('Worker ' . ++$workerId . ' stopped successfully');
});
$http->on(Constant::EVENT_BEFORE_RELOAD, function ($server) {
Console::success('Starting reload...');
});
$http->on(Constant::EVENT_AFTER_RELOAD, function ($server, $workerId) {
$http->on(Constant::EVENT_AFTER_RELOAD, function ($server) {
Console::success('Reload completed...');
});
@ -550,7 +556,7 @@ $http->on(Constant::EVENT_TASK, function () use ($register, $domains) {
/** @var Utopia\Database\Database $dbForPlatform */
$dbForPlatform = $app->getResource('dbForPlatform');
Console::loop(function () use ($dbForPlatform, $domains, &$lastSyncUpdate) {
Timer::tick(DOMAIN_SYNC_TIMER * 1000, function () use ($dbForPlatform, $domains, &$lastSyncUpdate) {
try {
$time = DateTime::now();
$limit = 1000;
@ -589,8 +595,6 @@ $http->on(Constant::EVENT_TASK, function () use ($register, $domains) {
} catch (Throwable $th) {
Console::error($th->getMessage());
}
}, DOMAIN_SYNC_TIMER, 0, function ($error) {
Console::error($error);
});
});

View file

@ -4,5 +4,9 @@
"repository": {
"type": "git",
"url": "git+https://github.com/appwrite/appwrite.git"
}
}
},
"files": [
"docs/examples",
"app/config/specs"
]
}

View file

@ -161,17 +161,20 @@ class Database extends Event
return $this->document;
}
public function getQueue(): string
public function setProject(Document $project): self
{
try {
$dsn = new DSN($this->getProject()->getAttribute('database'));
} catch (\InvalidArgumentException) {
// TODO: Temporary until all projects are using shared tables
$dsn = new DSN('mysql://' . $this->getProject()->getAttribute('database'));
$database = $project->getAttribute('database');
if (!empty($database)) {
try {
$dsn = new DSN($database);
} catch (\InvalidArgumentException) {
// TODO: Temporary until all projects are using shared tables
$dsn = new DSN("mysql://$database");
}
$this->queue = $dsn->getHost();
}
$this->queue = $dsn->getHost();
return $this->queue;
return parent::setProject($project);
}
/**

View file

@ -77,8 +77,8 @@ class Get extends Action
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_COLLECTIONS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_DOCUMENTS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_STORAGE),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASES_OPERATIONS_READS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASES_OPERATIONS_WRITES)
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_READS),
str_replace('{databaseInternalId}', $database->getSequence(), METRIC_DATABASE_ID_OPERATIONS_WRITES)
];
Authorization::skip(function () use ($dbForProject, $days, $metrics, &$stats) {