PHP code example of illuma-law / healthcheck-typesense

1. Go to this page and download the library: Download illuma-law/healthcheck-typesense library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

illuma-law / healthcheck-typesense example snippets


return [
    // Threshold in seconds before a successful request is considered 'slow' (Warning)
    'timeout_seconds' => 5,

    // Array of settings passed to the \Typesense\Client
    'client_settings' => [
        'api_key' => env('TYPESENSE_API_KEY', ''),
        'nodes' => [
            [
                'host' => env('TYPESENSE_HOST', 'localhost'),
                'port' => env('TYPESENSE_PORT', '8108'),
                'path' => env('TYPESENSE_PATH', ''),
                'protocol' => env('TYPESENSE_PROTOCOL', 'http'),
            ],
        ],
        'connection_timeout_seconds' => 2,
    ],
];

use IllumaLaw\HealthCheckTypesense\TypesenseCheck;
use Spatie\Health\Facades\Health;

Health::checks([
    TypesenseCheck::new(),
]);

use IllumaLaw\HealthCheckTypesense\TypesenseCheck;
use Spatie\Health\Facades\Health;

Health::checks([
    TypesenseCheck::new()
        ->timeout(3) // Issue a warning if the ping takes > 3 seconds
        ->clientSettings([
            'api_key' => config('scout.typesense.api_key'),
            'nodes' => [
                [
                    'host' => 'typesense.production.internal',
                    'port' => '8108',
                    'protocol' => 'http',
                ],
            ],
            'connection_timeout_seconds' => 2,
        ]),
]);

use IllumaLaw\HealthCheckTypesense\TypesenseCheck;
use Spatie\Health\Facades\Health;
use Typesense\Client;

Health::checks([
    TypesenseCheck::new()
        ->useClient(app(Client::class)),
]);
shell
php artisan vendor:publish --tag="healthcheck-typesense-config"