From b0c8e8980db6dac18e2bc8219cd97d5c4063ff42 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Tue, 20 Dec 2022 12:48:55 +0000 Subject: [PATCH] Continue removing resque --- app/controllers/api/health.php | 17 +++++++++++------ app/workers/builds.php | 1 - app/workers/deletes.php | 1 - app/workers/mails.php | 1 - app/workers/webhooks.php | 1 - src/Appwrite/Event/Event.php | 12 ++++++++++++ tests/unit/Event/EventTest.php | 6 +----- 7 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/controllers/api/health.php b/app/controllers/api/health.php index d6a2612f32..4c40953f9b 100644 --- a/app/controllers/api/health.php +++ b/app/controllers/api/health.php @@ -1,6 +1,8 @@ label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('events') ->inject('response') - ->action(function (Response $response) { + ->action(function (Event $events, Response $response) { - $response->dynamic(new Document([ 'size' => Resque::size(Event::WEBHOOK_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $events->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/logs') @@ -364,10 +367,11 @@ App::get('/v1/health/queue/logs') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('audits') ->inject('response') - ->action(function (Response $response) { + ->action(function (Audit $audits, Response $response) { - $response->dynamic(new Document([ 'size' => Resque::size(Event::AUDITS_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $audits->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/certificates') @@ -381,10 +385,11 @@ App::get('/v1/health/queue/certificates') ->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) + ->inject('certificates') ->inject('response') - ->action(function (Response $response) { + ->action(function (Certificate $certificates, Response $response) { - $response->dynamic(new Document([ 'size' => Resque::size(Event::CERTIFICATES_QUEUE_NAME) ]), Response::MODEL_HEALTH_QUEUE); + $response->dynamic(new Document([ 'size' => $certificates->getQueueSize() ]), Response::MODEL_HEALTH_QUEUE); }, ['response']); App::get('/v1/health/queue/functions') diff --git a/app/workers/builds.php b/app/workers/builds.php index 9ca077dfcd..63ecf6af2f 100644 --- a/app/workers/builds.php +++ b/app/workers/builds.php @@ -5,7 +5,6 @@ require_once __DIR__ . '/../worker.php'; use Appwrite\Event\Event; use Appwrite\Event\Func; use Appwrite\Messaging\Adapter\Realtime; -use Appwrite\Resque\Worker; use Appwrite\Utopia\Response\Model\Deployment; use Executor\Executor; use Appwrite\Usage\Stats; diff --git a/app/workers/deletes.php b/app/workers/deletes.php index e546c314b9..835cc78e80 100644 --- a/app/workers/deletes.php +++ b/app/workers/deletes.php @@ -9,7 +9,6 @@ use Utopia\Cache\Cache; use Utopia\Database\Database; use Utopia\Database\Document; use Utopia\Database\Query; -use Appwrite\Resque\Worker; use Executor\Executor; use Utopia\Storage\Device\Local; use Utopia\Abuse\Abuse; diff --git a/app/workers/mails.php b/app/workers/mails.php index 7d2927d562..f0658fedca 100644 --- a/app/workers/mails.php +++ b/app/workers/mails.php @@ -1,6 +1,5 @@ queue, $this->connection); + + return $client->getQueueSize(); + } + /** * Resets event. * diff --git a/tests/unit/Event/EventTest.php b/tests/unit/Event/EventTest.php index 6a001fac1e..a276733770 100644 --- a/tests/unit/Event/EventTest.php +++ b/tests/unit/Event/EventTest.php @@ -17,10 +17,6 @@ class EventTest extends TestCase public function setUp(): void { - $redisHost = App::getEnv('_APP_REDIS_HOST', ''); - $redisPort = App::getEnv('_APP_REDIS_PORT', ''); - \Resque::setBackend($redisHost . ':' . $redisPort); - $fallbackForRedis = URL::unparse([ 'scheme' => 'redis', 'host' => App::getEnv('_APP_REDIS_HOST', 'redis'), @@ -74,7 +70,7 @@ class EventTest extends TestCase $this->assertEquals('eventValue1', $this->object->getParam('eventKey1')); $this->assertEquals('eventValue2', $this->object->getParam('eventKey2')); $this->assertEquals(null, $this->object->getParam('eventKey3')); - $this->assertEquals(\Resque::size($this->queue), 1); + $this->assertEquals($this->object->getQueueSize(), 1); } public function testReset(): void