diff --git a/Dockerfile b/Dockerfile index a3bb4769db..bc3c4db044 100755 --- a/Dockerfile +++ b/Dockerfile @@ -29,7 +29,8 @@ RUN \ git \ zlib-dev \ brotli-dev \ - libmaxminddb-dev + libmaxminddb-dev \ + openssl-dev RUN docker-php-ext-install sockets @@ -47,7 +48,7 @@ RUN \ cd swoole-src && \ git checkout $PHP_SWOOLE_VERSION && \ phpize && \ - ./configure --enable-sockets --enable-http2 && \ + ./configure --enable-sockets --enable-http2 --enable-openssl && \ make && make install && \ cd .. && \ ## Maxminddb extension diff --git a/app/http.php b/app/http.php index 9e45bc3b52..d00bbc09eb 100644 --- a/app/http.php +++ b/app/http.php @@ -15,11 +15,23 @@ use Utopia\CLI\Console; // xdebug_start_trace('/tmp/trace'); -ini_set('memory_limit','512M'); -ini_set('display_errors', 1); -ini_set('display_startup_errors', 1); -ini_set('default_socket_timeout', -1); -error_reporting(E_ALL); +Files::load(__DIR__ . '/../public'); + +include __DIR__ . '/controllers/general.php'; + +$domain = App::getEnv('_APP_DOMAIN', ''); + +Console::info('Issuing a TLS certificate for the master domain ('.$domain.') in 30 seconds. + Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script + +ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ + 'document' => [], + 'domain' => $domain, + 'validateTarget' => false, + 'validateCNAME' => false, +]); + +Swoole\Runtime::enableCoroutine(SWOOLE_HOOK_ALL); $http = new Server("0.0.0.0", App::getEnv('PORT', 80)); @@ -61,22 +73,6 @@ $http->on('start', function (Server $http) use ($payloadSize) { }); }); -Files::load(__DIR__ . '/../public'); - -include __DIR__ . '/controllers/general.php'; - -$domain = App::getEnv('_APP_DOMAIN', ''); - -Console::info('Issuing a TLS certificate for the master domain ('.$domain.') in 30 seconds. - Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script - -ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [ - 'document' => [], - 'domain' => $domain, - 'validateTarget' => false, - 'validateCNAME' => false, -]); - $http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) { $request = new Request($swooleRequest); $response = new Response($swooleResponse); diff --git a/app/init.php b/app/init.php index 98ff4c9235..20a711e7af 100644 --- a/app/init.php +++ b/app/init.php @@ -11,6 +11,12 @@ if (\file_exists(__DIR__.'/../vendor/autoload.php')) { require_once __DIR__.'/../vendor/autoload.php'; } +ini_set('memory_limit','512M'); +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +ini_set('default_socket_timeout', -1); +error_reporting(E_ALL); + use Ahc\Jwt\JWT; use Ahc\Jwt\JWTException; use Appwrite\Auth\Auth; @@ -21,7 +27,6 @@ use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; use Appwrite\Event\Realtime; -use Appwrite\Extend\PDO; use Appwrite\OpenSSL\OpenSSL; use Utopia\App; use Utopia\View; @@ -31,6 +36,10 @@ use Utopia\Registry\Registry; use MaxMind\Db\Reader; use PHPMailer\PHPMailer\PHPMailer; use PDO as PDONative; +use Swoole\Database\PDOConfig; +use Swoole\Database\PDOPool; +use Swoole\Database\RedisConfig; +use Swoole\Database\RedisPool; const APP_NAME = 'Appwrite'; const APP_DOMAIN = 'appwrite.io'; @@ -139,7 +148,28 @@ Database::addFilter('encrypt', /* * Registry */ -$register->set('db', function () { // Register DB connection +$register->set('dbPool', function () { // Register DB connection + $config = new PDOConfig(); + $config + ->withHost(App::getEnv('_APP_DB_HOST', '')) + ->withPort(App::getEnv('_APP_DB_PORT', '')) + ->withDbName(App::getEnv('_APP_DB_SCHEMA', '')) + ->withUsername(App::getEnv('_APP_DB_USER', '')) + ->withPassword(App::getEnv('_APP_DB_PASS', '')) + ->withCharset('utf8mb4') + ->withOptions([ + PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', + PDONative::ATTR_TIMEOUT => 3, // Seconds + PDONative::ATTR_PERSISTENT => true, + PDONative::ATTR_DEFAULT_FETCH_MODE => PDONative::FETCH_ASSOC, + PDONative::ATTR_ERRMODE => PDONative::ERRMODE_EXCEPTION, + ]); + + $pool = new PDOPool($config); + + return $pool; +}); +$register->set('db', function () use ($register) { $dbHost = App::getEnv('_APP_DB_HOST', ''); $dbUser = App::getEnv('_APP_DB_USER', ''); $dbPass = App::getEnv('_APP_DB_PASS', ''); @@ -148,13 +178,11 @@ $register->set('db', function () { // Register DB connection $pdo = new PDO("mysql:host={$dbHost};dbname={$dbScheme};charset=utf8mb4", $dbUser, $dbPass, array( PDONative::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4', PDONative::ATTR_TIMEOUT => 3, // Seconds - PDONative::ATTR_PERSISTENT => true + PDONative::ATTR_PERSISTENT => true, + PDONative::ATTR_DEFAULT_FETCH_MODE => PDONative::FETCH_ASSOC, + PDONative::ATTR_ERRMODE => PDONative::ERRMODE_EXCEPTION, )); - // Connection settings - $pdo->setAttribute(PDONative::ATTR_DEFAULT_FETCH_MODE, PDONative::FETCH_ASSOC); // Return arrays - $pdo->setAttribute(PDONative::ATTR_ERRMODE, PDONative::ERRMODE_EXCEPTION); // Handle all errors with exceptions - return $pdo; }); $register->set('influxdb', function () { // Register DB connection @@ -178,21 +206,33 @@ $register->set('statsd', function () { // Register DB connection return $statsd; }); +$register->set('redisPool', function () { + $user = App::getEnv('_APP_REDIS_USER', ''); + $pass = App::getEnv('_APP_REDIS_PASS', ''); + $auth = ''; + if (!empty($user)) { + $auth += $user; + } + if (!empty($pass)) { + $auth += ':' . $pass; + } + + $config = new RedisConfig(); + $config + ->withHost(App::getEnv('_APP_REDIS_HOST', '')) + ->withPort(App::getEnv('_APP_REDIS_PORT', '')) + ->withAuth($auth) + ->withTimeout(0) + ->withReadTimeout(0) + ->withRetryInterval(0); + + $pool = new RedisPool($config); + + return $pool; +}); $register->set('cache', function () { // Register cache connection $redis = new Redis(); $redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''), App::getEnv('_APP_REDIS_PORT', '')); - $user = App::getEnv('_APP_REDIS_USER',''); - $pass = App::getEnv('_APP_REDIS_PASS',''); - $auth = []; - if(!empty($user)) { - $auth["user"] = $user; - } - if(!empty($pass)) { - $auth["pass"] = $pass; - } - if(!empty($auth)) { - $redis->auth($auth); - } $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); return $redis; diff --git a/app/realtime.php b/app/realtime.php index 55634c5067..c7674b1abb 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -1,16 +1,15 @@ set('db', function () use ($register) { + $pool = $register->get('dbPool'); + $pdo = $pool->get()->__getObject(); + + return $pdo; +}, true); + +$register->set('cache', function () use ($register) { // Register cache connection + $redis = $register->get('redisPool')->get(); + $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); + + return $redis; +}, true); + $server = new Server('0.0.0.0', 80); $server->set([ @@ -39,13 +51,11 @@ $subscriptions = []; $connections = []; $server->on('workerStart', function ($server, $workerId) use (&$subscriptions, &$connections, &$register) { - Console::success('Worker ' . ++$workerId . ' started succefully'); - + Console::success('Worker ' . $workerId . ' started succefully'); + $attempts = 0; $start = time(); - // $register->context('realtime-' . $workerId); - while ($attempts < 300) { try { if ($attempts > 0) { @@ -54,8 +64,7 @@ $server->on('workerStart', function ($server, $workerId) use (&$subscriptions, & sleep(5); // 5 sec delay between connection attempts } - $redis = $register->get('cache', true); - $redis->setOption(Redis::OPT_READ_TIMEOUT, -1); + $redis = $register->get('cache'); if ($redis->ping(true)) { $attempts = 0; diff --git a/app/workers/audits.php b/app/workers/audits.php index d6027dd2e3..13af7e828e 100644 --- a/app/workers/audits.php +++ b/app/workers/audits.php @@ -1,5 +1,6 @@ log($userId, $event, $resource, $userAgent, $ip, '', $data); } - public function tearDown(): void + public function shutdown(): void { // ... Remove environment for this job } diff --git a/app/workers/certificates.php b/app/workers/certificates.php index e8693e3566..6d08d2183d 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -9,6 +9,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Validator\Authorization; use Appwrite\Network\Validator\CNAME; +use Appwrite\Resque\Worker; require_once __DIR__.'/../init.php'; @@ -16,15 +17,15 @@ Console::title('Certificates V1 Worker'); Console::success(APP_NAME.' certificates worker v1 has started'); -class CertificatesV1 +class CertificatesV1 extends Worker { public $args = []; - public function setUp(): void + public function init(): void { } - public function perform() + public function execute(): void { global $register; @@ -204,8 +205,7 @@ class CertificatesV1 Authorization::reset(); } - public function tearDown(): void + public function shutdown(): void { - // ... Remove environment for this job } } diff --git a/app/workers/deletes.php b/app/workers/deletes.php index 426dcf1ed6..0478f7661a 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -5,6 +5,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Document; use Appwrite\Database\Validator\Authorization; +use Appwrite\Resque\Worker; use Utopia\Storage\Device\Local; use Utopia\Abuse\Abuse; use Utopia\Abuse\Adapters\TimeLimit; @@ -19,18 +20,17 @@ Console::title('Deletes V1 Worker'); Console::success(APP_NAME.' deletes worker v1 has started'."\n"); -class DeletesV1 +class DeletesV1 extends Worker { - public $args = []; protected $consoleDB = null; - public function setUp(): void + public function init(): void { } - public function perform() + public function execute(): void { $projectId = $this->args['projectId']; $type = $this->args['type']; @@ -82,9 +82,8 @@ class DeletesV1 } } - public function tearDown(): void + public function shutdown(): void { - // ... Remove environment for this job } protected function deleteDocuments(Document $document, $projectId) diff --git a/app/workers/functions.php b/app/workers/functions.php index 87e3a86245..707e6960fe 100644 --- a/app/workers/functions.php +++ b/app/workers/functions.php @@ -6,6 +6,7 @@ use Appwrite\Database\Adapter\MySQL as MySQLAdapter; use Appwrite\Database\Adapter\Redis as RedisAdapter; use Appwrite\Database\Validator\Authorization; use Appwrite\Event\Event; +use Appwrite\Resque\Worker; use Cron\CronExpression; use Swoole\Runtime; use Utopia\App; @@ -127,17 +128,17 @@ Console::info(count($list)." functions listed in " . ($executionEnd - $execution //TODO aviod scheduled execution if delay is bigger than X offest -class FunctionsV1 +class FunctionsV1 extends Worker { public $args = []; public $allowed = []; - public function setUp(): void + public function init(): void { } - public function perform() + public function execute(): void { global $register; @@ -195,7 +196,7 @@ class FunctionsV1 Console::success('Triggered function: '.$event); - $this->execute('event', $projectId, '', $database, $function, $event, $payload); + $this->run('event', $projectId, '', $database, $function, $event, $payload); } } break; @@ -251,7 +252,7 @@ class FunctionsV1 'scheduleOriginal' => $function->getAttribute('schedule', ''), ]); // Async task rescheduale - $this->execute($trigger, $projectId, $executionId, $database, $function); + $this->run($trigger, $projectId, $executionId, $database, $function); break; @@ -264,7 +265,7 @@ class FunctionsV1 throw new Exception('Function not found ('.$functionId.')'); } - $this->execute($trigger, $projectId, $executionId, $database, $function); + $this->run($trigger, $projectId, $executionId, $database, $function); break; default: @@ -286,7 +287,7 @@ class FunctionsV1 * * @return void */ - public function execute(string $trigger, string $projectId, string $executionId, Database $database, Document $function, string $event = '', string $payload = ''): void + public function run(string $trigger, string $projectId, string $executionId, Database $database, Document $function, string $event = '', string $payload = ''): void { global $list; @@ -548,7 +549,7 @@ class FunctionsV1 return $output; } - public function tearDown(): void + public function shutdown(): void { } } diff --git a/app/workers/mails.php b/app/workers/mails.php index 6f4422b57f..50e499f901 100644 --- a/app/workers/mails.php +++ b/app/workers/mails.php @@ -1,5 +1,6 @@ getAttribute('updated') !== $updated) { // Task have already been rescheduled by owner - return false; + return; } if ($task->getAttribute('status') !== 'play') { // Skip task and don't schedule again - return false; + return; } // Reschedule @@ -202,11 +203,10 @@ class TasksV1 // Send alert if needed (use SMTP as default for now) - return true; + return; } - public function tearDown(): void + public function shutdown(): void { - // ... Remove environment for this job } } diff --git a/app/workers/usage.php b/app/workers/usage.php index c83ae7ae30..1d1a5ba5a7 100644 --- a/app/workers/usage.php +++ b/app/workers/usage.php @@ -1,5 +1,6 @@ =7.3" + "php": ">=7.4" }, "require-dev": { "phpunit/phpunit": "^9.3", "vimeo/psalm": "4.0.1" }, + "default-branch": true, "type": "library", "autoload": { "psr-4": { @@ -1896,27 +1897,27 @@ ], "support": { "issues": "https://github.com/utopia-php/registry/issues", - "source": "https://github.com/utopia-php/registry/tree/0.2.4" + "source": "https://github.com/utopia-php/registry/tree/0.4.0" }, - "time": "2020-10-24T08:51:37+00:00" + "time": "2021-03-10T06:50:09+00:00" }, { "name": "utopia-php/storage", - "version": "0.4.1", + "version": "0.4.3", "source": { "type": "git", "url": "https://github.com/utopia-php/storage.git", - "reference": "86f749f2d79268528732e560f77dde0155e162ca" + "reference": "9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/utopia-php/storage/zipball/86f749f2d79268528732e560f77dde0155e162ca", - "reference": "86f749f2d79268528732e560f77dde0155e162ca", + "url": "https://api.github.com/repos/utopia-php/storage/zipball/9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7", + "reference": "9db3ab713a6d392c3c2c799aeea751f6c8dc2ff7", "shasum": "" }, "require": { "php": ">=7.4", - "utopia-php/framework": "0.10.0" + "utopia-php/framework": "0.*.*" }, "require-dev": { "phpunit/phpunit": "^9.3", @@ -1948,9 +1949,9 @@ ], "support": { "issues": "https://github.com/utopia-php/storage/issues", - "source": "https://github.com/utopia-php/storage/tree/0.4.1" + "source": "https://github.com/utopia-php/storage/tree/0.4.3" }, - "time": "2021-02-19T05:04:44+00:00" + "time": "2021-03-02T20:25:02+00:00" }, { "name": "utopia-php/swoole", @@ -2065,20 +2066,20 @@ }, { "name": "webmozart/assert", - "version": "dev-master", + "version": "1.9.1", "source": { "type": "git", "url": "https://github.com/webmozarts/assert.git", - "reference": "9c89b265ccc4092d58e66d72af5d343ee77a41ae" + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/9c89b265ccc4092d58e66d72af5d343ee77a41ae", - "reference": "9c89b265ccc4092d58e66d72af5d343ee77a41ae", + "url": "https://api.github.com/repos/webmozarts/assert/zipball/bafc69caeb4d49c39fd0779086c03a3738cbb389", + "reference": "bafc69caeb4d49c39fd0779086c03a3738cbb389", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", + "php": "^5.3.3 || ^7.0 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -2086,15 +2087,9 @@ "vimeo/psalm": "<3.9.1" }, "require-dev": { - "phpunit/phpunit": "^8.5.13" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, - "default-branch": true, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, "autoload": { "psr-4": { "Webmozart\\Assert\\": "src/" @@ -2118,9 +2113,9 @@ ], "support": { "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/master" + "source": "https://github.com/webmozarts/assert/tree/1.9.1" }, - "time": "2021-01-18T12:52:36+00:00" + "time": "2020-07-08T17:02:28+00:00" } ], "packages-dev": [ @@ -3279,12 +3274,12 @@ "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "e3324ecbde7319b0bbcf0fd7ca4af19469c38da9" + "reference": "f8d350d8514ff60b5993dd0121c62299480c989c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/e3324ecbde7319b0bbcf0fd7ca4af19469c38da9", - "reference": "e3324ecbde7319b0bbcf0fd7ca4af19469c38da9", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/f8d350d8514ff60b5993dd0121c62299480c989c", + "reference": "f8d350d8514ff60b5993dd0121c62299480c989c", "shasum": "" }, "require": { @@ -3328,7 +3323,7 @@ "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master" }, - "time": "2020-11-18T14:27:38+00:00" + "time": "2021-03-07T11:12:25+00:00" }, { "name": "phpdocumentor/type-resolver", @@ -3530,12 +3525,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "dae425925709122f7584cadeeb838edcaa491bb1" + "reference": "330949c62cbc3e44120990701c949e59a4f3e141" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/dae425925709122f7584cadeeb838edcaa491bb1", - "reference": "dae425925709122f7584cadeeb838edcaa491bb1", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/330949c62cbc3e44120990701c949e59a4f3e141", + "reference": "330949c62cbc3e44120990701c949e59a4f3e141", "shasum": "" }, "require": { @@ -3583,7 +3578,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:43+00:00" + "time": "2021-03-10T06:29:10+00:00" }, { "name": "phpunit/php-invoker", @@ -3591,12 +3586,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-invoker.git", - "reference": "5ad9e5f5d6ee1a837e1d50bab1017e0daf423b40" + "reference": "fe3276f5cd81d19a8e8ef90a32855545f7aae7cb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/5ad9e5f5d6ee1a837e1d50bab1017e0daf423b40", - "reference": "5ad9e5f5d6ee1a837e1d50bab1017e0daf423b40", + "url": "https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/fe3276f5cd81d19a8e8ef90a32855545f7aae7cb", + "reference": "fe3276f5cd81d19a8e8ef90a32855545f7aae7cb", "shasum": "" }, "require": { @@ -3647,7 +3642,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:51+00:00" + "time": "2021-03-10T06:29:18+00:00" }, { "name": "phpunit/php-text-template", @@ -3655,12 +3650,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "4ec5a2ac79a19b35d0cf83cce30604f77743067a" + "reference": "11d864dc75b7f73d1e03361bff717894587f3987" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/4ec5a2ac79a19b35d0cf83cce30604f77743067a", - "reference": "4ec5a2ac79a19b35d0cf83cce30604f77743067a", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/11d864dc75b7f73d1e03361bff717894587f3987", + "reference": "11d864dc75b7f73d1e03361bff717894587f3987", "shasum": "" }, "require": { @@ -3707,7 +3702,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:24+00:00" + "time": "2021-03-10T06:29:48+00:00" }, { "name": "phpunit/php-timer", @@ -3715,12 +3710,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "705821b0927b5e69e9e016c84de68dc6195c71b9" + "reference": "95242c4aa540e9b3655c7edbe8f76d55ac237b7b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/705821b0927b5e69e9e016c84de68dc6195c71b9", - "reference": "705821b0927b5e69e9e016c84de68dc6195c71b9", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/95242c4aa540e9b3655c7edbe8f76d55ac237b7b", + "reference": "95242c4aa540e9b3655c7edbe8f76d55ac237b7b", "shasum": "" }, "require": { @@ -3767,7 +3762,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:59+00:00" + "time": "2021-03-10T06:29:26+00:00" }, { "name": "phpunit/phpunit", @@ -3874,28 +3869,22 @@ }, { "name": "psr/container", - "version": "dev-master", + "version": "1.1.x-dev", "source": { "type": "git", "url": "https://github.com/php-fig/container.git", - "reference": "381524e8568e07f31d504a945b88556548c8c42e" + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/381524e8568e07f31d504a945b88556548c8c42e", - "reference": "381524e8568e07f31d504a945b88556548c8c42e", + "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", + "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", "shasum": "" }, "require": { "php": ">=7.2.0" }, - "default-branch": true, "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1.x-dev" - } - }, "autoload": { "psr-4": { "Psr\\Container\\": "src/" @@ -3922,9 +3911,9 @@ ], "support": { "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/master" + "source": "https://github.com/php-fig/container/tree/1.1.x" }, - "time": "2020-10-13T07:07:53+00:00" + "time": "2021-03-05T17:36:06+00:00" }, { "name": "sebastian/cli-parser", @@ -3932,12 +3921,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/cli-parser.git", - "reference": "3a42d843af4d27ca1155e1d926881af162733655" + "reference": "c8472024d13a267ba49f4c1e194a01cba5b094f5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/3a42d843af4d27ca1155e1d926881af162733655", - "reference": "3a42d843af4d27ca1155e1d926881af162733655", + "url": "https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/c8472024d13a267ba49f4c1e194a01cba5b094f5", + "reference": "c8472024d13a267ba49f4c1e194a01cba5b094f5", "shasum": "" }, "require": { @@ -3981,7 +3970,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:50+00:00" + "time": "2021-03-10T06:30:16+00:00" }, { "name": "sebastian/code-unit", @@ -4045,12 +4034,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", - "reference": "5f5db0b35f586eb5bca0581a10bb42dd56575986" + "reference": "84710fb3a027eb62978539705a0cd00713d474c8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/5f5db0b35f586eb5bca0581a10bb42dd56575986", - "reference": "5f5db0b35f586eb5bca0581a10bb42dd56575986", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/84710fb3a027eb62978539705a0cd00713d474c8", + "reference": "84710fb3a027eb62978539705a0cd00713d474c8", "shasum": "" }, "require": { @@ -4093,7 +4082,7 @@ "type": "github" } ], - "time": "2021-02-23T15:47:39+00:00" + "time": "2021-03-10T06:28:05+00:00" }, { "name": "sebastian/comparator", @@ -4101,12 +4090,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "dbc5fb421f242a5749845dc8dd0dc8cde2979dd9" + "reference": "5dfac003e3be0ca24000cee2a2e19ba2f21aa8f8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/dbc5fb421f242a5749845dc8dd0dc8cde2979dd9", - "reference": "dbc5fb421f242a5749845dc8dd0dc8cde2979dd9", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/5dfac003e3be0ca24000cee2a2e19ba2f21aa8f8", + "reference": "5dfac003e3be0ca24000cee2a2e19ba2f21aa8f8", "shasum": "" }, "require": { @@ -4168,7 +4157,7 @@ "type": "github" } ], - "time": "2021-02-23T15:47:47+00:00" + "time": "2021-03-10T06:28:15+00:00" }, { "name": "sebastian/complexity", @@ -4233,12 +4222,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "93e6aa13f3dc5f8327e7fb9756e9655fc4c23e90" + "reference": "08ab1620f0f35c41e50d847433193da76d33151e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/93e6aa13f3dc5f8327e7fb9756e9655fc4c23e90", - "reference": "93e6aa13f3dc5f8327e7fb9756e9655fc4c23e90", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/08ab1620f0f35c41e50d847433193da76d33151e", + "reference": "08ab1620f0f35c41e50d847433193da76d33151e", "shasum": "" }, "require": { @@ -4292,7 +4281,7 @@ "type": "github" } ], - "time": "2021-02-23T15:47:55+00:00" + "time": "2021-03-10T06:28:23+00:00" }, { "name": "sebastian/environment", @@ -4300,12 +4289,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e1743b808be9cfd33a716583ccb94b7d4d32e94" + "reference": "e34aa76b02666b7f12417f2000b6d4fbb9c2016c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e1743b808be9cfd33a716583ccb94b7d4d32e94", - "reference": "6e1743b808be9cfd33a716583ccb94b7d4d32e94", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/e34aa76b02666b7f12417f2000b6d4fbb9c2016c", + "reference": "e34aa76b02666b7f12417f2000b6d4fbb9c2016c", "shasum": "" }, "require": { @@ -4356,7 +4345,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:03+00:00" + "time": "2021-03-10T06:28:31+00:00" }, { "name": "sebastian/exporter", @@ -4364,12 +4353,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "eca7281ab29075df68b113a37a83be616b629b12" + "reference": "889b30136f9f8a6c0c4d71954b772ac8b8d7feab" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/eca7281ab29075df68b113a37a83be616b629b12", - "reference": "eca7281ab29075df68b113a37a83be616b629b12", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/889b30136f9f8a6c0c4d71954b772ac8b8d7feab", + "reference": "889b30136f9f8a6c0c4d71954b772ac8b8d7feab", "shasum": "" }, "require": { @@ -4434,7 +4423,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:12+00:00" + "time": "2021-03-10T06:28:38+00:00" }, { "name": "sebastian/global-state", @@ -4442,12 +4431,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "0ac702e6d13725242edb9b294c5d20b92fcfb8b4" + "reference": "8a1428d5351ea5dae3aa386d3b321499ac23adea" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ac702e6d13725242edb9b294c5d20b92fcfb8b4", - "reference": "0ac702e6d13725242edb9b294c5d20b92fcfb8b4", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/8a1428d5351ea5dae3aa386d3b321499ac23adea", + "reference": "8a1428d5351ea5dae3aa386d3b321499ac23adea", "shasum": "" }, "require": { @@ -4499,7 +4488,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:19+00:00" + "time": "2021-03-10T06:28:46+00:00" }, { "name": "sebastian/lines-of-code", @@ -4564,12 +4553,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "8cc80b4bda00a4c5997c3fc597a34872f3a1007d" + "reference": "b218fb1d63287edb7613b61122890f39e82ae8c2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/8cc80b4bda00a4c5997c3fc597a34872f3a1007d", - "reference": "8cc80b4bda00a4c5997c3fc597a34872f3a1007d", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/b218fb1d63287edb7613b61122890f39e82ae8c2", + "reference": "b218fb1d63287edb7613b61122890f39e82ae8c2", "shasum": "" }, "require": { @@ -4614,7 +4603,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:28+00:00" + "time": "2021-03-10T06:28:54+00:00" }, { "name": "sebastian/object-reflector", @@ -4622,12 +4611,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-reflector.git", - "reference": "1d33587c2c3e636936f895e103a9e82dd8102a8e" + "reference": "cbf30bc9ed44451f5301480f668cd4fcf6bb225a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/1d33587c2c3e636936f895e103a9e82dd8102a8e", - "reference": "1d33587c2c3e636936f895e103a9e82dd8102a8e", + "url": "https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/cbf30bc9ed44451f5301480f668cd4fcf6bb225a", + "reference": "cbf30bc9ed44451f5301480f668cd4fcf6bb225a", "shasum": "" }, "require": { @@ -4670,7 +4659,7 @@ "type": "github" } ], - "time": "2021-02-23T15:48:35+00:00" + "time": "2021-03-10T06:29:02+00:00" }, { "name": "sebastian/recursion-context", @@ -4678,12 +4667,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "43f58a51e8f853aadb228ba818d2be388af7237b" + "reference": "c3333538e25ec932d0cbdce77b6ac846757b809d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/43f58a51e8f853aadb228ba818d2be388af7237b", - "reference": "43f58a51e8f853aadb228ba818d2be388af7237b", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/c3333538e25ec932d0cbdce77b6ac846757b809d", + "reference": "c3333538e25ec932d0cbdce77b6ac846757b809d", "shasum": "" }, "require": { @@ -4734,7 +4723,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:08+00:00" + "time": "2021-03-10T06:29:33+00:00" }, { "name": "sebastian/resource-operations", @@ -4798,12 +4787,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "557863473c1de00e165a288d5b547f1f83652e7e" + "reference": "1bba184dccb563769fab9bd69c623c1a353dec98" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/557863473c1de00e165a288d5b547f1f83652e7e", - "reference": "557863473c1de00e165a288d5b547f1f83652e7e", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/1bba184dccb563769fab9bd69c623c1a353dec98", + "reference": "1bba184dccb563769fab9bd69c623c1a353dec98", "shasum": "" }, "require": { @@ -4847,7 +4836,7 @@ "type": "github" } ], - "time": "2021-02-23T15:49:16+00:00" + "time": "2021-03-10T06:29:41+00:00" }, { "name": "sebastian/version", @@ -4946,12 +4935,12 @@ "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "c08d7d0d458eceb62996d81d3be8d9fbf5564ec4" + "reference": "4e102e4de39852a1dcd3b2169d263b88afee7fff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/c08d7d0d458eceb62996d81d3be8d9fbf5564ec4", - "reference": "c08d7d0d458eceb62996d81d3be8d9fbf5564ec4", + "url": "https://api.github.com/repos/symfony/console/zipball/4e102e4de39852a1dcd3b2169d263b88afee7fff", + "reference": "4e102e4de39852a1dcd3b2169d263b88afee7fff", "shasum": "" }, "require": { @@ -5036,7 +5025,7 @@ "type": "tidelift" } ], - "time": "2021-02-23T10:10:15+00:00" + "time": "2021-03-08T21:52:55+00:00" }, { "name": "symfony/polyfill-ctype", @@ -5536,17 +5525,17 @@ "source": { "type": "git", "url": "https://github.com/symfony/service-contracts.git", - "reference": "e830e6ceebd6377b019e4c9a523d6f2c27007e4a" + "reference": "96cd360b9f03a22a30cf5354e630c557bd3aac33" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/e830e6ceebd6377b019e4c9a523d6f2c27007e4a", - "reference": "e830e6ceebd6377b019e4c9a523d6f2c27007e4a", + "url": "https://api.github.com/repos/symfony/service-contracts/zipball/96cd360b9f03a22a30cf5354e630c557bd3aac33", + "reference": "96cd360b9f03a22a30cf5354e630c557bd3aac33", "shasum": "" }, "require": { "php": ">=7.2.5", - "psr/container": "^1.0" + "psr/container": "^1.1" }, "suggest": { "symfony/service-implementation": "" @@ -5608,7 +5597,7 @@ "type": "tidelift" } ], - "time": "2021-02-25T16:38:04+00:00" + "time": "2021-03-05T22:51:52+00:00" }, { "name": "symfony/string", @@ -5799,12 +5788,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "728c611e8643a5dd44839ffa791e21763b04a694" + "reference": "37e48403c21e06f63bc27d7ccd997fbb72b0ae2a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/728c611e8643a5dd44839ffa791e21763b04a694", - "reference": "728c611e8643a5dd44839ffa791e21763b04a694", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/37e48403c21e06f63bc27d7ccd997fbb72b0ae2a", + "reference": "37e48403c21e06f63bc27d7ccd997fbb72b0ae2a", "shasum": "" }, "require": { @@ -5870,7 +5859,7 @@ "type": "tidelift" } ], - "time": "2021-02-22T11:56:05+00:00" + "time": "2021-03-10T10:07:14+00:00" }, { "name": "vimeo/psalm", diff --git a/src/Appwrite/Resque/Worker.php b/src/Appwrite/Resque/Worker.php new file mode 100644 index 0000000000..25c6ea2f52 --- /dev/null +++ b/src/Appwrite/Resque/Worker.php @@ -0,0 +1,33 @@ +init(); + } + + public function perform() + { + $this->execute(); + } + + public function tearDown(): void + { + $this->shutdown(); + } +} diff --git a/tests/benchmarks/http.js b/tests/benchmarks/http.js new file mode 100644 index 0000000000..a73f8d5633 --- /dev/null +++ b/tests/benchmarks/http.js @@ -0,0 +1,29 @@ +import http from 'k6/http'; +import { sleep, check } from 'k6'; +import { Counter } from 'k6/metrics'; + +// A simple counter for http requests +export const requests = new Counter('http_reqs'); + +// you can specify stages of your test (ramp up/down patterns) through the options object +// target is the number of VUs you are aiming for + +export const options = { + stages: [ + { target: 50, duration: '1m' }, + // { target: 15, duration: '1m' }, + // { target: 0, duration: '1m' }, + ], + thresholds: { + requests: ['count < 100'], + }, +}; + +export default function () { + const res = http.get('http://localhost:9501/v1/health/version?project=console'); + + const checkRes = check(res, { + 'status is 200': (r) => r.status === 200, + 'response body': (r) => r.body.indexOf('0.7.0') !== -1, + }); +} \ No newline at end of file diff --git a/tests/benchmarks/ws.js b/tests/benchmarks/ws.js new file mode 100644 index 0000000000..34cbfb0a3b --- /dev/null +++ b/tests/benchmarks/ws.js @@ -0,0 +1,38 @@ +// k6 run tests/benchmarks/ws.js + +import { URL } from 'https://jslib.k6.io/url/1.0.0/index.js'; +import ws from 'k6/ws'; +import { check } from 'k6'; + +export let options = { + stages: [ + { duration: '20s', target: 10 }, + { duration: '20s', target: 100 }, + { duration: '20s', target: 0 }, + ], +} + +export default function () { + const url = new URL('ws://localhost/v1/realtime'); + url.searchParams.append('project', '60479391b1c3f'); + url.searchParams.append('channels[]', 'files'); + + const res = ws.connect(url.toString(), function (socket) { + socket.on('open', () => { + console.log('connected') + }); + + socket.on('message', (data) => { + console.log('Message received: ', data) + }); + + socket.on('close', () => console.log('disconnected')); + + socket.setTimeout(function () { + console.log('2 seconds passed, closing the socket'); + socket.close(); + }, 2000); + }); + + check(res, { 'status is 101': (r) => r && r.status === 101 }); +} \ No newline at end of file