Go package healthcheck provides simple yet very convenient application health checking tools.
- Lightweight and easy to integrate
- Supports custom health check functions
- Has ready-to-run support for the 2 most popular Go HTTP servers:
net/httpviagithub.com/nijeti/healthcheck/servers/httpfasthttpviagithub.com/nijeti/healthcheck/servers/fasthttp
- Ready to be integrated with any other server of choice
go get github.com/nijeti/healthcheckgo get github.com/nijeti/healthcheck/servers/httpgo get github.com/nijeti/healthcheck/servers/fasthttpHere is an example of how to use the healthcheck library with the standard HTTP server:
package main
import (
"context"
"time"
"github.com/nijeti/healthcheck"
"github.com/nijeti/healthcheck/servers/http"
)
func main() {
// Create a new health checker
healthchecker := healthcheck.New(
healthcheck.WithSimpleProbe(
"database", func(ctx context.Context) error {
// Perform your health check
return nil
},
),
healthcheck.WithTimeoutDegraded(1*time.Second),
healthcheck.WithTimeoutUnhealthy(10*time.Second),
)
// Set up the HTTP server for health check endpoint
healthcheckServer := http.New(
healthchecker,
http.WithAddress(":8080"),
http.WithRoute("/health"),
)
// Start the server
healthcheckServer.Start()
defer healthcheckServer.Stop()
}The following projects have successfully integrated Healthcheck:
This project is licensed under the Apache-2.0 License.