Files
go-omni/health/README.md

18 lines
514 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# health
`health` 提供与网络层无关的存活和就绪 Handler。业务项目只需要注册依赖探针,路由仍通过 `omni.App` 或项目自己的 transport 注册:
```go
checker, err := health.New(health.Probe{
Name: "database",
Check: db.PingContext,
})
if err != nil {
return err
}
app.GET("/health/live", checker.LivenessHandler())
app.GET("/health/ready", checker.ReadinessHandler())
```
就绪探针会保留每项检查结果,并在至少一项失败时返回 `503` 和 `NOT_READY`。