docs: add comments to events passing
This commit is contained in:
parent
a470201205
commit
fdb64de616
5 changed files with 64 additions and 18 deletions
|
@ -221,6 +221,7 @@ App::shutdown(function ($utopia, $request, $response, $project, $events, $audits
|
||||||
$bucket = ($trigger && $trigger->getCollection() === 'buckets') ? $trigger : null;
|
$bucket = ($trigger && $trigger->getCollection() === 'buckets') ? $trigger : null;
|
||||||
|
|
||||||
$target = Realtime::fromPayload(
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
event: $allEvents[0],
|
event: $allEvents[0],
|
||||||
payload: $payload,
|
payload: $payload,
|
||||||
project: $project,
|
project: $project,
|
||||||
|
|
|
@ -13,7 +13,8 @@ Console::success(APP_NAME . ' audits worker v1 has started');
|
||||||
|
|
||||||
class AuditsV1 extends Worker
|
class AuditsV1 extends Worker
|
||||||
{
|
{
|
||||||
public function getName(): string {
|
public function getName(): string
|
||||||
|
{
|
||||||
return "audits";
|
return "audits";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,16 +37,23 @@ class AuditsV1 extends Worker
|
||||||
$userName = $user->getAttribute('name', '');
|
$userName = $user->getAttribute('name', '');
|
||||||
$userEmail = $user->getAttribute('email', '');
|
$userEmail = $user->getAttribute('email', '');
|
||||||
|
|
||||||
$event = $events[0];
|
|
||||||
|
|
||||||
$dbForProject = $this->getProjectDB($project->getId());
|
$dbForProject = $this->getProjectDB($project->getId());
|
||||||
$audit = new Audit($dbForProject);
|
$audit = new Audit($dbForProject);
|
||||||
$audit->log($user->getId(), $event, $resource, $userAgent, $ip, '', [
|
$audit->log(
|
||||||
|
userId: $user->getId(),
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $events[0],
|
||||||
|
resource: $resource,
|
||||||
|
userAgent: $userAgent,
|
||||||
|
ip: $ip,
|
||||||
|
location: '',
|
||||||
|
data: [
|
||||||
'userName' => $userName,
|
'userName' => $userName,
|
||||||
'userEmail' => $userEmail,
|
'userEmail' => $userEmail,
|
||||||
'mode' => $mode,
|
'mode' => $mode,
|
||||||
'data' => $payload,
|
'data' => $payload,
|
||||||
]);
|
]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function shutdown(): void
|
public function shutdown(): void
|
||||||
|
|
|
@ -31,7 +31,8 @@ class BuildsV1 extends Worker
|
||||||
return "builds";
|
return "builds";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init(): void {
|
public function init(): void
|
||||||
|
{
|
||||||
$this->executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
$this->executor = new Executor(App::getEnv('_APP_EXECUTOR_HOST'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +130,13 @@ class BuildsV1 extends Worker
|
||||||
'functionId' => $function->getId(),
|
'functionId' => $function->getId(),
|
||||||
'deploymentId' => $deployment->getId()
|
'deploymentId' => $deployment->getId()
|
||||||
]);
|
]);
|
||||||
$target = Realtime::fromPayload($allEvents[0], $build, $project);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $allEvents[0],
|
||||||
|
payload: $build,
|
||||||
|
project: $project
|
||||||
|
);
|
||||||
|
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
payload: $build->getArrayCopy(),
|
payload: $build->getArrayCopy(),
|
||||||
|
@ -196,7 +203,12 @@ class BuildsV1 extends Worker
|
||||||
/**
|
/**
|
||||||
* Send realtime Event
|
* Send realtime Event
|
||||||
*/
|
*/
|
||||||
$target = Realtime::fromPayload($allEvents[0], $build, $project);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $allEvents[0],
|
||||||
|
payload: $build,
|
||||||
|
project: $project
|
||||||
|
);
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
payload: $build->getArrayCopy(),
|
payload: $build->getArrayCopy(),
|
||||||
|
|
|
@ -102,7 +102,12 @@ class DatabaseV1 extends Worker
|
||||||
Console::error($th->getMessage());
|
Console::error($th->getMessage());
|
||||||
$dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'failed'));
|
$dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'failed'));
|
||||||
} finally {
|
} finally {
|
||||||
$target = Realtime::fromPayload($events[0], $attribute, $project);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $events[0],
|
||||||
|
payload: $attribute,
|
||||||
|
project: $project
|
||||||
|
);
|
||||||
|
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
|
@ -154,7 +159,12 @@ class DatabaseV1 extends Worker
|
||||||
Console::error($th->getMessage());
|
Console::error($th->getMessage());
|
||||||
$dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'stuck'));
|
$dbForProject->updateDocument('attributes', $attribute->getId(), $attribute->setAttribute('status', 'stuck'));
|
||||||
} finally {
|
} finally {
|
||||||
$target = Realtime::fromPayload($events[0], $attribute, $project);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $events[0],
|
||||||
|
payload: $attribute,
|
||||||
|
project: $project
|
||||||
|
);
|
||||||
|
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
|
@ -255,7 +265,12 @@ class DatabaseV1 extends Worker
|
||||||
Console::error($th->getMessage());
|
Console::error($th->getMessage());
|
||||||
$dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'failed'));
|
$dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'failed'));
|
||||||
} finally {
|
} finally {
|
||||||
$target = Realtime::fromPayload($events[0], $index, $project);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $events[0],
|
||||||
|
payload: $index,
|
||||||
|
project: $project
|
||||||
|
);
|
||||||
|
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
|
@ -300,7 +315,12 @@ class DatabaseV1 extends Worker
|
||||||
Console::error($th->getMessage());
|
Console::error($th->getMessage());
|
||||||
$dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'stuck'));
|
$dbForProject->updateDocument('indexes', $index->getId(), $index->setAttribute('status', 'stuck'));
|
||||||
} finally {
|
} finally {
|
||||||
$target = Realtime::fromPayload($events[0], $index, $project);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $events[0],
|
||||||
|
payload: $index,
|
||||||
|
project: $project
|
||||||
|
);
|
||||||
|
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
|
|
|
@ -75,6 +75,7 @@ class FunctionsV1 extends Worker
|
||||||
function: $function,
|
function: $function,
|
||||||
dbForProject: $database,
|
dbForProject: $database,
|
||||||
trigger: 'event',
|
trigger: 'event',
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
event: $events[0],
|
event: $events[0],
|
||||||
eventData: $payload,
|
eventData: $payload,
|
||||||
user: $user
|
user: $user
|
||||||
|
@ -329,7 +330,11 @@ class FunctionsV1 extends Worker
|
||||||
'functionId' => $function->getId(),
|
'functionId' => $function->getId(),
|
||||||
'executionId' => $execution->getId()
|
'executionId' => $execution->getId()
|
||||||
]);
|
]);
|
||||||
$target = Realtime::fromPayload($allEvents[0], $execution);
|
$target = Realtime::fromPayload(
|
||||||
|
// Pass first, most verbose event pattern
|
||||||
|
event: $allEvents[0],
|
||||||
|
payload: $execution
|
||||||
|
);
|
||||||
Realtime::send(
|
Realtime::send(
|
||||||
projectId: 'console',
|
projectId: 'console',
|
||||||
payload: $execution->getArrayCopy(),
|
payload: $execution->getArrayCopy(),
|
||||||
|
|
Loading…
Reference in a new issue