Merge remote-tracking branch 'origin/feat-db-pools' into feat-executor-v3
This commit is contained in:
commit
20bc1ab00e
6 changed files with 190 additions and 12 deletions
|
@ -785,6 +785,17 @@ $collections = [
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('resourceInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('resourceId'),
|
'$id' => ID::custom('resourceId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2223,6 +2234,17 @@ $collections = [
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('deploymentInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('deployment'),
|
'$id' => ID::custom('deployment'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2256,6 +2278,17 @@ $collections = [
|
||||||
'array' => true,
|
'array' => true,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('scheduleInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('scheduleId'),
|
'$id' => ID::custom('scheduleId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2381,6 +2414,17 @@ $collections = [
|
||||||
'$id' => ID::custom('deployments'),
|
'$id' => ID::custom('deployments'),
|
||||||
'name' => 'Deployments',
|
'name' => 'Deployments',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('resourceInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('resourceId'),
|
'$id' => ID::custom('resourceId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2403,6 +2447,17 @@ $collections = [
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('buildInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('buildId'),
|
'$id' => ID::custom('buildId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2583,6 +2638,17 @@ $collections = [
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'$id' => 'deploymentInternalId',
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('deploymentId'),
|
'$id' => ID::custom('deploymentId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2699,6 +2765,17 @@ $collections = [
|
||||||
'$id' => ID::custom('executions'),
|
'$id' => ID::custom('executions'),
|
||||||
'name' => 'Executions',
|
'name' => 'Executions',
|
||||||
'attributes' => [
|
'attributes' => [
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('functionInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('functionId'),
|
'$id' => ID::custom('functionId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
@ -2710,6 +2787,17 @@ $collections = [
|
||||||
'array' => false,
|
'array' => false,
|
||||||
'filters' => [],
|
'filters' => [],
|
||||||
],
|
],
|
||||||
|
[
|
||||||
|
'$id' => ID::custom('deploymentInternalId'),
|
||||||
|
'type' => Database::VAR_STRING,
|
||||||
|
'format' => '',
|
||||||
|
'size' => Database::LENGTH_KEY,
|
||||||
|
'signed' => true,
|
||||||
|
'required' => false,
|
||||||
|
'default' => null,
|
||||||
|
'array' => false,
|
||||||
|
'filters' => [],
|
||||||
|
],
|
||||||
[
|
[
|
||||||
'$id' => ID::custom('deploymentId'),
|
'$id' => ID::custom('deploymentId'),
|
||||||
'type' => Database::VAR_STRING,
|
'type' => Database::VAR_STRING,
|
||||||
|
|
|
@ -82,6 +82,7 @@ App::post('/v1/functions')
|
||||||
'enabled' => $enabled,
|
'enabled' => $enabled,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'runtime' => $runtime,
|
'runtime' => $runtime,
|
||||||
|
'deploymentInternalId' => '',
|
||||||
'deployment' => '',
|
'deployment' => '',
|
||||||
'events' => $events,
|
'events' => $events,
|
||||||
'schedule' => $schedule,
|
'schedule' => $schedule,
|
||||||
|
@ -104,6 +105,7 @@ App::post('/v1/functions')
|
||||||
);
|
);
|
||||||
|
|
||||||
$function->setAttribute('scheduleId', $schedule->getId());
|
$function->setAttribute('scheduleId', $schedule->getId());
|
||||||
|
$function->setAttribute('scheduleInternalId', $schedule->getInternalId());
|
||||||
$dbForProject->updateDocument('functions', $function->getId(), $function);
|
$dbForProject->updateDocument('functions', $function->getId(), $function);
|
||||||
|
|
||||||
$eventsInstance->setParam('functionId', $function->getId());
|
$eventsInstance->setParam('functionId', $function->getId());
|
||||||
|
@ -536,6 +538,7 @@ App::patch('/v1/functions/:functionId/deployments/:deploymentId')
|
||||||
}
|
}
|
||||||
|
|
||||||
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
||||||
|
'deploymentInternalId' => $deployment->getInternalId(),
|
||||||
'deployment' => $deployment->getId()
|
'deployment' => $deployment->getId()
|
||||||
])));
|
])));
|
||||||
|
|
||||||
|
@ -742,6 +745,7 @@ App::post('/v1/functions/:functionId/deployments')
|
||||||
Permission::update(Role::any()),
|
Permission::update(Role::any()),
|
||||||
Permission::delete(Role::any()),
|
Permission::delete(Role::any()),
|
||||||
],
|
],
|
||||||
|
'resourceInternalId' => $function->getInternalId(),
|
||||||
'resourceId' => $function->getId(),
|
'resourceId' => $function->getId(),
|
||||||
'resourceType' => 'functions',
|
'resourceType' => 'functions',
|
||||||
'entrypoint' => $entrypoint,
|
'entrypoint' => $entrypoint,
|
||||||
|
@ -772,6 +776,7 @@ App::post('/v1/functions/:functionId/deployments')
|
||||||
Permission::update(Role::any()),
|
Permission::update(Role::any()),
|
||||||
Permission::delete(Role::any()),
|
Permission::delete(Role::any()),
|
||||||
],
|
],
|
||||||
|
'resourceInternalId' => $function->getInternalId(),
|
||||||
'resourceId' => $function->getId(),
|
'resourceId' => $function->getId(),
|
||||||
'resourceType' => 'functions',
|
'resourceType' => 'functions',
|
||||||
'entrypoint' => $entrypoint,
|
'entrypoint' => $entrypoint,
|
||||||
|
@ -969,6 +974,7 @@ App::delete('/v1/functions/:functionId/deployments/:deploymentId')
|
||||||
if ($function->getAttribute('deployment') === $deployment->getId()) { // Reset function deployment
|
if ($function->getAttribute('deployment') === $deployment->getId()) { // Reset function deployment
|
||||||
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
$function = $dbForProject->updateDocument('functions', $function->getId(), new Document(array_merge($function->getArrayCopy(), [
|
||||||
'deployment' => '',
|
'deployment' => '',
|
||||||
|
'deploymentInternalId' => '',
|
||||||
])));
|
])));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,7 +1127,9 @@ App::post('/v1/functions/:functionId/executions')
|
||||||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', new Document([
|
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', new Document([
|
||||||
'$id' => $executionId,
|
'$id' => $executionId,
|
||||||
'$permissions' => !$user->isEmpty() ? [Permission::read(Role::user($user->getId()))] : [],
|
'$permissions' => !$user->isEmpty() ? [Permission::read(Role::user($user->getId()))] : [],
|
||||||
|
'functionInternalId' => $function->getInternalId(),
|
||||||
'functionId' => $function->getId(),
|
'functionId' => $function->getId(),
|
||||||
|
'deploymentInternalId' => $deployment->getInternalId(),
|
||||||
'deploymentId' => $deployment->getId(),
|
'deploymentId' => $deployment->getId(),
|
||||||
'trigger' => 'http', // http / schedule / event
|
'trigger' => 'http', // http / schedule / event
|
||||||
'status' => $async ? 'waiting' : 'processing', // waiting / processing / completed / failed
|
'status' => $async ? 'waiting' : 'processing', // waiting / processing / completed / failed
|
||||||
|
|
|
@ -97,6 +97,7 @@ class BuildsV1 extends Worker
|
||||||
'$id' => $buildId,
|
'$id' => $buildId,
|
||||||
'$permissions' => [],
|
'$permissions' => [],
|
||||||
'startTime' => $startTime,
|
'startTime' => $startTime,
|
||||||
|
'deploymentInternalId' => $deployment->getInternalId(),
|
||||||
'deploymentId' => $deployment->getId(),
|
'deploymentId' => $deployment->getId(),
|
||||||
'status' => 'processing',
|
'status' => 'processing',
|
||||||
'path' => '',
|
'path' => '',
|
||||||
|
@ -108,7 +109,8 @@ class BuildsV1 extends Worker
|
||||||
'stderr' => '',
|
'stderr' => '',
|
||||||
'duration' => 0
|
'duration' => 0
|
||||||
]));
|
]));
|
||||||
$deployment->setAttribute('buildId', $buildId);
|
$deployment->setAttribute('buildId', $build->getId());
|
||||||
|
$deployment->setAttribute('buildInternalId', $build->getInternalId());
|
||||||
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
||||||
} else {
|
} else {
|
||||||
$build = $dbForProject->getDocument('builds', $buildId);
|
$build = $dbForProject->getDocument('builds', $buildId);
|
||||||
|
@ -205,6 +207,7 @@ class BuildsV1 extends Worker
|
||||||
|
|
||||||
/** Set auto deploy */
|
/** Set auto deploy */
|
||||||
if ($deployment->getAttribute('activate') === true) {
|
if ($deployment->getAttribute('activate') === true) {
|
||||||
|
$function->setAttribute('deploymentInternalId', $deployment->getInternalId());
|
||||||
$function->setAttribute('deployment', $deployment->getId());
|
$function->setAttribute('deployment', $deployment->getId());
|
||||||
$function = $dbForProject->updateDocument('functions', $function->getId(), $function);
|
$function = $dbForProject->updateDocument('functions', $function->getId(), $function);
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,7 +222,8 @@ Server::setResource('execute', function () {
|
||||||
$usage
|
$usage
|
||||||
->setParam('projectId', $project->getId())
|
->setParam('projectId', $project->getId())
|
||||||
->setParam('projectInternalId', $project->getInternalId())
|
->setParam('projectInternalId', $project->getInternalId())
|
||||||
->setParam('functionId', $function->getId()) // TODO: We should use functionInternalId in usage stats
|
->setParam('functionId', $function->getId())
|
||||||
|
->setParam('functionInternalId', $function->getInternalId())
|
||||||
->setParam('executions.{scope}.compute', 1)
|
->setParam('executions.{scope}.compute', 1)
|
||||||
->setParam('executionStatus', $execution->getAttribute('status', ''))
|
->setParam('executionStatus', $execution->getAttribute('status', ''))
|
||||||
->setParam('executionTime', $execution->getAttribute('duration'))
|
->setParam('executionTime', $execution->getAttribute('duration'))
|
||||||
|
|
14
composer.lock
generated
14
composer.lock
generated
|
@ -5287,16 +5287,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "twig/twig",
|
"name": "twig/twig",
|
||||||
"version": "v3.5.1",
|
"version": "v3.5.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/twigphp/Twig.git",
|
"url": "https://github.com/twigphp/Twig.git",
|
||||||
"reference": "a6e0510cc793912b451fd40ab983a1d28f611c15"
|
"reference": "3ffcf4b7d890770466da3b2666f82ac054e7ec72"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/twigphp/Twig/zipball/a6e0510cc793912b451fd40ab983a1d28f611c15",
|
"url": "https://api.github.com/repos/twigphp/Twig/zipball/3ffcf4b7d890770466da3b2666f82ac054e7ec72",
|
||||||
"reference": "a6e0510cc793912b451fd40ab983a1d28f611c15",
|
"reference": "3ffcf4b7d890770466da3b2666f82ac054e7ec72",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -5347,7 +5347,7 @@
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"issues": "https://github.com/twigphp/Twig/issues",
|
"issues": "https://github.com/twigphp/Twig/issues",
|
||||||
"source": "https://github.com/twigphp/Twig/tree/v3.5.1"
|
"source": "https://github.com/twigphp/Twig/tree/v3.5.0"
|
||||||
},
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
|
@ -5359,7 +5359,7 @@
|
||||||
"type": "tidelift"
|
"type": "tidelift"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2023-02-08T07:49:20+00:00"
|
"time": "2022-12-27T12:28:18+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"aliases": [],
|
"aliases": [],
|
||||||
|
@ -5388,5 +5388,5 @@
|
||||||
"platform-overrides": {
|
"platform-overrides": {
|
||||||
"php": "8.0"
|
"php": "8.0"
|
||||||
},
|
},
|
||||||
"plugin-api-version": "2.3.0"
|
"plugin-api-version": "2.2.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,12 +90,90 @@ class V17 extends Migration
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/**
|
/**
|
||||||
* Create 'size'
|
* Create 'deploymentInternalId' attribute
|
||||||
*/
|
*/
|
||||||
$this->createAttributeFromCollection($this->projectDB, $id, 'size');
|
$this->createAttributeFromCollection($this->projectDB, $id, 'deploymentInternalId');
|
||||||
$this->projectDB->deleteCachedCollection($id);
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
} catch (\Throwable $th) {
|
} catch (\Throwable $th) {
|
||||||
Console::warning("'size' from {$id}: {$th->getMessage()}");
|
Console::warning("'deploymentInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'schedules':
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'resourceInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'resourceInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'resourceInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'functions':
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'deploymentInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'deploymentInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'deploymentInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'scheduleInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'scheduleInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'scheduleInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'deployments':
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'resourceInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'resourceInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'resourceInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'buildInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'buildInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'buildInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'executions':
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'functionInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'functionInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'functionInternalId' from {$id}: {$th->getMessage()}");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* Create 'deploymentInternalId' attribute
|
||||||
|
*/
|
||||||
|
$this->createAttributeFromCollection($this->projectDB, $id, 'deploymentInternalId');
|
||||||
|
$this->projectDB->deleteCachedCollection($id);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
Console::warning("'deploymentInternalId' from {$id}: {$th->getMessage()}");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue