Merge pull request #5620 from appwrite/fix-system-performance
Fix system performance
This commit is contained in:
commit
b68f601240
|
@ -1 +1 @@
|
||||||
Subproject commit 3a0c8f0334d402a6e27c8b5c0512f3d60080ddbd
|
Subproject commit b981302dee30eab33e155af79f0088822b29a2b6
|
|
@ -89,7 +89,6 @@ $http->on('start', function (Server $http) use ($payloadSize, $register) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$cache = $app->getResource('cache'); /** @var Utopia\Cache\Cache $cache */
|
$cache = $app->getResource('cache'); /** @var Utopia\Cache\Cache $cache */
|
||||||
$cache->flush();
|
|
||||||
Console::success('[Setup] - Creating database: appwrite...');
|
Console::success('[Setup] - Creating database: appwrite...');
|
||||||
$dbForConsole->create();
|
$dbForConsole->create();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
|
|
|
@ -265,8 +265,7 @@ $server->job()
|
||||||
while ($sum >= $limit) {
|
while ($sum >= $limit) {
|
||||||
$functions = $dbForProject->find('functions', [
|
$functions = $dbForProject->find('functions', [
|
||||||
Query::limit($limit),
|
Query::limit($limit),
|
||||||
Query::offset($offset),
|
Query::offset($offset)
|
||||||
Query::orderAsc('name'),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sum = \count($functions);
|
$sum = \count($functions);
|
||||||
|
@ -278,7 +277,15 @@ $server->job()
|
||||||
if (!array_intersect($events, $function->getAttribute('events', []))) {
|
if (!array_intersect($events, $function->getAttribute('events', []))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Console::success('Iterating function: ' . $function->getAttribute('name'));
|
|
||||||
|
/** Skip if a function has been triggered by its own execution */
|
||||||
|
$event = "functions.{$function->getId()}.executions.*";
|
||||||
|
if (in_array($event, $events)) {
|
||||||
|
Console::warning("Skipping function: {$function->getAttribute('name')} from project: {$project->getId()} triggered by self");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console::success("Iterating function: {$function->getAttribute('name')} from project: {$project->getId()}");
|
||||||
$execute(
|
$execute(
|
||||||
log: $log,
|
log: $log,
|
||||||
statsd: $statsd,
|
statsd: $statsd,
|
||||||
|
|
|
@ -7,6 +7,11 @@ use Utopia\Validator;
|
||||||
|
|
||||||
class Event extends Validator
|
class Event extends Validator
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected string $message = 'Event is not valid.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Description.
|
* Get Description.
|
||||||
*
|
*
|
||||||
|
@ -16,7 +21,7 @@ class Event extends Validator
|
||||||
*/
|
*/
|
||||||
public function getDescription(): string
|
public function getDescription(): string
|
||||||
{
|
{
|
||||||
return 'Event is not valid.';
|
return $this->message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,6 +45,12 @@ class Event extends Validator
|
||||||
* Identify all sections of the pattern.
|
* Identify all sections of the pattern.
|
||||||
*/
|
*/
|
||||||
$type = $parts[0] ?? false;
|
$type = $parts[0] ?? false;
|
||||||
|
|
||||||
|
if ($type == 'functions') {
|
||||||
|
$this->message = 'Triggering a function on a function event is not allowed.';
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$resource = $parts[1] ?? false;
|
$resource = $parts[1] ?? false;
|
||||||
$hasSubResource = $count > 3 && ($events[$type]['$resource'] ?? false) && ($events[$type][$parts[2]]['$resource'] ?? false);
|
$hasSubResource = $count > 3 && ($events[$type]['$resource'] ?? false) && ($events[$type][$parts[2]]['$resource'] ?? false);
|
||||||
$hasSubSubResource = $count > 5 && $hasSubResource && ($events[$type][$parts[2]][$parts[4]]['$resource'] ?? false);
|
$hasSubSubResource = $count > 5 && $hasSubResource && ($events[$type][$parts[2]][$parts[4]]['$resource'] ?? false);
|
||||||
|
|
Loading…
Reference in a new issue