1
0
Fork 0
mirror of synced 2024-06-27 18:50:47 +12:00

fix(realtime): disable sending realtime stats

Disable sending realtime stats because the $database->find('realtime')
is throwing:

> Cannot execute queries while other unbuffered queries are active.

In addition, the realtime stats are not being collected so there's no
point in having this enabled.
This commit is contained in:
Steven Nguyen 2024-05-08 21:37:46 +00:00 committed by GitHub
parent 8562823b07
commit fa78ae078f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -268,54 +268,54 @@ $server->onWorkerStart(function (int $workerId) use ($server, $register, $stats,
/**
* Sending current connections to project channels on the console project every 5 seconds.
*/
if ($realtime->hasSubscriber('console', Role::users()->toString(), 'project')) {
$database = getConsoleDB();
// if ($realtime->hasSubscriber('console', Role::users()->toString(), 'project')) {
// $database = getConsoleDB();
$payload = [];
// $payload = [];
$list = Authorization::skip(fn () => $database->find('realtime', [
Query::greaterThan('timestamp', DateTime::addSeconds(new \DateTime(), -15)),
]));
// $list = Authorization::skip(fn () => $database->find('realtime', [
// Query::greaterThan('timestamp', DateTime::addSeconds(new \DateTime(), -15)),
// ]));
/**
* Aggregate stats across containers.
*/
foreach ($list as $document) {
foreach (json_decode($document->getAttribute('value')) as $projectId => $value) {
if (array_key_exists($projectId, $payload)) {
$payload[$projectId] += $value;
} else {
$payload[$projectId] = $value;
}
}
}
// /**
// * Aggregate stats across containers.
// */
// foreach ($list as $document) {
// foreach (json_decode($document->getAttribute('value')) as $projectId => $value) {
// if (array_key_exists($projectId, $payload)) {
// $payload[$projectId] += $value;
// } else {
// $payload[$projectId] = $value;
// }
// }
// }
foreach ($stats as $projectId => $value) {
if (!array_key_exists($projectId, $payload)) {
continue;
}
// foreach ($stats as $projectId => $value) {
// if (!array_key_exists($projectId, $payload)) {
// continue;
// }
$event = [
'project' => 'console',
'roles' => ['team:' . $stats->get($projectId, 'teamId')],
'data' => [
'events' => ['stats.connections'],
'channels' => ['project'],
'timestamp' => DateTime::formatTz(DateTime::now()),
'payload' => [
$projectId => $payload[$projectId]
]
]
];
// $event = [
// 'project' => 'console',
// 'roles' => ['team:' . $stats->get($projectId, 'teamId')],
// 'data' => [
// 'events' => ['stats.connections'],
// 'channels' => ['project'],
// 'timestamp' => DateTime::formatTz(DateTime::now()),
// 'payload' => [
// $projectId => $payload[$projectId]
// ]
// ]
// ];
$server->send($realtime->getSubscribers($event), json_encode([
'type' => 'event',
'data' => $event['data']
]));
}
// $server->send($realtime->getSubscribers($event), json_encode([
// 'type' => 'event',
// 'data' => $event['data']
// ]));
// }
$register->get('pools')->reclaim();
}
// $register->get('pools')->reclaim();
// }
/**
* Sending test message for SDK E2E tests every 5 seconds.
*/