Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chocofamilyme/phalcon-healthcheck
https://github.com/chocofamilyme/phalcon-healthcheck
Last synced: 12 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/chocofamilyme/phalcon-healthcheck
- Owner: chocofamilyme
- Created: 2019-08-21T12:07:04.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-19T10:48:42.000Z (about 4 years ago)
- Last Synced: 2024-09-18T03:29:45.472Z (3 months ago)
- Language: PHP
- Size: 72.3 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Phalcon Health Check Library
Health Check library adds new endpoints(routes) to your project which are used to check some services of your application.
For example you want to check "Database Connection" of your microservice.# Installation
```bash
composer require chocofamilyme/phalcon-healthcheck ^1.0
```
- Example setting your application:
```php
setShared('application', $application);$container->register(new HealthCheckServiceProvider());
```
- Add above ServiceProvider class to the config config/providers.php
- Copy healthCheck.php to config/ and manage necessary configuration values for the project# Checks
- Database connection check
- Cache write&read check
- Sessions write&read check
- Storage check# Routes
- /health
```json
{
"DB": "OK",
"CACHE": "OK",
"SESSIONS": "CRITICAL",
"STORAGE": "OK"
}
```
- /health/extended
```json
{
"DB": {
"STATUS": "OK",
"STATUS_BOOL": true,
"MESSAGE": null
},
"CACHE": {
"STATUS": "OK",
"STATUS_BOOL": true,
"MESSAGE": null
},
"SESSIONS": {
"STATUS": "CRITICAL",
"STATUS_BOOL": false,
"MESSAGE": "Connection to tarantool.example.com failed"
},
"STORAGE": {
"STATUS": "OK",
"STATUS_BOOL": true,
"MESSAGE": null
}
}
```# How to write your custom checks
Create a class which implements Chocofamily\PhalconHealthCheck\Services\Checks\ComponentCheckInterface
and add it to healthcheck.php config file like
```php
return [
'componentChecks' => [
'YOURCUSTOMCHECK' => YourCustomCheck::class
]
]
```# Responses
There is a configuration param which describes which response class to use to output the response. For example
- /health - Chocofamily\PhalconHealthCheck\Responses\ChocofamilyResponse::class
output would look like this
```json
{
"data": {
"DB": "OK",
"CACHE": "OK",
"SESSIONS": "CRITICAL",
"STORAGE": "OK"
}
}
```Feel free to add your responses, if you want for example to output it in a view instead json.