2019-05-09 18:54:39 +12:00
< ? php
2019-08-21 03:43:01 +12:00
use Appwrite\ClamAV\Network ;
2020-12-28 06:57:35 +13:00
use Appwrite\Event\Event ;
2022-05-03 02:34:01 +12:00
use Appwrite\Extend\Exception ;
2021-12-15 03:17:55 +13:00
use Appwrite\Utopia\Response ;
2020-06-29 05:31:21 +12:00
use Utopia\App ;
2022-10-18 00:43:57 +13:00
use Utopia\Config\Config ;
2021-12-21 00:34:48 +13:00
use Utopia\Database\Document ;
2022-10-18 00:43:57 +13:00
use Utopia\Pools\Group ;
2022-11-17 08:39:35 +13:00
use Utopia\Queue\Client ;
use Utopia\Queue\Connection ;
2022-05-03 02:34:01 +12:00
use Utopia\Registry\Registry ;
use Utopia\Storage\Device ;
2021-01-22 21:28:33 +13:00
use Utopia\Storage\Device\Local ;
2022-05-24 02:54:50 +12:00
use Utopia\Storage\Storage ;
2023-11-14 02:07:11 +13:00
use Utopia\Validator\Integer ;
2023-10-19 08:44:06 +13:00
use Utopia\Validator\Text ;
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health' )
2023-08-02 08:49:20 +12:00
-> desc ( 'Get HTTP' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
2020-01-31 05:18:46 +13:00
-> label ( 'sdk.method' , 'get' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.description' , '/docs/references/health/get.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_STATUS )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-05-03 02:28:36 +12:00
-> action ( function ( Response $response ) {
2020-06-30 09:43:34 +12:00
2021-12-15 03:17:55 +13:00
$output = [
2022-10-18 00:43:57 +13:00
'name' => 'http' ,
2021-12-15 03:17:55 +13:00
'status' => 'pass' ,
2021-12-15 23:19:29 +13:00
'ping' => 0
2021-12-15 03:17:55 +13:00
];
$response -> dynamic ( new Document ( $output ), Response :: MODEL_HEALTH_STATUS );
2020-12-27 04:10:45 +13:00
});
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/version' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get version' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-06-15 20:01:32 +12:00
-> label ( 'scope' , 'public' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_VERSION )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-05-03 02:28:36 +12:00
-> action ( function ( Response $response ) {
2021-12-15 03:17:55 +13:00
$response -> dynamic ( new Document ([ 'version' => APP_VERSION_STABLE ]), Response :: MODEL_HEALTH_VERSION );
2020-12-27 04:10:45 +13:00
});
2020-06-15 20:01:32 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/db' )
2023-08-02 08:49:20 +12:00
-> desc ( 'Get DB' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getDB' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.description' , '/docs/references/health/get-db.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_STATUS )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-10-18 00:43:57 +13:00
-> inject ( 'pools' )
-> action ( function ( Response $response , Group $pools ) {
2020-06-30 09:43:34 +12:00
2022-10-18 00:43:57 +13:00
$output = [];
2022-05-24 02:54:50 +12:00
2022-10-18 00:43:57 +13:00
$configs = [
'Console.DB' => Config :: getParam ( 'pools-console' ),
'Projects.DB' => Config :: getParam ( 'pools-database' ),
];
2022-05-24 02:54:50 +12:00
2022-10-18 00:43:57 +13:00
foreach ( $configs as $key => $config ) {
foreach ( $config as $database ) {
try {
$adapter = $pools -> get ( $database ) -> pop () -> getResource ();
2022-05-24 02:54:50 +12:00
2022-10-18 00:43:57 +13:00
$checkStart = \microtime ( true );
2022-10-19 21:35:30 +13:00
if ( $adapter -> ping ()) {
2022-10-18 00:43:57 +13:00
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'pass' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
} else {
2023-11-09 02:20:50 +13:00
$failure [] = $database ;
2022-10-18 00:43:57 +13:00
}
} catch ( \Throwable $th ) {
2023-11-09 02:20:50 +13:00
$failure [] = $database ;
2022-10-18 00:43:57 +13:00
}
}
2021-10-27 22:21:16 +13:00
}
2021-10-15 22:05:21 +13:00
2023-11-09 02:20:50 +13:00
if ( ! empty ( $failure )) {
throw new Exception ( Exception :: GENERAL_SERVER_ERROR , 'DB failure on: ' . implode ( " , " , $failure ));
}
2022-10-18 00:43:57 +13:00
$response -> dynamic ( new Document ([
'statuses' => $output ,
'total' => count ( $output ),
]), Response :: MODEL_HEALTH_STATUS_LIST );
2020-12-27 04:10:45 +13:00
});
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/cache' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get cache' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getCache' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.description' , '/docs/references/health/get-cache.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_STATUS )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-10-18 00:43:57 +13:00
-> inject ( 'pools' )
-> action ( function ( Response $response , Group $pools ) {
2021-12-15 03:17:55 +13:00
2022-10-18 00:43:57 +13:00
$output = [];
2021-12-15 03:17:55 +13:00
2022-10-18 00:43:57 +13:00
$configs = [
'Cache' => Config :: getParam ( 'pools-cache' ),
];
2019-05-09 18:54:39 +12:00
2022-10-18 00:43:57 +13:00
foreach ( $configs as $key => $config ) {
foreach ( $config as $database ) {
try {
$adapter = $pools -> get ( $database ) -> pop () -> getResource ();
2019-05-09 18:54:39 +12:00
2022-10-18 00:43:57 +13:00
$checkStart = \microtime ( true );
2022-10-19 21:35:30 +13:00
if ( $adapter -> ping ()) {
2022-10-18 00:43:57 +13:00
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'pass' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
} else {
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'fail' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
}
} catch ( \Throwable $th ) {
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'fail' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
}
}
2021-10-19 04:08:50 +13:00
}
2021-12-15 03:17:55 +13:00
2022-10-18 00:43:57 +13:00
$response -> dynamic ( new Document ([
'statuses' => $output ,
'total' => count ( $output ),
]), Response :: MODEL_HEALTH_STATUS_LIST );
});
App :: get ( '/v1/health/queue' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get queue' )
2022-10-18 00:43:57 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueue' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_STATUS )
-> inject ( 'response' )
-> inject ( 'pools' )
-> action ( function ( Response $response , Group $pools ) {
$output = [];
$configs = [
'Queue' => Config :: getParam ( 'pools-queue' ),
2021-12-15 03:17:55 +13:00
];
2022-10-18 00:43:57 +13:00
foreach ( $configs as $key => $config ) {
foreach ( $config as $database ) {
try {
$adapter = $pools -> get ( $database ) -> pop () -> getResource ();
$checkStart = \microtime ( true );
2022-10-19 21:35:30 +13:00
if ( $adapter -> ping ()) {
2022-10-18 00:43:57 +13:00
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'pass' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
} else {
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'fail' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
}
} catch ( \Throwable $th ) {
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'fail' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
}
}
}
$response -> dynamic ( new Document ([
'statuses' => $output ,
'total' => count ( $output ),
]), Response :: MODEL_HEALTH_STATUS_LIST );
});
App :: get ( '/v1/health/pubsub' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get pubsub' )
2022-10-18 00:43:57 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getPubSub' )
-> label ( 'sdk.description' , '/docs/references/health/get-pubsub.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_STATUS )
-> inject ( 'response' )
-> inject ( 'pools' )
-> action ( function ( Response $response , Group $pools ) {
$output = [];
$configs = [
'PubSub' => Config :: getParam ( 'pools-pubsub' ),
];
foreach ( $configs as $key => $config ) {
foreach ( $config as $database ) {
try {
$adapter = $pools -> get ( $database ) -> pop () -> getResource ();
$checkStart = \microtime ( true );
2022-10-19 21:35:30 +13:00
if ( $adapter -> ping ()) {
2022-10-18 00:43:57 +13:00
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'pass' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
} else {
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'fail' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
}
} catch ( \Throwable $th ) {
$output [] = new Document ([
2022-10-19 21:35:30 +13:00
'name' => $key . " ( $database ) " ,
2022-10-18 00:43:57 +13:00
'status' => 'fail' ,
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
]);
}
}
}
$response -> dynamic ( new Document ([
'statuses' => $output ,
'total' => count ( $output ),
]), Response :: MODEL_HEALTH_STATUS_LIST );
2020-12-27 04:10:45 +13:00
});
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/time' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get time' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getTime' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.description' , '/docs/references/health/get-time.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_TIME )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-05-03 02:28:36 +12:00
-> action ( function ( Response $response ) {
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
/*
* Code from : @ see https :// www . beliefmedia . com . au / query - ntp - time - server
*/
$host = 'time.google.com' ; // https://developers.google.com/time/
$gap = 60 ; // Allow [X] seconds gap
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
/* Create a socket and connect to NTP server */
$sock = \socket_create ( AF_INET , SOCK_DGRAM , SOL_UDP );
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
\socket_connect ( $sock , $host , 123 );
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
/* Send request */
2022-05-24 02:54:50 +12:00
$msg = " \010 " . \str_repeat ( " \0 " , 47 );
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
\socket_send ( $sock , $msg , \strlen ( $msg ), 0 );
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
/* Receive response and close socket */
\socket_recv ( $sock , $recv , 48 , MSG_WAITALL );
\socket_close ( $sock );
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
/* Interpret response */
$data = \unpack ( 'N12' , $recv );
$timestamp = \sprintf ( '%u' , $data [ 9 ]);
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
/* NTP is number of seconds since 0000 UT on 1 January 1900
Unix time is seconds since 0000 UT on 1 January 1970 */
$timestamp -= 2208988800 ;
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
$diff = ( $timestamp - \time ());
2019-05-09 18:54:39 +12:00
2020-06-30 09:43:34 +12:00
if ( $diff > $gap || $diff < ( $gap * - 1 )) {
2022-07-27 02:24:32 +12:00
throw new Exception ( Exception :: GENERAL_SERVER_ERROR , 'Server time gaps detected' );
2019-05-09 18:54:39 +12:00
}
2020-06-30 09:43:34 +12:00
2021-12-15 03:17:55 +13:00
$output = [
2021-12-15 23:19:29 +13:00
'remoteTime' => $timestamp ,
'localTime' => \time (),
2021-12-15 03:17:55 +13:00
'diff' => $diff
];
$response -> dynamic ( new Document ( $output ), Response :: MODEL_HEALTH_TIME );
2020-12-27 04:10:45 +13:00
});
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/queue/webhooks' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get webhooks queue' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.method' , 'getQueueWebhooks' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-webhooks.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: WEBHOOK_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2020-06-30 09:43:34 +12:00
}, [ 'response' ]);
2019-05-09 18:54:39 +12:00
2023-09-25 01:36:20 +13:00
App :: get ( '/v1/health/queue/logs' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get logs queue' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.namespace' , 'health' )
2023-09-25 01:36:20 +13:00
-> label ( 'sdk.method' , 'getQueueLogs' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-logs.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: AUDITS_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2020-06-30 09:43:34 +12:00
}, [ 'response' ]);
2020-05-01 20:39:45 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/queue/certificates' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get certificates queue' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueCertificates' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-certificates.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: CERTIFICATES_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2020-06-30 09:43:34 +12:00
}, [ 'response' ]);
2020-05-01 20:39:45 +12:00
2023-09-25 01:07:37 +13:00
App :: get ( '/v1/health/queue/builds' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get builds queue' )
2023-09-25 01:07:37 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueBuilds' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-builds.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2023-09-25 01:07:37 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: BUILDS_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2023-09-25 01:07:37 +13:00
}, [ 'response' ]);
2023-10-19 13:09:32 +13:00
App :: get ( '/v1/health/queue/databases' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get databases queue' )
2023-09-25 01:07:37 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueDatabases' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-databases.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-10-19 22:25:38 +13:00
-> param ( 'name' , 'database_db_main' , new Text ( 256 ), 'Queue name for which to check the queue size' , true )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2023-09-25 01:07:37 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( string $name , int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 22:25:38 +13:00
$client = new Client ( $name , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2023-09-25 01:07:37 +13:00
}, [ 'response' ]);
App :: get ( '/v1/health/queue/deletes' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get deletes queue' )
2023-09-25 01:07:37 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueDeletes' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-deletes.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2023-09-25 01:07:37 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: DELETE_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2023-09-25 01:07:37 +13:00
}, [ 'response' ]);
App :: get ( '/v1/health/queue/mails' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get mails queue' )
2023-09-25 01:07:37 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueMails' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-mails.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2023-09-25 01:07:37 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: MAILS_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2023-09-25 01:07:37 +13:00
}, [ 'response' ]);
App :: get ( '/v1/health/queue/messaging' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get messaging queue' )
2023-09-25 01:07:37 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueMessaging' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-messaging.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2023-09-25 01:07:37 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: MESSAGING_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2023-09-25 01:07:37 +13:00
}, [ 'response' ]);
App :: get ( '/v1/health/queue/migrations' )
2023-09-28 11:13:03 +13:00
-> desc ( 'Get migrations queue' )
2023-09-25 01:07:37 +13:00
-> groups ([ 'api' , 'health' ])
-> label ( 'scope' , 'health.read' )
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueMigrations' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-migrations.md' )
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2023-10-19 08:44:06 +13:00
-> inject ( 'queue' )
2023-09-25 01:07:37 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2023-10-19 08:44:06 +13:00
$client = new Client ( Event :: MIGRATIONS_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2023-09-25 01:07:37 +13:00
}, [ 'response' ]);
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/queue/functions' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get functions queue' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2020-05-17 03:34:37 +12:00
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getQueueFunctions' )
-> label ( 'sdk.description' , '/docs/references/health/get-queue-functions.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_QUEUE )
2023-11-14 02:39:33 +13:00
-> param ( 'threshold' , 5000 , new Integer ( true ), 'Queue size threshold. When hit (equal or higher), endpoint returns server error. Default value is 5000.' , true )
2022-11-19 03:22:46 +13:00
-> inject ( 'queue' )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2023-11-14 02:39:33 +13:00
-> action ( function ( int | string $threshold , Connection $queue , Response $response ) {
$threshold = \intval ( $threshold );
2023-11-14 02:07:11 +13:00
2022-11-19 03:22:46 +13:00
$client = new Client ( Event :: FUNCTIONS_QUEUE_NAME , $queue );
2023-11-14 02:07:11 +13:00
$size = $client -> getQueueSize ();
2023-11-14 02:39:33 +13:00
if ( $size >= $threshold ) {
2023-11-18 02:59:57 +13:00
throw new Exception ( Exception :: QUEUE_SIZE_EXCEEDED , " Queue size threshold hit. Current size is { $size } and threshold is { $threshold } . " );
2023-11-14 02:07:11 +13:00
}
$response -> dynamic ( new Document ([ 'size' => $size ]), Response :: MODEL_HEALTH_QUEUE );
2020-06-30 09:43:34 +12:00
}, [ 'response' ]);
2020-05-17 03:34:37 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/storage/local' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get local storage' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
-> label ( 'sdk.method' , 'getStorageLocal' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.description' , '/docs/references/health/get-storage-local.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_STATUS )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-05-03 02:28:36 +12:00
-> action ( function ( Response $response ) {
2020-06-30 09:43:34 +12:00
2021-12-15 03:17:55 +13:00
$checkStart = \microtime ( true );
2022-05-24 02:54:50 +12:00
foreach (
[
2023-11-09 02:20:50 +13:00
'Uploads' => APP_STORAGE_UPLOADS ,
'Cache' => APP_STORAGE_CACHE ,
'Config' => APP_STORAGE_CONFIG ,
'Certs' => APP_STORAGE_CERTIFICATES
2022-05-24 02:54:50 +12:00
] as $key => $volume
) {
2020-06-30 09:43:34 +12:00
$device = new Local ( $volume );
if ( ! \is_readable ( $device -> getRoot ())) {
2022-07-27 02:24:32 +12:00
throw new Exception ( Exception :: GENERAL_SERVER_ERROR , 'Device ' . $key . ' dir is not readable' );
2019-05-09 18:54:39 +12:00
}
2020-06-30 09:43:34 +12:00
if ( ! \is_writable ( $device -> getRoot ())) {
2022-07-27 02:24:32 +12:00
throw new Exception ( Exception :: GENERAL_SERVER_ERROR , 'Device ' . $key . ' dir is not writable' );
2020-06-30 09:43:34 +12:00
}
2019-05-09 18:54:39 +12:00
}
2020-06-30 09:43:34 +12:00
2021-12-15 03:17:55 +13:00
$output = [
'status' => 'pass' ,
2021-12-17 01:19:04 +13:00
'ping' => \round (( \microtime ( true ) - $checkStart ) / 1000 )
2021-12-15 03:17:55 +13:00
];
$response -> dynamic ( new Document ( $output ), Response :: MODEL_HEALTH_STATUS );
2020-12-27 04:10:45 +13:00
});
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/anti-virus' )
2023-08-02 03:26:48 +12:00
-> desc ( 'Get antivirus' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2020-05-17 03:34:37 +12:00
-> label ( 'scope' , 'health.read' )
2021-04-16 19:22:17 +12:00
-> label ( 'sdk.auth' , [ APP_AUTH_TYPE_KEY ])
2019-05-09 18:54:39 +12:00
-> label ( 'sdk.namespace' , 'health' )
2021-12-15 23:09:43 +13:00
-> label ( 'sdk.method' , 'getAntivirus' )
2020-05-01 20:39:45 +12:00
-> label ( 'sdk.description' , '/docs/references/health/get-storage-anti-virus.md' )
2021-12-15 03:17:55 +13:00
-> label ( 'sdk.response.code' , Response :: STATUS_CODE_OK )
-> label ( 'sdk.response.type' , Response :: CONTENT_TYPE_JSON )
-> label ( 'sdk.response.model' , Response :: MODEL_HEALTH_ANTIVIRUS )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
2022-05-03 02:28:36 +12:00
-> action ( function ( Response $response ) {
2019-05-09 18:54:39 +12:00
2021-12-15 03:17:55 +13:00
$output = [
'status' => '' ,
'version' => ''
];
2020-06-30 09:43:34 +12:00
if ( App :: getEnv ( '_APP_STORAGE_ANTIVIRUS' ) === 'disabled' ) { // Check if scans are enabled
2021-12-15 03:17:55 +13:00
$output [ 'status' ] = 'disabled' ;
$output [ 'version' ] = '' ;
} else {
2022-05-24 02:54:50 +12:00
$antivirus = new Network (
App :: getEnv ( '_APP_STORAGE_ANTIVIRUS_HOST' , 'clamav' ),
( int ) App :: getEnv ( '_APP_STORAGE_ANTIVIRUS_PORT' , 3310 )
);
2021-12-15 03:17:55 +13:00
try {
2021-12-15 23:06:26 +13:00
$output [ 'version' ] = @ $antivirus -> version ();
$output [ 'status' ] = ( @ $antivirus -> ping ()) ? 'pass' : 'fail' ;
2022-05-24 02:54:50 +12:00
} catch ( \Exception $e ) {
2022-07-27 02:24:32 +12:00
throw new Exception ( Exception :: GENERAL_SERVER_ERROR , 'Antivirus is not available' );
2021-12-15 03:17:55 +13:00
}
2019-05-09 18:54:39 +12:00
}
2020-06-30 09:43:34 +12:00
2021-12-15 23:06:26 +13:00
$response -> dynamic ( new Document ( $output ), Response :: MODEL_HEALTH_ANTIVIRUS );
2020-12-27 04:10:45 +13:00
});
2019-05-09 18:54:39 +12:00
2020-06-29 05:31:21 +12:00
App :: get ( '/v1/health/stats' ) // Currently only used internally
2023-11-09 02:20:50 +13:00
-> desc ( 'Get system stats' )
2020-06-26 06:32:12 +12:00
-> groups ([ 'api' , 'health' ])
2021-05-13 02:53:25 +12:00
-> label ( 'scope' , 'root' )
2021-04-16 19:22:17 +12:00
// ->label('sdk.auth', [APP_AUTH_TYPE_KEY])
2020-05-01 20:39:45 +12:00
// ->label('sdk.namespace', 'health')
// ->label('sdk.method', 'getStats')
2019-05-09 18:54:39 +12:00
-> label ( 'docs' , false )
2020-12-27 04:10:45 +13:00
-> inject ( 'response' )
-> inject ( 'register' )
2022-02-15 21:43:57 +13:00
-> inject ( 'deviceFiles' )
2022-05-03 02:28:36 +12:00
-> action ( function ( Response $response , Registry $register , Device $deviceFiles ) {
2020-06-30 09:43:34 +12:00
$cache = $register -> get ( 'cache' );
$cacheStats = $cache -> info ();
$response
-> json ([
'storage' => [
2022-05-24 02:54:50 +12:00
'used' => Storage :: human ( $deviceFiles -> getDirectorySize ( $deviceFiles -> getRoot () . '/' )),
2022-02-15 21:43:57 +13:00
'partitionTotal' => Storage :: human ( $deviceFiles -> getPartitionTotalSpace ()),
'partitionFree' => Storage :: human ( $deviceFiles -> getPartitionFreeSpace ()),
2020-06-30 09:43:34 +12:00
],
'cache' => [
2020-10-15 10:34:57 +13:00
'uptime' => $cacheStats [ 'uptime_in_seconds' ] ? ? 0 ,
'clients' => $cacheStats [ 'connected_clients' ] ? ? 0 ,
'hits' => $cacheStats [ 'keyspace_hits' ] ? ? 0 ,
'misses' => $cacheStats [ 'keyspace_misses' ] ? ? 0 ,
'memory_used' => $cacheStats [ 'used_memory' ] ? ? 0 ,
'memory_used_human' => $cacheStats [ 'used_memory_human' ] ? ? 0 ,
'memory_used_peak' => $cacheStats [ 'used_memory_peak' ] ? ? 0 ,
'memory_used_peak_human' => $cacheStats [ 'used_memory_peak_human' ] ? ? 0 ,
2020-06-30 09:43:34 +12:00
],
]);
2020-12-27 04:10:45 +13:00
});