jackdpeterson / status-aware
此包已被放弃,不再维护。未建议替代包。
返回底层服务的聚合状态和一些调试信息。适用于API仪表板。
此包尚未发布版本,信息较少。
README
报告服务及其子组件状态的方法。
此模块的总体目标是使报告API子组件状态对开发者友好且非侵入性。预计此模块提供的数据的主要消费者将是用户友好的仪表板或Pingdom等服务。
稳定性说明
此模块尚未准备好投入生产。虽然可能没有重大问题...但尚未编写单元测试。也没有在实际使用此模块时解决边缘情况。
安装
composer.json需求部分
"jackdpeterson/status-aware" : "dev-master"
编辑config/application.config.php
return array (
'modules' => array(
...
'StatusAware'
...
)
);
提供状态数据
- 创建一个实现StatusAware\StatusInterface接口的类。
- 确定如何检查要检查的组件的状态(例如,带有失败处理超时的CURL调用)
- 返回一个数组,如下所示
public function getServiceStatus() {
return array(
'name' => 'something identifiable',
'is_critical' => true,
'status' => 'up',
'message' => ''
);
}
响应数组中的保留字段及其格式
'name' => (string) that helps you identify the service/component in question
'status' => (string) 'up','down','degraded'
'is_critical' => (boolean) Is this functionality critical to your API? If down then the overall status will be 'down'.
'message' => '' => if 'up', the message is expected to be blank, ''. Otherwise it is assumed that you will provide a useful debugging message about the condition of soft-failure or hard-failure.
提供附加状态数据
您当然可以在getServiceStatus()数组中提供更多信息,如堆栈跟踪...只要将数据作为字符串类型传递。
获取状态数据
对/status执行HTTP GET请求将返回关于状态的数据。
重要且值得再次强调
在响应上设置超时并处理异常。否则,如果某些服务故障...这可能不会返回任何内容!