Skip to content

brpaz/go-healthcheck

Repository files navigation

Go Healthcheck

A Golang library that provides Healthchecks for your Go Application.

Go version Go Report Card CI status Coverage Status License: MIT Documentation

🎯 Features

  • Built-in Healthchecks that covers the monitoring of the most common use cases, like databases, HTTP endpoints, Redis, Disk space, and more. Check the list of available checks.
  • Built-in HTTP handler compatible with the native http package that constructs the Healthcheck endpoint following the RFC Healthcheck specification.
  • Implement your own custom Healthchecks easily by implementing a simple interface.
  • No external dependencies.

🚀 Getting Started

Installation

go get -u github.com/brpaz/go-healthcheck/v2

Basic Usage

To use the library, simply create a new instance of the Healthcheck service, add your desired checks, and expose the healthcheck endpoint using the provided HTTP handler.

package main

import (
  "net/http"

  "github.com/brpaz/go-healthcheck/v2"
  "github.com/brpaz/go-healthcheck/v2/checks/mockcheck"
)

func main() {
  // Create your healthchecks.
  check1 := mockcheck.NewCheck(
      mockcheck.WithName("my-check"),
      mockcheck.WithStatus(checks.StatusPass),
  )

  hc := healthcheck.New(
    healthcheck.WithServiceID("my-service"),
    healthcheck.WithDescription("My Service"),
    healthcheck.WithVersion("1.0.0"),
    healthcheck.WithReleaseID("1.0.0-SNAPSHOT"),
    healthcheck.WithChecks(mycheck),
  )

  http.HandleFunc("/health", healthcheck.HealthHandler(hc))
  http.ListenAndServe(":8080", nil)
}

For more information about this package and how to use the provided checks, refer to the Documentation.

🤝 Contributing

All contributions are welcome! Please read the CONTRIBUTING file for details on how to contribute.

🫶 Support

If you find this project helpful and would like to support its development, there are a few ways you can contribute:

Sponsor me on GitHub

Buy Me A Coffee

🧑‍🦱 Contacts

🗒️ License

This project is licensed under the MIT License - see the LICENSE file for details.

🔗 Reference

About

A Golang library that provides Healthchecks for your Go Application.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •  

Languages