feat: bootstrap reusable GoOmni framework
This commit is contained in:
17
health/README.md
Normal file
17
health/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# 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`。
|
||||
Reference in New Issue
Block a user