2 Star 0 Fork 0

TeamsHub/backend-gopkg

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
alarm.go 661 Bytes
一键复制 编辑 原始数据 按行查看 历史
HCY 提交于 2024-05-10 12:41 . c
package httpclient
import (
"bufio"
"bytes"
"go.uber.org/zap"
)
// AlarmVerify Verify parse the body and verify that it is correct
type AlarmVerify func(body []byte) (shouldAlarm bool)
type AlarmObject interface {
Send(subject, body string) error
}
func onFailedAlarm(title string, raw []byte, logger *zap.Logger, alarmObject AlarmObject) {
buf := bytes.NewBuffer(nil)
scanner := bufio.NewScanner(bytes.NewReader(raw))
for scanner.Scan() {
buf.WriteString(scanner.Text())
buf.WriteString(" <br/>")
}
if err := alarmObject.Send(title, buf.String()); err != nil && logger != nil {
logger.Error("calls failed alarm err", zap.Error(err))
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wuzheng0709/backend-gopkg.git
git@gitee.com:wuzheng0709/backend-gopkg.git
wuzheng0709
backend-gopkg
backend-gopkg
v1.4.16

搜索帮助

0d507c66 1850385 C8b1a773 1850385