docnet/matt-client
最新稳定版本:v1.2.0
Composer 安装命令:
composer require docnet/matt-client
包简介
PHP Client for MATT (Monitor All The Things) notifications
关键字:
README 文档
README
This is a trivial PHP client (one class with a fluent interface) that helps you to monitor success or failure of stuff.
One thing that is often overlooked when writing crons and other regular processes is health monitoring. This usually takes the form of "Oh my god, such-and-such a script has not run successfully for 2 weeks, help!".
Absence of Success
One key thing here is that this system looks for the absence of a success message. So, if your cron starts hitting a Fatal error, this will tell you. Regular "log/email" stuff in a script will not even get hit.
Getting Started
When you need to know if some regular process stops working, do something like this at the end of your script (when you know the job is done to satisfaction)
Docnet\MATT::expect('My cron finished OK')->every('15m')->sms('07777123456');
If something should never happen, do this (perhaps in the main 'catch' block)
Docnet\MATT::expect('Some horrible error')->never()->email('bill@microsoft.com');
Install with Composer
Here's the require line for Composer users...
"docnet/matt-client": "dev-master"
No set-up required
You don't need to go and set up monitors in a web interface or anything. The first time you make a call (as above) the server will start watching.
You'll get a single set up message too, on first call for a unique event reference.
Named recipients
You can used named targets and groups that have been set up too, so in this example 'support' means several people
Docnet\MATT::expect('Some other horrible error')->never()->email('support');
At the time of writing, named recipients must be set up by the author.
Event Names
The expect() singleton factory method takes an event name/identifier as a parameter. These are limited to 32 characters and will be truncated.
We trigger a E_USER_WARNING when we do this.
Intervals
The every() method take a string parameter to represent intervals. Supported interval strings are one of
- minute
- hour
- day
- week
- month
OR, one of the following time representations, where N is a number
- Nm
- Nh
- Nd
Changing Intervals
If you start off with
Docnet\MATT::expect('My cron finished OK')->every('5m')->sms('07777123456');
And then decide you want to change the interval, just change the value you are passing to every(), like this:
Docnet\MATT::expect('My cron finished OK')->every('15m')->sms('07777123456');
The system will update it's watch interval automatically for you, and send you another confirmation message.
Alert Frequency
MATT will send you alerts once every skipped interval.
So, a failed cron due to run once per hour will send you alerts once per hour until it runs successfully again.
Watch out - If you ask for an SMS every minute - you'll get one!
Monitors are HOST and DOCNET_APP_ID unique
By default, the MATT client will include your hostname as part of the request and, if defined, the DOCNET_APP_ID.
Monitors are unique to host+app_id pairs.
This means a monitor for "Google feed uploaded OK" can run and each client check will be independent of each other.
If you need to override the hostname, you can use the from() method as follows (but watch overlap with development).
Docnet\MATT::expect('Clustered cron')->from('cluster')->every('hour')->email('support');
Cancellation (stop monitoring)
If you need to stop the server monitoring a particular event, use cancel() like this
MATT::expect('Some other horrible error')->cancel();
The system will notify current SMS and EMAIL recipients of the cancellation.
Silent watching/cancelling
If you need to suppress the "Now watching..." and "Stopped watching..." messages, use suppress_watch_message() like this
Docnet\MATT::expect('Clustered cron')->from('cluster')->every('hour')->email('support')->suppress_watch_message(); Docnet\MATT::expect('Clustered cron')->cancel()->suppress_watch_message();
API calls over HTTPS with PHP Streams
As we don't know what sort of platforms we are going to be deployed on to, we don't use Curl in case it's not installed.
So, API calls are made over HTTPS using PHP native Streams and associated context options. If HTTPS using PHP native Streams fails and Curl is available, the API call will be attempted via Curl
API calls are made on __destruct() of each MATT instance. If the call fails, an E_USER_WARNING triggered.
If the response from the server includes a textual message, this is pushed out with an E_USER_NOTICE.
PHP Version Support
Desired compatibility with PHP 5.3.0 and above.
Coding Standards
Desired adherence to PSR-2.
docnet/matt-client 适用场景与选型建议
docnet/matt-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.19k 次下载、GitHub Stars 达 4, 最近一次更新时间为 2014 年 08 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「notifications」 「docnet」 「matt」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 docnet/matt-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 docnet/matt-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 docnet/matt-client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova package that adds a notification feed in your Nova app.
Rapport
Simple framework for building HTTP JSON APIs in PHP. 2.
This application provides advanced string functions beyond what Laravel itself provides.
Captures outgoing SMS notifications
Laravel package to send notifications when some exceptions are thrown.
统计信息
- 总下载量: 1.19k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2014-08-21