cego / service-health-checking
A package containing a generic health check endpoint designed with expansion in mind
Installs: 25 992
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 8
Forks: 0
Open Issues: 1
Requires
- php: ^7.4|^8.0
- ext-json: *
- illuminate/http: ^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- cego/php-cs-fixer: ^2.0.0
- cego/phpstan: ^2.0.0
- cego/request-insurance: ^1.0.0
- orchestra/testbench: ^9.0
- phpunit/phpunit: ^11.0
- dev-main
- 1.1.0
- 1.0.0
- 0.6.0
- 0.5.5
- 0.5.4
- 0.5.3
- 0.5.2
- 0.5.1
- 0.5.0
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.6
- 0.2.5
- 0.2.4
- 0.2.3
- 0.2.2
- 0.2.1
- 0.2.0
- 0.1.1
- 0.1.0
- dev-renovate/configure
- dev-thwo/guzzle-security-vulnerability
- dev-nbj/prepare-for-laravel-10
- dev-thwo/randomize-cache-check-key
- dev-thwo/more-informative-about-ri-thresholds
- dev-thwo/handle-exceptions
- dev-set-active-limit-1k
- dev-niza/bump-package-versions-to-laravel9
- dev-thwo/use-config-facade
- dev-thwo/merge-config
This package is auto-updated.
Last update: 2024-12-15 10:54:08 UTC
README
This package contains core functionality for HTTP health checking of Laravel services.
Usage
When the package is installed, a health endpoint, /vendor/service-health-checking
is exposed. The endpoint
returns 200 OK
and a body with a JSON data object with the following format:
{ "status": "pass|warn|fail", "checks": [ { "status": "pass|warn|fail", "name": "HealthCheckClassName", "description": "Description defined in the health check class", "message": "Message set in the HealthStatus object" } ] }
The checks
array contains an entry for each registered health check.
Creating health checks
To create a health check for your service, simply create a class that extends
\Cego\ServiceHealthChecking\BaseHealthCheck
. The base method has 2 abstract methods:
check(): HealthStatus
should perform the check and return aHealthStatus
object.getDescription(): string
should return a description of the health check.
Registering health checks
Firstly, publish the package assets by running:
php artisan vendor:publish --provider="Cego\ServiceHealthChecking\ServiceHealthCheckingServiceProvider"
The package will publish a config file, service-health-checking.php
, in which health check classes must be
registered, in order for them to run. The package is shipped with a basic database connection check, which is registered
by default.