All Projects → hellofresh → Health Go

hellofresh / Health Go

Licence: apache-2.0
Library to provide basic healthcheck functionality to Go applications.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Health Go

Android Kubernetes Blockchain
WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode. Refer to https://developer.ibm.com/patterns/category/blockchain/ for other blockchain code patterns.
Stars: ✭ 105 (-3.67%)
Mutual labels:  microservice
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+9722.02%)
Mutual labels:  open-source
Swagger Combined
Combines all swagger documents in microservices
Stars: ✭ 108 (-0.92%)
Mutual labels:  microservice
Recognizer
A authentication and user service
Stars: ✭ 106 (-2.75%)
Mutual labels:  microservice
Pdf
Simple http microservice that converts Word documents to PDF
Stars: ✭ 107 (-1.83%)
Mutual labels:  microservice
Godot
Godot Engine – Multi-platform 2D and 3D game engine
Stars: ✭ 44,556 (+40777.06%)
Mutual labels:  open-source
Surging.hero
基于Surging框架实现的权限管理系统
Stars: ✭ 105 (-3.67%)
Mutual labels:  microservice
Vircadia
Vircadia open source metaverse platform, based on the former High Fidelity Virtual Reality Platform.
Stars: ✭ 110 (+0.92%)
Mutual labels:  open-source
Laracom
Laravel FREE E-Commerce Software
Stars: ✭ 1,570 (+1340.37%)
Mutual labels:  open-source
Openitcockpit
openITCOCKPIT is an Open Source system monitoring tool built for different monitoring engines like Nagios, Naemon and Prometheus.
Stars: ✭ 108 (-0.92%)
Mutual labels:  open-source
Readyresponder
Local Incident Management System - This is used for tracking resources for Local Emergency Management
Stars: ✭ 106 (-2.75%)
Mutual labels:  open-source
Mui Treasury
A collection of ready-to-use components based on Material-UI
Stars: ✭ 1,821 (+1570.64%)
Mutual labels:  open-source
Serverless
⚡ Serverless Framework – Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more! –
Stars: ✭ 41,584 (+38050.46%)
Mutual labels:  microservice
Awesome Forensics
A curated list of awesome forensic analysis tools and resources
Stars: ✭ 1,775 (+1528.44%)
Mutual labels:  open-source
Dotnet Istanbul Microservices Demo
This is the demo application that i created for my talk 'Microservice Architecture & Implementation with Asp.Net Core' at Dotnet İstanbul Meetup Group.
Stars: ✭ 109 (+0%)
Mutual labels:  microservice
Dev Stuff
😎 Programming stuff for everyone. Collection of articles, videos about architecture, Domain Driven Design, microservices, testing etc.
Stars: ✭ 105 (-3.67%)
Mutual labels:  microservice
Micro
Asynchronous HTTP microservices
Stars: ✭ 9,987 (+9062.39%)
Mutual labels:  microservice
Android Ratingreviews
Simple star rating system bars, a view similar to the ones seen on Google Playstore. ⭐🌟✨
Stars: ✭ 110 (+0.92%)
Mutual labels:  open-source
Sentinel Golang
Sentinel Go version (Reliability & Resilience)
Stars: ✭ 1,817 (+1566.97%)
Mutual labels:  microservice
Vaadin Microservices Demo
A microservices example developed with Spring Cloud and Vaadin
Stars: ✭ 108 (-0.92%)
Mutual labels:  microservice

health-go

Go Report Card Go Doc Coverage Status

  • Exposes an HTTP handler that retrieves health status of the application
  • Implements some generic checkers for the following services:
    • RabbitMQ
    • PostgreSQL
    • Redis
    • HTTP
    • MongoDB
    • MySQL
    • gRPC
    • Memcached

Usage

The library exports Handler and HandlerFunc functions which are fully compatible with net/http.

Additionally, library exports Measure function that returns summary status for all the registered health checks, so it can be used in non-HTTP environments.

Handler

package main

