add internalId to collections
This commit is contained in:
parent
20f9b0c655
commit
b89e04f561
5 changed files with 69 additions and 10 deletions
|
@ -61,7 +61,6 @@ $collections = [
|
|||
],
|
||||
],
|
||||
],
|
||||
|
||||
'collections' => [
|
||||
'$collection' => ID::custom('databases'),
|
||||
'$id' => ID::custom('collections'),
|
||||
|
@ -2371,6 +2370,17 @@ $collections = [
|
|||
'$id' => ID::custom('deployments'),
|
||||
'name' => 'Deployments',
|
||||
'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'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -2393,6 +2403,17 @@ $collections = [
|
|||
'array' => false,
|
||||
'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'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -2573,6 +2594,17 @@ $collections = [
|
|||
'array' => false,
|
||||
'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'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -2689,6 +2721,17 @@ $collections = [
|
|||
'$id' => ID::custom('executions'),
|
||||
'name' => 'Executions',
|
||||
'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'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -2700,6 +2743,17 @@ $collections = [
|
|||
'array' => false,
|
||||
'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'),
|
||||
'type' => Database::VAR_STRING,
|
||||
|
@ -3318,7 +3372,6 @@ $collections = [
|
|||
],
|
||||
],
|
||||
],
|
||||
|
||||
'files' => [
|
||||
'$collection' => ID::custom('buckets'),
|
||||
'$id' => ID::custom('files'),
|
||||
|
|
|
@ -526,6 +526,7 @@ App::post('/v1/functions/:functionId/deployments')
|
|||
Permission::update(Role::any()),
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
'resourceInternalId' => $function->getInternalId(),
|
||||
'resourceId' => $function->getId(),
|
||||
'resourceType' => 'functions',
|
||||
'entrypoint' => $entrypoint,
|
||||
|
@ -556,6 +557,7 @@ App::post('/v1/functions/:functionId/deployments')
|
|||
Permission::update(Role::any()),
|
||||
Permission::delete(Role::any()),
|
||||
],
|
||||
'resourceInternalId' => $function->getInternalId(),
|
||||
'resourceId' => $function->getId(),
|
||||
'resourceType' => 'functions',
|
||||
'entrypoint' => $entrypoint,
|
||||
|
@ -902,7 +904,9 @@ App::post('/v1/functions/:functionId/executions')
|
|||
$execution = Authorization::skip(fn () => $dbForProject->createDocument('executions', new Document([
|
||||
'$id' => $executionId,
|
||||
'$permissions' => !$user->isEmpty() ? [Permission::read(Role::user($user->getId()))] : [],
|
||||
'functionInternalId' => $function->getInternalId(),
|
||||
'functionId' => $function->getId(),
|
||||
'deploymentInternalId' => $deployment->getInternalId(),
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'trigger' => 'http', // http / schedule / event
|
||||
'status' => $async ? 'waiting' : 'processing', // waiting / processing / completed / failed
|
||||
|
|
|
@ -194,14 +194,14 @@ $databaseListener = function (string $event, Document $document, Document $proje
|
|||
$queueForUsage
|
||||
->addMetric("deployments", $value) // per project
|
||||
->addMetric("deployments.storage", $document->getAttribute('size') * $value) // per project
|
||||
->addMetric("{$document->getAttribute('resourceType')}" . "." . "{$document->getAttribute('resourceId')}" . ".deployments", $value)// per function
|
||||
->addMetric("{$document->getAttribute('resourceType')}" . "." . "{$document->getAttribute('resourceId')}" . ".deployments.storage", $document->getAttribute('size') * $value) // per function
|
||||
->addMetric("{$document->getAttribute('resourceType')}" . "." . "{$document->getAttribute('resourceInternalId')}" . ".deployments", $value)// per function
|
||||
->addMetric("{$document->getAttribute('resourceType')}" . "." . "{$document->getAttribute('resourceInternalId')}" . ".deployments.storage", $document->getAttribute('size') * $value) // per function
|
||||
;
|
||||
break;
|
||||
case $document->getCollection() === 'executions':
|
||||
$queueForUsage
|
||||
->addMetric("executions", $value) // per project
|
||||
->addMetric("{$document->getAttribute('functionId')}" . ".executions", $value) // per function
|
||||
->addMetric("{$document->getAttribute('functionInternalId')}" . ".executions", $value) // per function
|
||||
;
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -96,6 +96,7 @@ class BuildsV1 extends Worker
|
|||
'$id' => $buildId,
|
||||
'$permissions' => [],
|
||||
'startTime' => $startTime,
|
||||
'deploymentInternalId' => $deployment->getInternalId(),
|
||||
'deploymentId' => $deployment->getId(),
|
||||
'status' => 'processing',
|
||||
'path' => '',
|
||||
|
@ -107,7 +108,8 @@ class BuildsV1 extends Worker
|
|||
'stderr' => '',
|
||||
'duration' => 0
|
||||
]));
|
||||
$deployment->setAttribute('buildId', $buildId);
|
||||
$deployment->setAttribute('buildId', $build->getId());
|
||||
$deployment->setAttribute('buildInternalId', $build->getInternalId());
|
||||
$deployment = $dbForProject->updateDocument('deployments', $deployment->getId(), $deployment);
|
||||
} else {
|
||||
$build = $dbForProject->getDocument('builds', $buildId);
|
||||
|
@ -254,9 +256,9 @@ class BuildsV1 extends Worker
|
|||
->addMetric("builds", 1) // per project
|
||||
->addMetric("builds.storage", $build->getAttribute('size', 0))
|
||||
->addMetric("builds.compute", $build->getAttribute('duration', 0))
|
||||
->addMetric("{$function->getId()}" . ".builds", 1) // per function
|
||||
->addMetric("{$function->getId()}" . ".builds.storage", $build->getAttribute('size', 0))
|
||||
->addMetric("{$function->getId()}" . ".builds.compute", $build->getAttribute('duration', 0))
|
||||
->addMetric("{$function->getInternalId()}" . ".builds", 1) // per function
|
||||
->addMetric("{$function->getInternalId()}" . ".builds.storage", $build->getAttribute('size', 0))
|
||||
->addMetric("{$function->getInternalId()}" . ".builds.compute", $build->getAttribute('duration', 0))
|
||||
->trigger()
|
||||
;
|
||||
}
|
||||
|
|
|
@ -215,7 +215,7 @@ Server::setResource('execute', function () {
|
|||
$queueForUsage
|
||||
->setProject($project)
|
||||
->addMetric('executions.compute', (int)($execution->getAttribute('duration') * 1000))// per project
|
||||
->addMetric("{$function->getId()}" . ".executions.compute", (int)($execution->getAttribute('duration') * 1000))// per function
|
||||
->addMetric("{$function->getInternalId()}" . ".executions.compute", (int)($execution->getAttribute('duration') * 1000))// per function
|
||||
->trigger()
|
||||
;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue