health check middleware for Echo web framework
type redisResource struct {
*redis.Client
}
func (r redisResource) HealthCheck() error {
return r.Client.Ping().Err()
}
func main() {
// ...
e := echo.New()
e.Use(health.New(redisResource{Client: redisClient}))
// ...
}
For HTTP service, liveness and readiness should be identical.
curl http://127.0.0.1:1234/_health
This will check all resources with HealthCheck()
method
canhead hi@canhead.xyz MIT License