mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
tidy up
This commit is contained in:
@@ -50,7 +50,7 @@ function call(string $url, string $token, array $data): int
|
||||
. json_encode($keys) . $eol;
|
||||
}
|
||||
$payload .= "--" . $delimiter . "--" . $eol;
|
||||
var_dump($payload);
|
||||
|
||||
$status = 404;
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
||||
@@ -95,7 +95,6 @@ function handle($dbForConsole, $regions, $data): void
|
||||
$token = $jwt->encode([]);
|
||||
|
||||
foreach ($regions as $code => $region) {
|
||||
var_dump($region);
|
||||
$time = DateTime::now();
|
||||
$status = call($region['domain'] . '/v1/edge/sync', $token, $data);
|
||||
if ($status !== Response::STATUS_CODE_OK) {
|
||||
|
||||
@@ -46,14 +46,14 @@ class EdgeSync extends Action
|
||||
Console::success("[{$time}] New task every {$interval} seconds");
|
||||
|
||||
foreach ($regions as $code => $region) {
|
||||
$count = 0;
|
||||
$chunk = 0;
|
||||
$limit = 500;
|
||||
$sum = $limit;
|
||||
$keys = [];
|
||||
$found = false;
|
||||
while ($sum === $limit) {
|
||||
$chunk++;
|
||||
|
||||
$count = 0;
|
||||
$results = $dbForConsole->find('syncs', [
|
||||
Query::equal('region', [App::getEnv('_APP_REGION')]),
|
||||
Query::equal('target', [$code]),
|
||||
@@ -62,6 +62,7 @@ class EdgeSync extends Action
|
||||
|
||||
$sum = count($results);
|
||||
if ($sum > 0) {
|
||||
$found = true;
|
||||
foreach ($results as $document) {
|
||||
$key = $document->getAttribute('key');
|
||||
$keys[] = [
|
||||
@@ -72,17 +73,18 @@ class EdgeSync extends Action
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($keys)) {
|
||||
Console::info("[{$time}] Enqueueing keys chunk {$count} to region {$code}");
|
||||
$queueForEdgeSyncOut
|
||||
->enqueue([
|
||||
'region' => $code,
|
||||
'keys' => $keys
|
||||
]);
|
||||
} else {
|
||||
Console::info("[{$time}] No keys where found for region {$code}.");
|
||||
if (!empty($keys)) {
|
||||
Console::info("[{$time}] Enqueueing chunk {$chunk}, {$count} keys to region {$code}");
|
||||
$queueForEdgeSyncOut
|
||||
->enqueue([
|
||||
'region' => $code,
|
||||
'keys' => $keys
|
||||
]);
|
||||
}
|
||||
}
|
||||
if (!$found) {
|
||||
Console::info("[{$time}] No keys where found for region {$code}.");
|
||||
}
|
||||
}
|
||||
}, $interval);
|
||||
|
||||
Reference in New Issue
Block a user