1
0
Fork 0
mirror of synced 2024-10-02 02:07:04 +13:00

Continue removing resque

This commit is contained in:
Bradley Schofield 2022-12-20 12:48:55 +00:00
parent 886a1a2abb
commit b0c8e8980d
7 changed files with 24 additions and 15 deletions

View file

@ -1,6 +1,8 @@
<?php <?php
use Appwrite\ClamAV\Network; use Appwrite\ClamAV\Network;
use Appwrite\Event\Audit;
use Appwrite\Event\Certificate;
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Extend\Exception; use Appwrite\Extend\Exception;
use Appwrite\Utopia\Response; use Appwrite\Utopia\Response;
@ -347,10 +349,11 @@ App::get('/v1/health/queue/webhooks')
->label('sdk.response.code', Response::STATUS_CODE_OK) ->label('sdk.response.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE)
->inject('events')
->inject('response') ->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']); }, ['response']);
App::get('/v1/health/queue/logs') 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.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE)
->inject('audits')
->inject('response') ->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']); }, ['response']);
App::get('/v1/health/queue/certificates') 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.code', Response::STATUS_CODE_OK)
->label('sdk.response.type', Response::CONTENT_TYPE_JSON) ->label('sdk.response.type', Response::CONTENT_TYPE_JSON)
->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE) ->label('sdk.response.model', Response::MODEL_HEALTH_QUEUE)
->inject('certificates')
->inject('response') ->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']); }, ['response']);
App::get('/v1/health/queue/functions') App::get('/v1/health/queue/functions')

View file

@ -5,7 +5,6 @@ require_once __DIR__ . '/../worker.php';
use Appwrite\Event\Event; use Appwrite\Event\Event;
use Appwrite\Event\Func; use Appwrite\Event\Func;
use Appwrite\Messaging\Adapter\Realtime; use Appwrite\Messaging\Adapter\Realtime;
use Appwrite\Resque\Worker;
use Appwrite\Utopia\Response\Model\Deployment; use Appwrite\Utopia\Response\Model\Deployment;
use Executor\Executor; use Executor\Executor;
use Appwrite\Usage\Stats; use Appwrite\Usage\Stats;

View file

@ -9,7 +9,6 @@ use Utopia\Cache\Cache;
use Utopia\Database\Database; use Utopia\Database\Database;
use Utopia\Database\Document; use Utopia\Database\Document;
use Utopia\Database\Query; use Utopia\Database\Query;
use Appwrite\Resque\Worker;
use Executor\Executor; use Executor\Executor;
use Utopia\Storage\Device\Local; use Utopia\Storage\Device\Local;
use Utopia\Abuse\Abuse; use Utopia\Abuse\Abuse;

View file

@ -1,6 +1,5 @@
<?php <?php
use Appwrite\Resque\Worker;
use Appwrite\Template\Template; use Appwrite\Template\Template;
use Utopia\App; use Utopia\App;
use Utopia\CLI\Console; use Utopia\CLI\Console;

View file

@ -2,7 +2,6 @@
require_once __DIR__ . '/../worker.php'; require_once __DIR__ . '/../worker.php';
use Appwrite\Resque\Worker;
use Utopia\App; use Utopia\App;
use Utopia\CLI\Console; use Utopia\CLI\Console;
use Utopia\Database\Document; use Utopia\Database\Document;

View file

@ -276,6 +276,18 @@ class Event
]); ]);
} }
/**
* Get Queue Size
*
* @return int
*/
public function getQueueSize(): int
{
$client = new Client($this->queue, $this->connection);
return $client->getQueueSize();
}
/** /**
* Resets event. * Resets event.
* *

View file

@ -17,10 +17,6 @@ class EventTest extends TestCase
public function setUp(): void public function setUp(): void
{ {
$redisHost = App::getEnv('_APP_REDIS_HOST', '');
$redisPort = App::getEnv('_APP_REDIS_PORT', '');
\Resque::setBackend($redisHost . ':' . $redisPort);
$fallbackForRedis = URL::unparse([ $fallbackForRedis = URL::unparse([
'scheme' => 'redis', 'scheme' => 'redis',
'host' => App::getEnv('_APP_REDIS_HOST', '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('eventValue1', $this->object->getParam('eventKey1'));
$this->assertEquals('eventValue2', $this->object->getParam('eventKey2')); $this->assertEquals('eventValue2', $this->object->getParam('eventKey2'));
$this->assertEquals(null, $this->object->getParam('eventKey3')); $this->assertEquals(null, $this->object->getParam('eventKey3'));
$this->assertEquals(\Resque::size($this->queue), 1); $this->assertEquals($this->object->getQueueSize(), 1);
} }
public function testReset(): void public function testReset(): void