mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
addressing comments
This commit is contained in:
@@ -189,8 +189,8 @@ return [
|
||||
'syncs' => [
|
||||
'key' => 'edge',
|
||||
'name' => 'edge',
|
||||
'subtitle' => 'Appwrite\'s cache edges sync Endpoint',
|
||||
'description' => 'Cache edges sync Endpoint',
|
||||
'subtitle' => 'Appwrite\'s cache edge sync Endpoint',
|
||||
'description' => 'Cache edge sync Endpoint',
|
||||
'controller' => 'api/edge.php',
|
||||
'sdk' => false,
|
||||
'docs' => false,
|
||||
|
||||
+16
-15
@@ -4,6 +4,8 @@ require_once __DIR__ . '/../worker.php';
|
||||
|
||||
use Ahc\Jwt\JWT;
|
||||
use Appwrite\Utopia\Response;
|
||||
use Swoole\Runtime;
|
||||
use Swoole\Timer;
|
||||
use Utopia\App;
|
||||
use Utopia\Config\Config;
|
||||
use Utopia\Database\Database;
|
||||
@@ -102,6 +104,8 @@ $connection = new Queue\Connection\Redis(fn() => $queue);
|
||||
$adapter = new Queue\Adapter\Swoole($connection, 2, 'syncOut');
|
||||
$server = new Queue\Server($adapter);
|
||||
|
||||
|
||||
|
||||
$server->job()
|
||||
->inject('message')
|
||||
->inject('dbForConsole')
|
||||
@@ -130,23 +134,16 @@ $server->job()
|
||||
}
|
||||
|
||||
$keys[$payload['key']] = null;
|
||||
if (count($keys) >= MAX_KEY_COUNT || ($counter + SUBMITION_INTERVAL) < time()) {
|
||||
var_dump([
|
||||
'regions' => array_keys($regions),
|
||||
'time_h' => date('m/d/Y H:i:s', $counter),
|
||||
'because_time' => ($counter + SUBMITION_INTERVAL) < time(),
|
||||
'because_count' => count($keys) >= MAX_KEY_COUNT,
|
||||
'count' => count($keys),
|
||||
'counter' => $counter + SUBMITION_INTERVAL,
|
||||
'time' => time(),
|
||||
'keys' => array_keys($keys),
|
||||
]);
|
||||
call($dbForConsole, $regions, array_keys($keys));
|
||||
$counter = time();
|
||||
$keys = [];
|
||||
}
|
||||
|
||||
// if (count($keys) >= MAX_KEY_COUNT || ($counter + SUBMITION_INTERVAL) < time()) {
|
||||
// call($dbForConsole, $regions, array_keys($keys));
|
||||
// $counter = time();
|
||||
// $keys = [];
|
||||
// }
|
||||
});
|
||||
|
||||
Runtime::enableCoroutine(SWOOLE_HOOK_ALL);
|
||||
|
||||
$server
|
||||
->error()
|
||||
->inject('error')
|
||||
@@ -157,6 +154,10 @@ $server
|
||||
|
||||
$server
|
||||
->workerStart(function () {
|
||||
Timer::tick(1000, function () {
|
||||
var_dump(date('m/d/Y H:i:s', time()));
|
||||
});
|
||||
echo "Out region [" . App::getEnv('_APP_REGION', 'nyc1') . "] cache purging worker Started" . PHP_EOL;
|
||||
})
|
||||
->start();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user