github.com/bufbuild/connect-grpchealth-go@v1.1.1/README.md (about) 1 connect-grpchealth-go 2 ===================== 3 4 [](https://github.com/bufbuild/connect-grpchealth-go/actions/workflows/ci.yaml) 5 [](https://goreportcard.com/report/github.com/bufbuild/connect-grpchealth-go) 6 [](https://pkg.go.dev/github.com/bufbuild/connect-grpchealth-go) 7 8 `connect-grpchealth-go` adds support for gRPC-style health checks to any 9 `net/http` server — including those built with [Connect][connect-go]. By 10 polling this API, load balancers, container orchestrators, and other 11 infrastructure systems can respond to changes in your HTTP server's health. 12 13 The exposed health checking API is wire compatible with Google's gRPC 14 implementations, so it works with [grpcurl], [grpc-health-probe], and 15 [Kubernetes gRPC liveness probes][k8s-liveness]. 16 17 For more on Connect, see the [announcement blog post][blog], the documentation 18 on [connect.build][docs] (especially the [Getting Started] guide for Go), the 19 [`connect-go`][connect-go] repo, or the [demo service][demo]. 20 21 ## Example 22 23 ```go 24 package main 25 26 import ( 27 "net/http" 28 29 "golang.org/x/net/http2" 30 "golang.org/x/net/http2/h2c" 31 grpchealth "github.com/bufbuild/connect-grpchealth-go" 32 ) 33 34 func main() { 35 mux := http.NewServeMux() 36 checker := grpchealth.NewStaticChecker( 37 "acme.user.v1.UserService", 38 "acme.group.v1.GroupService", 39 // protoc-gen-connect-go generates package-level constants 40 // for these fully-qualified protobuf service names, so you'd more likely 41 // reference userv1.UserServiceName and groupv1.GroupServiceName. 42 ) 43 mux.Handle(grpchealth.NewHandler(checker)) 44 // If you don't need to support HTTP/2 without TLS (h2c), you can drop 45 // x/net/http2 and use http.ListenAndServeTLS instead. 46 http.ListenAndServe( 47 ":8080", 48 h2c.NewHandler(mux, &http2.Server{}), 49 ) 50 } 51 ``` 52 53 ## Status: Stable 54 55 This module is stable. It supports: 56 57 * The [two most recent major releases][go-support-policy] of Go. 58 * [APIv2] of Protocol Buffers in Go (`google.golang.org/protobuf`). 59 60 Within those parameters, `connect-grpchealth-go` follows semantic versioning. 61 We will _not_ make breaking changes in the 1.x series of releases. 62 63 ## Legal 64 65 Offered under the [Apache 2 license][license]. 66 67 [APIv2]: https://blog.golang.org/protobuf-apiv2 68 [Getting Started]: https://connect.build/go/getting-started 69 [blog]: https://buf.build/blog/connect-a-better-grpc 70 [connect-go]: https://github.com/bufbuild/connect-go 71 [demo]: https://github.com/bufbuild/connect-demo 72 [docs]: https://connect.build 73 [docs]: https://connect.build 74 [go-support-policy]: https://golang.org/doc/devel/release#policy 75 [grpc-health-probe]: https://github.com/grpc-ecosystem/grpc-health-probe/ 76 [grpcurl]: https://github.com/fullstorydev/grpcurl 77 [k8s-liveness]: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/#define-a-grpc-liveness-probe 78 [license]: https://github.com/bufbuild/connect-grpchealth-go/blob/main/LICENSE.txt