mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Set hard timeouts for API dbs
This commit is contained in:
@@ -466,6 +466,11 @@ return [
|
||||
'description' => 'Database already exists',
|
||||
'code' => 409
|
||||
],
|
||||
Exception::DATABASE_TIMEOUT => [
|
||||
'name' => Exception::DATABASE_TIMEOUT,
|
||||
'description' => 'Database timed out.',
|
||||
'code' => 408
|
||||
],
|
||||
|
||||
/** Collections */
|
||||
Exception::COLLECTION_NOT_FOUND => [
|
||||
|
||||
@@ -690,7 +690,11 @@ App::error()
|
||||
break;
|
||||
}
|
||||
} elseif ($error instanceof Utopia\Database\Exception\Conflict) {
|
||||
$error = new AppwriteException(AppwriteException::DOCUMENT_UPDATE_CONFLICT, null, null, $error);
|
||||
$error = new AppwriteException(AppwriteException::DOCUMENT_UPDATE_CONFLICT, previous: $error);
|
||||
$code = $error->getCode();
|
||||
$message = $error->getMessage();
|
||||
} elseif ($error instanceof Utopia\Database\Exception\Timeout) {
|
||||
$error = new AppwriteException(AppwriteException::DATABASE_TIMEOUT, $message, previous: $error);
|
||||
$code = $error->getCode();
|
||||
$message = $error->getMessage();
|
||||
}
|
||||
|
||||
+8
-4
@@ -1115,11 +1115,13 @@ App::setResource('dbForProject', function (Group $pools, Database $dbForConsole,
|
||||
$dbAdapter = $pools
|
||||
->get($project->getAttribute('database'))
|
||||
->pop()
|
||||
->getResource()
|
||||
;
|
||||
->getResource();
|
||||
|
||||
$database = new Database($dbAdapter, $cache);
|
||||
$database->setNamespace('_' . $project->getInternalId());
|
||||
|
||||
$database
|
||||
->setNamespace('_' . $project->getInternalId())
|
||||
->setTimeout(milliseconds: 15000);
|
||||
|
||||
return $database;
|
||||
}, ['pools', 'dbForConsole', 'cache', 'project']);
|
||||
@@ -1133,7 +1135,9 @@ App::setResource('dbForConsole', function (Group $pools, Cache $cache) {
|
||||
|
||||
$database = new Database($dbAdapter, $cache);
|
||||
|
||||
$database->setNamespace('_console');
|
||||
$database
|
||||
->setNamespace('_console')
|
||||
->setTimeout(milliseconds: 15000);
|
||||
|
||||
return $database;
|
||||
}, ['pools', 'cache']);
|
||||
|
||||
@@ -145,6 +145,7 @@ class Exception extends \Exception
|
||||
/** Databases */
|
||||
public const DATABASE_NOT_FOUND = 'database_not_found';
|
||||
public const DATABASE_ALREADY_EXISTS = 'database_already_exists';
|
||||
public const DATABASE_TIMEOUT = 'database_timeout';
|
||||
|
||||
/** Collections */
|
||||
public const COLLECTION_NOT_FOUND = 'collection_not_found';
|
||||
|
||||
Reference in New Issue
Block a user