36 lines
824 B
Go
36 lines
824 B
Go
|
|
// Package controller - 健康检查控制器
|
||
|
|
// 功能:服务健康状态检查接口
|
||
|
|
package controller
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
|
||
|
|
"github.com/gogf/gf/v2/frame/g"
|
||
|
|
)
|
||
|
|
|
||
|
|
var Health = new(health)
|
||
|
|
|
||
|
|
type health struct{}
|
||
|
|
|
||
|
|
// Check 健康检查
|
||
|
|
func (c *health) Check(ctx context.Context, req *HealthCheckReq) (res *HealthCheckRes, err error) {
|
||
|
|
res = &HealthCheckRes{
|
||
|
|
Status: "ok",
|
||
|
|
Service: "customerservice",
|
||
|
|
Version: "v1.0.0",
|
||
|
|
}
|
||
|
|
return
|
||
|
|
}
|
||
|
|
|
||
|
|
// HealthCheckReq 健康检查请求
|
||
|
|
type HealthCheckReq struct {
|
||
|
|
g.Meta `path:"/" method:"get" tags:"Health" summary:"健康检查" dc:"检查服务是否正常运行"`
|
||
|
|
}
|
||
|
|
|
||
|
|
// HealthCheckRes 健康检查响应
|
||
|
|
type HealthCheckRes struct {
|
||
|
|
Status string `json:"status" dc:"状态"`
|
||
|
|
Service string `json:"service" dc:"服务名称"`
|
||
|
|
Version string `json:"version" dc:"版本"`
|
||
|
|
}
|