Track health of various dependencies - golang

Test

Background

This package helps setup health check based on status of external dependencies. The idea is to add all external dependencies like database, queue connections etc, and based on their status, the health handler will return 500 or 200 response with details about all the dependencies.

Installation

go get github.com/daveamit/health@latest

Limitation

Current implementation maintains everything in default instance of healthImpl as this package is intended to be used as singleton instance. But if there are use cases where I need to expose API such that health interface and newHealth are make public and provide added api to setup registry and do various customization for prometheus

Usage

package main

import "github.com/daveamit/health"

func main() {
    // Register a dep
    health.EnsureService("posgtres", "default")


    // postgresConn is a hypothetical function, assume that it return
    // a valid pg connection on sucess and err on failure.
    pg, err := postgresConn()

    if err != nil {
        // tell the package that `postgres` service is connected and usable.
        health.ServiceUp("postgres", "default")
    } else {
        health.ServiceDown("postgres", "default")
    }

    // so something with the pg connection
    ...
    ...
    ...

    // serve prom and health endpoints @ 8000 port
    http.Handle("/prom", health.PrometheusScrapHandler())
    http.Handle("/health", health.HealthCheckHandler())
    http.ListenAndServe(":8000", nil)
}
Similar Resources

[TOOL, CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations.

typex Examine Go types and their transitive dependencies. Export results as TypeScript value objects (or types) declaration. Installation go get -u gi

Dec 6, 2022

Give your dependencies stars on GitHub! 🌟

Give stars to your dependencies of Go repositories and say thank you to developers!!

May 29, 2022

Easily create & extract archives, and compress & decompress files of various formats

archiver Introducing Archiver 3.1 - a cross-platform, multi-format archive utility and Go library. A powerful and flexible library meets an elegant CL

Jan 7, 2023

Fast conversions across various Go types with a simple API.

Go Package: conv Get: go get -u github.com/cstockton/go-conv Example: // Basic types if got, err := conv.Bool(`TRUE`); err == nil { fmt.Printf("conv.

Nov 29, 2022

Convert various benchmarking formats to benchfmt

benchfmt-convert This repo contains tools for converting various formats to benchfmt for use with benchstat. Most useful is github.com/prattmic/benchf

Sep 17, 2021

This repository provides various utilities to help you build your NFT collection!

Attention! A powerful computer may be required! About This repository provides various utilities to help you build your NFT collection: Generate image

Nov 4, 2022

Gosfdc module - a collection of packages containing the data structures from the various Salesforce APIs and Tools

Gosfdc module - a collection of packages containing the data structures from the various Salesforce APIs and Tools

Jan 21, 2022

Various Dungeons and Dragons Tools. Written in go as an aid to learning the language.

dnd_tools Various Dungeons and Dragons Tools. Written in go as an aid to learning the language. Some tools are generic, while others will target eithe

Jan 28, 2022

This is a demo of various bursavich.dev packages.

Demo This provides a demo of various bursavich.dev packages. See the frontend command for a unified usage example, from which the following sample met

Feb 10, 2022
Related tags
⛑ Gatus - Automated service health dashboard
⛑ Gatus - Automated service health dashboard

A service health dashboard in Go that is meant to be used as a docker image with a custom configuration file. I personally deploy it in my Kubernetes

Dec 31, 2022
An easy to use, extensible health check library for Go applications.

Try browsing the code on Sourcegraph! Go Health Check An easy to use, extensible health check library for Go applications. Table of Contents Example M

Dec 30, 2022
An simple, easily extensible and concurrent health-check library for Go services
An simple, easily extensible and concurrent health-check library for Go services

Healthcheck A simple and extensible RESTful Healthcheck API implementation for Go services. Health provides an http.Handlefunc for use as a healthchec

Dec 30, 2022
Render health ECG (electrocardiogram) animation
Render health ECG (electrocardiogram) animation

HealthECG Render health ECG (electrocardiogram) animation About This program shows how the health ECG animation was implemented in the original Reside

Jan 6, 2022
keep track of things you learn / discover everyday!
keep track of things you learn / discover everyday!

?? Personal Archive Personal-Archive keeps track of things you learn / discover everyday! ?? Why I face tons of articles every day. Via googling or RS

May 23, 2022
An application to track my net worth

retire-early A summer holiday project to track my net worth and also learn Go. Inspired by a Programmer's Guide to Saving, Investing, and Retiring Ear

Aug 14, 2022
You could leverage Alfred and Google Sheets to track your time with ease.
You could leverage Alfred and Google Sheets to track your time with ease.

You could leverage Alfred and Google Sheets to track your time with ease. The goal is to track your time in a way that is easy to understand how much time you spend on.

Dec 25, 2022
Bird Watcher on Exercism's Go Track

Bird Watcher Welcome to Bird Watcher on Exercism's Go Track. If you need help ru

Dec 30, 2021
Solutions to Exercism's Go track

Exercism Go Track Running the tests To run the tests run the command go test from within the exercise directory. If the test suite contains benchmarks

May 19, 2022
GoThanks automatically stars Go's official repository and your go.mod github dependencies, providing a simple way to say thanks to the maintainers of the modules you use and the contributors of Go itself.
GoThanks automatically stars Go's official repository and your go.mod github dependencies, providing a simple way  to say thanks to the maintainers of the modules you use and the contributors of Go itself.

Give thanks (in the form of a GitHub ★) to your fellow Go modules maintainers. About GoThanks performs the following operations Sends a star to Go's r

Dec 24, 2022