1 Star 1 Fork 0

kade/library

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
ioc.go 944 Bytes
一键复制 编辑 原始数据 按行查看 历史
kade 提交于 2024-06-20 11:13 . v2.0.0 ioc 整体优化
package gin
import (
"gitee.com/go-kade/library/ioc"
ioc_health "gitee.com/go-kade/library/ioc/apps/health"
"gitee.com/go-kade/library/ioc/config/log"
"github.com/rs/zerolog"
"google.golang.org/grpc/health"
healthgrpc "google.golang.org/grpc/health/grpc_health_v1"
)
func init() {
ioc.Api().Registry(&HealthChecker{
HealthCheck: ioc_health.HealthCheck{
Path: ioc_health.DEFAUL_HEALTH_PATH,
},
})
}
type HealthChecker struct {
ioc.ObjectImpl
ioc_health.HealthCheck
log *zerolog.Logger
Service healthgrpc.HealthServer `ioc:"autowire=true;namespace=controllers"`
}
func (h *HealthChecker) Name() string {
return ioc_health.AppName
}
func (h *HealthChecker) Init() error {
if h.Service == nil {
h.Service = health.NewServer()
}
h.log = log.Sub("health_check")
h.Registry()
return nil
}
func (h *HealthChecker) Meta() ioc.ObjectMeta {
meta := ioc.DefaultObjectMeta()
meta.CustomPathPrefix = h.Path
return meta
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/go-kade/library.git
git@gitee.com:go-kade/library.git
go-kade
library
library
v1.3.8

搜索帮助