Go package healthcheck
provides a 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/http
viagithub.com/nijeti/healthcheck/servers/http
fasthttp
viagithub.com/nijeti/healthcheck/servers/fasthttp
- Ready to be integrated with any other server of choice
go get github.com/nijeti/healthcheck
go get github.com/nijeti/healthcheck/servers/http
go get github.com/nijeti/healthcheck/servers/fasthttp
Here 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 has successfully integrated Healthcheck:
This project is licensed under the Apache-2.0 License.