1 Star 0 Fork 0

h79/goutils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
health.go 781 Bytes
一键复制 编辑 原始数据 按行查看 历史
huqiuyun 提交于 2022-10-20 17:31 . config path
package server
import (
"gitee.com/h79/goutils/common/config"
"gitee.com/h79/goutils/common/json"
"time"
)
const (
GHealthTtl = 10
KGRpcProtocol = "grpc"
KHttpProtocol = "http"
KTCPProtocol = "tcp"
)
type Health struct {
URL Address `json:"url"`
Method string `json:"method"`
Protocol string `json:"protocol"`
Ttl bool `json:"ttl"`
Interval time.Duration `json:"interval"` //(second)
SuccessStatus int `json:"successStatus"`
}
func ReadHealth(filename string) (Health, error) {
if len(filename) == 0 {
filename = config.FileNameInEnvPath("healthcheck.json")
}
health := Health{
Ttl: true,
Interval: GHealthTtl}
err := json.Read(filename, &health)
return health, err
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/h79/goutils.git
git@gitee.com:h79/goutils.git
h79
goutils
goutils
v1.6.11

搜索帮助

A270a887 8829481 3d7a4017 8829481