Categorygithub.com/bufbuild/connect-grpchealth-go
modulepackage
1.1.1
Repository: https://github.com/bufbuild/connect-grpchealth-go.git
Documentation: pkg.go.dev

# README

connect-grpchealth-go

Build Report Card GoDoc

connect-grpchealth-go adds support for gRPC-style health checks to any net/http server — including those built with Connect. By polling this API, load balancers, container orchestrators, and other infrastructure systems can respond to changes in your HTTP server's health.

The exposed health checking API is wire compatible with Google's gRPC implementations, so it works with grpcurl, grpc-health-probe, and Kubernetes gRPC liveness probes.

For more on Connect, see the announcement blog post, the documentation on connect.build (especially the Getting Started guide for Go), the connect-go repo, or the demo service.

Example

package main

import (
  "net/http"

  "golang.org/x/net/http2"
  "golang.org/x/net/http2/h2c"
  grpchealth "github.com/bufbuild/connect-grpchealth-go"
)

func main() {
  mux := http.NewServeMux()
  checker := grpchealth.NewStaticChecker(
    "acme.user.v1.UserService",
    "acme.group.v1.GroupService",
    // protoc-gen-connect-go generates package-level constants
    // for these fully-qualified protobuf service names, so you'd more likely
    // reference userv1.UserServiceName and groupv1.GroupServiceName.
  )
  mux.Handle(grpchealth.NewHandler(checker))
  // If you don't need to support HTTP/2 without TLS (h2c), you can drop
  // x/net/http2 and use http.ListenAndServeTLS instead.
  http.ListenAndServe(
    ":8080",
    h2c.NewHandler(mux, &http2.Server{}),
  )
}

Status: Stable

This module is stable. It supports:

Within those parameters, connect-grpchealth-go follows semantic versioning. We will not make breaking changes in the 1.x series of releases.

Legal

Offered under the Apache 2 license.

# Functions

NewHandler wraps the supplied Checker to build an HTTP handler for gRPC's health-checking API.
NewStaticChecker constructs a StaticChecker.

# Constants

HealthV1ServiceName is the fully-qualified name of the v1 version of the health service.
StatusNotServing indicates that the process is healthy but the service is not accepting requests.
StatusServing indicates that the service is ready to accept requests.
StatusUnknown indicates that the service's health state is indeterminate.

# Structs

CheckRequest is a request for the health of a service.
CheckResponse reports the health of a service (or of the whole process).
StaticChecker is a simple Checker implementation.

# Interfaces

A Checker reports the health of a service.

# Type aliases

Status describes the health of a service.