Update health.php
This commit is contained in:
parent
dc2107fe66
commit
867bc0281c
1 changed files with 17 additions and 19 deletions
|
@ -18,21 +18,6 @@ use Utopia\Validator\Integer;
|
||||||
use Utopia\Validator\Text;
|
use Utopia\Validator\Text;
|
||||||
use Utopia\Validator\WhiteList;
|
use Utopia\Validator\WhiteList;
|
||||||
|
|
||||||
const QUEUE_NAMES = [
|
|
||||||
'Database' => Event::DATABASE_QUEUE_NAME,
|
|
||||||
'Delete' => Event::DELETE_QUEUE_NAME,
|
|
||||||
'Audit' => Event::AUDITS_QUEUE_NAME,
|
|
||||||
'Mail' => Event::MAILS_QUEUE_NAME,
|
|
||||||
'Function' => Event::FUNCTIONS_QUEUE_NAME,
|
|
||||||
'Usage' => Event::USAGE_QUEUE_NAME,
|
|
||||||
'Webhook' => Event::WEBHOOK_QUEUE_NAME,
|
|
||||||
'Certificate' => Event::CERTIFICATES_QUEUE_NAME,
|
|
||||||
'Build' => Event::BUILDS_QUEUE_NAME,
|
|
||||||
'Messaging' => Event::MESSAGING_QUEUE_NAME,
|
|
||||||
'Migration' => Event::MIGRATIONS_QUEUE_NAME,
|
|
||||||
'Hamster' => Event::HAMSTER_QUEUE_NAME,
|
|
||||||
];
|
|
||||||
|
|
||||||
App::get('/v1/health')
|
App::get('/v1/health')
|
||||||
->desc('Get HTTP')
|
->desc('Get HTTP')
|
||||||
->groups(['api', 'health'])
|
->groups(['api', 'health'])
|
||||||
|
@ -710,7 +695,20 @@ App::get('/v1/health/queue/failed/:queueName')
|
||||||
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
->label('sdk.auth', [APP_AUTH_TYPE_KEY])
|
||||||
->label('sdk.namespace', 'health')
|
->label('sdk.namespace', 'health')
|
||||||
->label('sdk.method', 'getFailedJobs')
|
->label('sdk.method', 'getFailedJobs')
|
||||||
->param('queueName', '', new WhiteList(array_keys(QUEUE_NAMES)), 'The name of the queue')
|
->param('queueName', '', new WhiteList([
|
||||||
|
Event::DATABASE_QUEUE_NAME,
|
||||||
|
Event::DELETE_QUEUE_NAME,
|
||||||
|
Event::AUDITS_QUEUE_NAME,
|
||||||
|
Event::MAILS_QUEUE_NAME,
|
||||||
|
Event::FUNCTIONS_QUEUE_NAME,
|
||||||
|
Event::USAGE_QUEUE_NAME,
|
||||||
|
Event::WEBHOOK_CLASS_NAME,
|
||||||
|
Event::CERTIFICATES_QUEUE_NAME,
|
||||||
|
Event::BUILDS_QUEUE_NAME,
|
||||||
|
Event::MESSAGING_QUEUE_NAME,
|
||||||
|
Event::MIGRATIONS_QUEUE_NAME,
|
||||||
|
Event::HAMSTER_CLASS_NAME
|
||||||
|
]), 'The name of the queue')
|
||||||
->label('sdk.description', '/docs/references/health/get-failed-queue-jobs.md')
|
->label('sdk.description', '/docs/references/health/get-failed-queue-jobs.md')
|
||||||
->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)
|
||||||
|
@ -718,10 +716,10 @@ App::get('/v1/health/queue/failed/:queueName')
|
||||||
->inject('response')
|
->inject('response')
|
||||||
->inject('queue')
|
->inject('queue')
|
||||||
->action(function (string $queueName, Response $response, Connection $queue) {
|
->action(function (string $queueName, Response $response, Connection $queue) {
|
||||||
$client = new Client(QUEUE_NAMES[$queueName], $queue);
|
$client = new Client($queueName, $queue);
|
||||||
$failed = $client->sumFailedJobs(); //TODO: Replace with countFailedJobs() when new version is ready
|
$failed = $client->countFailedJobs();
|
||||||
|
|
||||||
$response->dynamic(new Document([ 'failed' => $failed]), Response::MODEL_HEALTH_FAILED_JOBS);
|
$response->dynamic(new Document(['failed' => $failed]), Response::MODEL_HEALTH_FAILED_JOBS);
|
||||||
});
|
});
|
||||||
|
|
||||||
App::get('/v1/health/stats') // Currently only used internally
|
App::get('/v1/health/stats') // Currently only used internally
|
||||||
|
|
Loading…
Reference in a new issue