Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Checker ¶
type Checker struct {
// contains filtered or unexported fields
}
A Checker can be used to provide a liveliness and readiness endpoint for your application. Use `checker.AddReadinessProbe` to add a test for readiness.
func (*Checker) AddReadinessProbe ¶
Add a probe which should be run each time the service is checked for readiness. Example:
conn, _ := grpc.Dial(...) checker.AddReadinessProbe("eventstore", health.GrpcProbe(conn))
func (*Checker) AppendHealthEndpoints ¶ added in v0.2.0
Appends `/.well-known/alive` and `/.well-known/ready` endpoints to given server mux
func (*Checker) ServeHTTPBackground ¶
Serves health endpoint in background. Calls os.Exit(1) in error. Use with defer to graceful shutdown the server. Example:
func main() { health := &Checker{} defer health.ServeHTTPBackground(":8080")() }
type GrpcStateReporter ¶
type GrpcStateReporter interface {
GetState() connectivity.State
}
Interface matching a gRPC client's state method.
type MongoStateReporter ¶ added in v0.2.1
Interface matching a mongodb client's ping method.
type NatsStateReporter ¶
type NatsStateReporter interface {
Status() nats.Status
}
Interface matching a nats client's status method.
type Probe ¶
type Probe func() error
A Probe is a health check for a service you depend on. Should return an error if the tested service is unhealthy.
func GrpcProbe ¶
func GrpcProbe(conn GrpcStateReporter) Probe
Checks a grpc connection for readiness.
Example:
cc, _ := grpc.Dial(...) checker.AddReadinessProbe("my-grpc-service", health.GrpcProbe(cc))
func HTTPProbe ¶ added in v0.2.0
Pings a http endpoint for readiness. Called endpoint should return 2xx as status. **INFO:** If you check another service using this lib, always use the `/.well-known/alive endpoint` to prevent cascading requests.
Example:
checker.AddReadinessProbe("my-http-service", health.HTTPProbe("http://my-service:8080/.well-known/alive"))
func MongoProbe ¶ added in v0.2.1
func MongoProbe(client MongoStateReporter) Probe
Checks a mongodb connection for readiness.
Example:
client, _ := mongo.Connect(ctx, options.Client().ApplyURI(uri)) checker.AddReadinessProbe("my-mongo-client", health.MongoProbe(client))
func NatsProbe ¶
func NatsProbe(conn NatsStateReporter) Probe
Checks a nats connection for readiness.
Example:
sc, _ := stan.Connect(...) checker.AddReadinessProbe("my-stan-service", health.NatsProbe(sc.NatsConn()))
func RedisPoolProbe ¶
Checks a pool of redis connection for readiness.
func VaultProbe ¶
func VaultProbe(hr VaultHealthReporter) Probe
Checks a vault connection for readiness
type VaultHealthReporter ¶
type VaultHealthReporter interface {
Health() (*vault.HealthResponse, error)
}
Interface matching a vault client's health method.