All Projects → etherlabsio → Healthcheck

etherlabsio / Healthcheck

Licence: mit
An simple, easily extensible and concurrent health-check library for Go services

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Healthcheck

Health Checks Api
Standardize the way services and applications expose their status in a distributed application
Stars: ✭ 78 (-51.55%)
Mutual labels:  api, microservice, health-check
Server
Serve your Rubix ML models in production with scalable stand-alone model inference servers.
Stars: ✭ 30 (-81.37%)
Mutual labels:  api, microservice
Fusio
Open source API management platform
Stars: ✭ 946 (+487.58%)
Mutual labels:  api, microservice
Up
Up focuses on deploying "vanilla" HTTP servers so there's nothing new to learn, just develop with your favorite existing frameworks such as Express, Koa, Django, Golang net/http or others.
Stars: ✭ 8,439 (+5141.61%)
Mutual labels:  api, microservice
Kapow
Kapow! If you can script it, you can HTTP it.
Stars: ✭ 526 (+226.71%)
Mutual labels:  api, microservice
Just Api
💥 Test REST, GraphQL APIs
Stars: ✭ 768 (+377.02%)
Mutual labels:  api, microservice
Go Restful Api
An idiomatic Go REST API starter kit (boilerplate) following SOLID principles and Clean Architecture
Stars: ✭ 1,043 (+547.83%)
Mutual labels:  api, microservice
Grapi
😮 A surprisingly easy API server and generator in gRPC and Go
Stars: ✭ 364 (+126.09%)
Mutual labels:  api, microservice
Phalapi
A PHP framework foucs on API fast development.接口,从简单开始!PhalApi简称π框架,一个轻量级PHP开源接口框架,专注于接口服务开发。
Stars: ✭ 1,365 (+747.83%)
Mutual labels:  api, microservice
Kardia
A humane service status API module to expose any operational/internals of any Node.js based microservice. JSON format over HTTP protocol.
Stars: ✭ 70 (-56.52%)
Mutual labels:  microservice, health-check
Gearbox
Gearbox ⚙️ is a web framework written in Go with a focus on high performance
Stars: ✭ 455 (+182.61%)
Mutual labels:  api, microservice
Appkernel
API development made easy: a smart Python 3 API framework
Stars: ✭ 152 (-5.59%)
Mutual labels:  api, microservice
Typescript Rest
This is a lightweight annotation-based expressjs extension for typescript.
Stars: ✭ 458 (+184.47%)
Mutual labels:  api, microservice
Graphiti
Stylish Graph APIs
Stars: ✭ 783 (+386.34%)
Mutual labels:  api, microservice
Awesome Ocelot
A curated list of awesome ocelot books, courses, trainings, conference talks, blogs and most inspiring open source contributors
Stars: ✭ 386 (+139.75%)
Mutual labels:  api, microservice
Altair
Lightweight and Robust API Gateway written in Go
Stars: ✭ 34 (-78.88%)
Mutual labels:  api, microservice
Laravel5 Jsonapi
Laravel 5 JSON API Transformer Package
Stars: ✭ 313 (+94.41%)
Mutual labels:  api, microservice
Kanary
A minimalist web framework for building REST APIs in Kotlin/Java.
Stars: ✭ 319 (+98.14%)
Mutual labels:  api, microservice
Graphql Microservices
Showcasing a graphql microservice setup
Stars: ✭ 68 (-57.76%)
Mutual labels:  api, microservice
Symfony Jsonapi
JSON API Transformer Bundle for Symfony 2 and Symfony 3
Stars: ✭ 114 (-29.19%)
Mutual labels:  api, microservice

Healthcheck

Build Status Go Report Card GoDoc codecov FOSSA Status

A simple and extensible RESTful Healthcheck API implementation for Go services.

Health provides an http.Handlefunc for use as a healthcheck endpoint used by external services or load balancers. The function is used to determine the health of the application and to remove unhealthy application hosts or containers from rotation.

Instead of blindly returning a 200 HTTP status code, a healthcheck endpoint should test all the mandatory dependencies that are essential for proper functioning of a web service.

Implementing the Checker interface and passing it on to healthcheck allows you to test the the dependencies such as a database connection, caches, files and even external services you rely on. You may choose to not fail the healthcheck on failure of certain dependencies such as external services that you are not always dependent on.

Example

package main

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

    "github.com/etherlabsio/healthcheck"
    "github.com/etherlabsio/healthcheck/checkers"
    _ "github.com/go-sql-driver/mysql"
    "github.com/gorilla/mux"
)

func main() {
    // For brevity, error check is being omitted here.
    db, _ := sql.Open("mysql", "user:[email protected]/dbname")
    defer db.Close()

    r := mux.NewRouter()
    r.Handle("/healthcheck", healthcheck.Handler(

        // WithTimeout allows you to set a max overall timeout.
        healthcheck.WithTimeout(5*time.Second),

        // Checkers fail the status in case of any error.
        healthcheck.WithChecker(
            "heartbeat", checkers.Heartbeat("$PROJECT_PATH/heartbeat"),
        ),

        healthcheck.WithChecker(
            "database", healthcheck.CheckerFunc(
                func(ctx context.Context) error {
                    return db.PingContext(ctx)
                },
            ),
        ),

        // Observers do not fail the status in case of error.
        healthcheck.WithObserver(
            "diskspace", checkers.DiskSpace("/var/log", 90),
        ),
    ))

    http.ListenAndServe(":8080", r)
}

Based on the example provided above, curl localhost:8080/healthcheck | jq should yield on error a response with an HTTP statusCode of 503.

{
  "status": "Service Unavailable",
  "errors": {
    "database": "dial tcp 127.0.0.1:3306: getsockopt: connection refused",
    "heartbeat": "heartbeat not found. application should be out of rotation"
  }
}

License

This project is licensed under the terms of the MIT license. See the LICENSE file.

FOSSA Status

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].