Merge pull request #8104 from appwrite/fix-unreliable-realtime-workaround
Disable sending realtime stats
This commit is contained in:
commit
6b31f1323d
|
@ -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.
|
* Sending current connections to project channels on the console project every 5 seconds.
|
||||||
*/
|
*/
|
||||||
if ($realtime->hasSubscriber('console', Role::users()->toString(), 'project')) {
|
// if ($realtime->hasSubscriber('console', Role::users()->toString(), 'project')) {
|
||||||
$database = getConsoleDB();
|
// $database = getConsoleDB();
|
||||||
|
|
||||||
$payload = [];
|
// $payload = [];
|
||||||
|
|
||||||
$list = Authorization::skip(fn () => $database->find('realtime', [
|
// $list = Authorization::skip(fn () => $database->find('realtime', [
|
||||||
Query::greaterThan('timestamp', DateTime::addSeconds(new \DateTime(), -15)),
|
// Query::greaterThan('timestamp', DateTime::addSeconds(new \DateTime(), -15)),
|
||||||
]));
|
// ]));
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* Aggregate stats across containers.
|
// * Aggregate stats across containers.
|
||||||
*/
|
// */
|
||||||
foreach ($list as $document) {
|
// foreach ($list as $document) {
|
||||||
foreach (json_decode($document->getAttribute('value')) as $projectId => $value) {
|
// foreach (json_decode($document->getAttribute('value')) as $projectId => $value) {
|
||||||
if (array_key_exists($projectId, $payload)) {
|
// if (array_key_exists($projectId, $payload)) {
|
||||||
$payload[$projectId] += $value;
|
// $payload[$projectId] += $value;
|
||||||
} else {
|
// } else {
|
||||||
$payload[$projectId] = $value;
|
// $payload[$projectId] = $value;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
foreach ($stats as $projectId => $value) {
|
// foreach ($stats as $projectId => $value) {
|
||||||
if (!array_key_exists($projectId, $payload)) {
|
// if (!array_key_exists($projectId, $payload)) {
|
||||||
continue;
|
// continue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$event = [
|
// $event = [
|
||||||
'project' => 'console',
|
// 'project' => 'console',
|
||||||
'roles' => ['team:' . $stats->get($projectId, 'teamId')],
|
// 'roles' => ['team:' . $stats->get($projectId, 'teamId')],
|
||||||
'data' => [
|
// 'data' => [
|
||||||
'events' => ['stats.connections'],
|
// 'events' => ['stats.connections'],
|
||||||
'channels' => ['project'],
|
// 'channels' => ['project'],
|
||||||
'timestamp' => DateTime::formatTz(DateTime::now()),
|
// 'timestamp' => DateTime::formatTz(DateTime::now()),
|
||||||
'payload' => [
|
// 'payload' => [
|
||||||
$projectId => $payload[$projectId]
|
// $projectId => $payload[$projectId]
|
||||||
]
|
// ]
|
||||||
]
|
// ]
|
||||||
];
|
// ];
|
||||||
|
|
||||||
$server->send($realtime->getSubscribers($event), json_encode([
|
// $server->send($realtime->getSubscribers($event), json_encode([
|
||||||
'type' => 'event',
|
// 'type' => 'event',
|
||||||
'data' => $event['data']
|
// 'data' => $event['data']
|
||||||
]));
|
// ]));
|
||||||
}
|
// }
|
||||||
|
|
||||||
$register->get('pools')->reclaim();
|
// $register->get('pools')->reclaim();
|
||||||
}
|
// }
|
||||||
/**
|
/**
|
||||||
* Sending test message for SDK E2E tests every 5 seconds.
|
* Sending test message for SDK E2E tests every 5 seconds.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue