Updated health controller
This commit is contained in:
parent
acc9bd7a91
commit
0aa2687074
|
@ -14,21 +14,23 @@ App::get('/v1/health')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'get')
|
||||
->label('sdk.description', '/docs/references/health/get.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/version')
|
||||
->desc('Get Version')
|
||||
->groups(['api', 'health'])
|
||||
->label('scope', 'public')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['version' => APP_VERSION_STABLE]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/db')
|
||||
->desc('Get DB')
|
||||
|
@ -38,6 +40,8 @@ App::get('/v1/health/db')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getDB')
|
||||
->label('sdk.description', '/docs/references/health/get-db.md')
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->action(function ($response, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
|
@ -45,7 +49,7 @@ App::get('/v1/health/db')
|
|||
$register->get('db'); /* @var $db PDO */
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response', 'register']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/cache')
|
||||
->desc('Get Cache')
|
||||
|
@ -55,13 +59,15 @@ App::get('/v1/health/cache')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getCache')
|
||||
->label('sdk.description', '/docs/references/health/get-cache.md')
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->action(function ($response, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
$register->get('cache'); /* @var $cache Predis\Client */
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/time')
|
||||
->desc('Get Time')
|
||||
|
@ -71,6 +77,7 @@ App::get('/v1/health/time')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getTime')
|
||||
->label('sdk.description', '/docs/references/health/get-time.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
|
@ -109,7 +116,7 @@ App::get('/v1/health/time')
|
|||
}
|
||||
|
||||
$response->json(['remote' => $timestamp, 'local' => \time(), 'diff' => $diff]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/webhooks')
|
||||
->desc('Get Webhooks Queue')
|
||||
|
@ -119,11 +126,12 @@ App::get('/v1/health/queue/webhooks')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueWebhooks')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-webhooks.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-webhooks')]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/tasks')
|
||||
->desc('Get Tasks Queue')
|
||||
|
@ -133,11 +141,12 @@ App::get('/v1/health/queue/tasks')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueTasks')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-tasks.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-tasks')]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/logs')
|
||||
->desc('Get Logs Queue')
|
||||
|
@ -147,11 +156,12 @@ App::get('/v1/health/queue/logs')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueLogs')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-logs.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-audit')]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/usage')
|
||||
->desc('Get Usage Queue')
|
||||
|
@ -161,11 +171,12 @@ App::get('/v1/health/queue/usage')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueUsage')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-usage.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-usage')]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/certificates')
|
||||
->desc('Get Certificate Queue')
|
||||
|
@ -175,11 +186,12 @@ App::get('/v1/health/queue/certificates')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueCertificates')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-certificates.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-certificates')]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/queue/functions')
|
||||
->desc('Get Functions Queue')
|
||||
|
@ -189,11 +201,12 @@ App::get('/v1/health/queue/functions')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getQueueFunctions')
|
||||
->label('sdk.description', '/docs/references/health/get-queue-functions.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
$response->json(['size' => Resque::size('v1-functions')]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/storage/local')
|
||||
->desc('Get Local Storage')
|
||||
|
@ -203,6 +216,7 @@ App::get('/v1/health/storage/local')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getStorageLocal')
|
||||
->label('sdk.description', '/docs/references/health/get-storage-local.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
|
@ -224,7 +238,7 @@ App::get('/v1/health/storage/local')
|
|||
}
|
||||
|
||||
$response->json(['status' => 'OK']);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/anti-virus')
|
||||
->desc('Get Anti virus')
|
||||
|
@ -234,6 +248,7 @@ App::get('/v1/health/anti-virus')
|
|||
->label('sdk.namespace', 'health')
|
||||
->label('sdk.method', 'getAntiVirus')
|
||||
->label('sdk.description', '/docs/references/health/get-storage-anti-virus.md')
|
||||
->inject('response')
|
||||
->action(function ($response) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
|
||||
|
@ -247,7 +262,7 @@ App::get('/v1/health/anti-virus')
|
|||
'status' => (@$antiVirus->ping()) ? 'online' : 'offline',
|
||||
'version' => @$antiVirus->version(),
|
||||
]);
|
||||
}, ['response']);
|
||||
});
|
||||
|
||||
App::get('/v1/health/stats') // Currently only used internally
|
||||
->desc('Get System Stats')
|
||||
|
@ -257,6 +272,8 @@ App::get('/v1/health/stats') // Currently only used internally
|
|||
// ->label('sdk.namespace', 'health')
|
||||
// ->label('sdk.method', 'getStats')
|
||||
->label('docs', false)
|
||||
->inject('response')
|
||||
->inject('register')
|
||||
->action(function ($response, $register) {
|
||||
/** @var Appwrite\Utopia\Response $response */
|
||||
/** @var Utopia\Registry\Registry $register */
|
||||
|
@ -288,4 +305,4 @@ App::get('/v1/health/stats') // Currently only used internally
|
|||
'memory_used_peak_human' => $cacheStats['used_memory_peak_human'] ?? 0,
|
||||
],
|
||||
]);
|
||||
}, ['response', 'register']);
|
||||
});
|
||||
|
|
|
@ -59,7 +59,7 @@ class HealthCustomClientTest extends Scope
|
|||
/**
|
||||
* Test for SUCCESS
|
||||
*/
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/db', array_merge([
|
||||
$response = $this->client->call(Client::METHOD_GET, '/health/cache', array_merge([
|
||||
'content-type' => 'application/json',
|
||||
'x-appwrite-project' => $this->getProject()['$id'],
|
||||
], $this->getHeaders()), []);
|
||||
|
|
Loading…
Reference in a new issue