Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
Func represents a health check that returns an error when the resource is unavailable.
func NewDBPingProbe ¶
NewDBPingProbe creates a Func that pings databases such as PostgreSQL using the provided client.
func NewHTTPProbe ¶
NewHTTPProbe creates a Func that performs an HTTP request against the supplied endpoint. The probe succeeds when the response status code is within the 2xx range.
func NewMongoPingProbe ¶
func NewMongoPingProbe(client MongoPinger, readPref *readpref.ReadPref) Func
NewMongoPingProbe creates a Func that pings MongoDB using the provided client. If readPref is nil it defaults to readpref.Primary.
func NewPingProbe ¶
NewPingProbe wraps a PingFunc with standardised error handling suitable for InfoHandler probes.
Example ¶
package main
import (
"context"
"fmt"
"github.com/drblury/apiweaver/probe"
)
func main() {
probeFunc := probe.NewPingProbe("noop", func(ctx context.Context) error {
return nil
})
fmt.Println(probeFunc(context.Background()))
}
Output: <nil>
type MongoPinger ¶
MongoPinger captures the subset of the MongoDB client used for readiness checks.