import (
	"context"
	"net/http"
	"time"

	"github.com/hellofresh/health-go/v4"
	healthMysql "github.com/hellofresh/health-go/v4/checks/mysql"
)

func main() {
	// add some checks on instance creation
	h, _ := health.New(health.WithChecks(health.Config{
		Name:      "rabbitmq",
		Timeout:   time.Second * 5,
		SkipOnErr: true,
		Check: func(ctx context.Context) error {
			// rabbitmq health check implementation goes here
			return nil
		}}, health.Config{
		Name: "mongodb",
		Check: func(ctx context.Context) error {
			// mongo_db health check implementation goes here
			return nil
		},
	},
	))

	// and then add some more if needed
	h.Register(health.Config{
		Name:      "mysql",
		Timeout:   time.Second * 2,
		SkipOnErr: false,
		Check: healthMysql.New(healthMysql.Config{
			DSN: "test:[email protected](0.0.0.0:31726)/test?charset=utf8",
		}),
	})

	http.Handle("/status", h.Handler())
	http.ListenAndServe(":3000", nil)
}

HandlerFunc

package main

import (
	"context"
	"net/http"
	"time"

	"github.com/go-chi/chi"
	"github.com/hellofresh/health-go/v4"
	healthMysql "github.com/hellofresh/health-go/v4/checks/mysql"
)

func main() {
	// add some checks on instance creation
	h, _ := health.New(health.WithChecks(health.Config{
		Name:      "rabbitmq",
		Timeout:   time.Second * 5,
		SkipOnErr: true,
		Check: func(ctx context.Context) error {
			// rabbitmq health check implementation goes here
			return nil
		}}, health.Config{
		Name: "mongodb",
		Check: func(ctx context.Context) error {
			// mongo_db health check implementation goes here
			return nil
		},
	},
	))

	// and then add some more if needed
	h.Register(health.Config{
		Name:      "mysql",
		Timeout:   time.Second * 2,
		SkipOnErr: false,
		Check: healthMysql.New(healthMysql.Config{
			DSN: "test:[email protected](0.0.0.0:31726)/test?charset=utf8",
		}),
	})

	r := chi.NewRouter()
	r.Get("/status", h.HandlerFunc)
	http.ListenAndServe(":3000", nil)
}

For more examples please check here

API Documentation

GET /status

Get the health of the application.

  • Method: GET
  • Endpoint: /status
  • Request:
curl localhost:3000/status
  • Response:

HTTP/1.1 200 OK

{
  "status": "OK",
  "timestamp": "2017-01-01T00:00:00.413567856+033:00",
  "system": {
    "version": "go1.8",
    "goroutines_count": 4,
    "total_alloc_bytes": 21321,
    "heap_objects_count": 21323,
    "alloc_bytes": 234523
  }
}

HTTP/1.1 200 OK

{
  "status": "Partially Available",
  "timestamp": "2017-01-01T00:00:00.413567856+033:00",
  "failures": {
    "rabbitmq": "Failed during rabbitmq health check"
  },
  "system": {
    "version": "go1.8",
    "goroutines_count": 4,
    "total_alloc_bytes": 21321,
    "heap_objects_count": 21323,
    "alloc_bytes": 234523
  }
}

HTTP/1.1 503 Service Unavailable

{
  "status": "Unavailable",
  "timestamp": "2017-01-01T00:00:00.413567856+033:00",
  "failures": {
    "mongodb": "Failed during mongodb health check"
  },
  "system": {
    "version": "go1.8",
    "goroutines_count": 4,
    "total_alloc_bytes": 21321,
    "heap_objects_count": 21323,
    "alloc_bytes": 234523
  }
}

Contributing

  • Fork it
  • Create your feature branch (git checkout -b my-new-feature)
  • Commit your changes (git commit -am 'Add some feature')
  • Push to the branch (git push origin my-new-feature)
  • Create new Pull Request

GitHub @hellofresh  ·  Medium @engineering.hellofresh

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].