68publishers/health-check
Composer 安装命令:
composer require 68publishers/health-check
包简介
Check the status of an application services.
README 文档
README
💗 Health check for external services that are important for your application.
Installation
The best way to install 68publishers/health-check is using Composer:
$ composer require 68publishers/health-check
Standalone usage
use SixtyEightPublishers\HealthCheck\ExportMode; use SixtyEightPublishers\HealthCheck\HealthChecker; use SixtyEightPublishers\HealthCheck\ServiceChecker\PDOServiceChecker; use SixtyEightPublishers\HealthCheck\ServiceChecker\RedisServiceChecker; $checker = new HealthChecker(); $checker->addServiceChecker(new PDOServiceChecker('pgsql:host=127.0.0.1;port=5432;dbname=example', 'user', 'password')); $checker->addServiceChecker(new RedisServiceChecker()) # check all services $result = $checker->check(); # you can throw an exception if (!$result->isOk()) { throw $result->getError(); } # or covert the result into a JSON echo json_encode($result); # check Redis only $result = $checker->check(['redis']); # check in the "Full" mode. The default mode is "Simple". $result = $checker->check(NULL, ExportMode::Full); # the result now contains detailed information about each service echo json_encode($result);
Available service checkers
- PDO -
SixtyEightPublishers\HealthCheck\ServiceChecker\PDOServiceChecker - Doctrine DBAL -
SixtyEightPublishers\HealthCheck\ServiceChecker\DbalConnectionServiceChecker - Redis -
SixtyEightPublishers\HealthCheck\ServiceChecker\RedisServiceChecker - Http -
SixtyEightPublishers\HealthCheck\ServiceChecker\HttpServiceChecker
You can create your own service checker. Just create a class that implements the interface ServiceCheckerInterface.
Integration into Nette Framework
The package provides compiler extensions for easy integration with Nette Framework.
Configuration example
extensions: 68publishers.health_check: SixtyEightPublishers\HealthCheck\Bridge\Nette\DI\HealthCheckExtension 68publishers.health_check: service_checkers: - SixtyEightPublishers\HealthCheck\ServiceChecker\RedisServiceChecker() - SixtyEightPublishers\HealthCheck\ServiceChecker\PDOServiceChecker::fromParams([ driver: pgsql host: '127.0.0.1' port: 5432 dbname: example user: user password: password ]) - MyCustomServiceChecker('foo') export_mode: full_if_debug # This is the default value. Supported values are "full_if_debug", "full", "simple" or custom service that implements an interface "ExportModeResolverInterface".
Now the service of type SixtyEightPublishers\HealthCheck\HealthCheckerInterface is accessible in DIC.
Health check using Symfony Console
extensions: 68publishers.health_check: SixtyEightPublishers\HealthCheck\Bridge\Nette\DI\HealthCheckExtension 68publishers.health_check.console: SixtyEightPublishers\HealthCheck\Bridge\Nette\DI\HealthCheckConsoleExtension
Now you can run this command:
$ bin/console health-check [<services>] [--export-mode <mode>]
Health check using Nette Application
extensions: 68publishers.health_check: SixtyEightPublishers\HealthCheck\Bridge\Nette\DI\HealthCheckExtension 68publishers.health_check.application: SixtyEightPublishers\HealthCheck\Bridge\Nette\DI\HealthCheckApplicationExtension 68publishers.health_check.application: route: '/health-check' # The default value. You can change it or set it as "false".
The extension automatically appends the health check route into your RouteList. If you want to disable this behaviour, please set the option route to false and add the route to your route factory manually e.g.:
<?php namespace App; use Nette\Application\Routers\RouteList; use SixtyEightPublishers\HealthCheck\Bridge\Nette\Application\HealthCheckRoute; class RouteFactory { public static function create(): RouteList { $router = new RouteList(); $router->add(new HealthCheckRoute('/health-check')); # ... other routes ... return $router; } }
Now you can check your services through an endpoint your-domain.com/health-check.
The endpoint returns the status code 200 if everything is ok and 503 if some service check failed.
Contributing
Before opening a pull request, please check your changes using the following commands
$ make init # to pull and start all docker images
$ make cs.check
$ make stan
$ make tests.all
68publishers/health-check 适用场景与选型建议
68publishers/health-check 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.54k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2021 年 08 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「check」 「nette」 「health」 「68publishers」 「health-check」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 68publishers/health-check 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 68publishers/health-check 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 68publishers/health-check 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Symfony bundle for chameleon-system/sanitycheck
This Extension integrates a credit check and more made by the LEONEX Risk Management Platform into your order process. Extensive configuration and evaluation options is provided in the Platform
Is your Laravel app OK? Health checks running in production to ensure you can sleep well at night and be sure everything is still OK.
Provides healthcheck endpoints in accordance with IETF's healthcheck draft RFC
Provide status and health api endpoints
SoftWax Health Check Bundle for Symfony framework
统计信息
- 总下载量: 6.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 29
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-08-06