cms-health-project/serializable-reference-implementation
最新稳定版本:0.0.5
Composer 安装命令:
composer require cms-health-project/serializable-reference-implementation
包简介
Reference implementation of the CMS HealthCheck RFC using the \JsonSerializable interface.
README 文档
README
Introduction
This library provides an example reference implementation of the
CMS HealthCheck RFC
using the \JsonSerializable interface to avoid the usage of a
dedicated formatter or builder as it is integrated into the classes
directly.
Maintainer
This package has been created and is maintained by Stefan Bürk stefan@buerk.tech.
Installation
To use this library in your project or library, require it with:
conmposer require "cms-health-project/serializable-reference-implementation"
Usage
Build up the result structure:
$time = \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:sP', '2024-03-19T01:23:45+00:00'); $check1 = new Check('package:check-one'); $check1->addCheckResults( new CheckResult( 'check1-component1', 'system', CheckResultStatus::Pass, $time, ), ); $check2 = new Check('package:check-two'); $check2->addCheckResults( new CheckResult( 'check2-component1', 'system', CheckResultStatus::Fail, $time, 'observed-value', 'with-unit', 'and-output' ), ); $checks = new CheckCollection(); $checks->addCheck($check1, $check2); $healthCheck = new HealthCheck( HealthCheckStatus::Fail, '1', 'service-id', 'description', $checks, );
and than simply use json_encode() to create the json:
$json = \json_encode($healthCheck, JSON_THROW_ON_ERROR | JSON_PRETTY_PRINT);
and you get the json, for example:
{
"status": "fail",
"version": "1",
"serviceId": "service-id",
"description": "description",
"checks": {
"package:check-one": [
{
"componentId": "check1-component1",
"componentType": "system",
"status": "pass",
"time": "2024-03-19T01:23:45+00:00"
}
],
"package:check-two": [
{
"componentId": "check2-component1",
"componentType": "system",
"status": "fail",
"time": "2024-03-19T01:23:45+00:00",
"output": "and-output",
"observedValue": "observed-value",
"observedUnit": "with-unit"
}
]
}
}
Contribution
This package contains for now only a cgl check based on php-cs-fixer.
composer install
composer cgl:fix
统计信息
- 总下载量: 93
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-16