Documentation
¶
Index ¶
- func Must(check gosundheit.Check, err error) gosundheit.Check
- func NewHTTPCheck(config HTTPCheckConfig) (check gosundheit.Check, err error)
- func NewHostResolveCheck(host string, minRequiredResults int) gosundheit.Check
- func NewPingCheck(name string, pinger Pinger) (gosundheit.Check, error)
- func NewResolveCheck(lookupFn LookupFunc, resolveThis string, minRequiredResults int) gosundheit.Check
- type BodyProvider
- type CustomCheck
- type HTTPCheckConfig
- type LookupFunc
- type PingContextFunc
- type Pinger
- type RequestOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Must ¶ added in v0.0.10
func Must(check gosundheit.Check, err error) gosundheit.Check
Must is a helper that wraps a call to a function returning (gosundheit.Check, error) and panics if the error is non-nil. It is intended for use in check initializations such as
c := checks.Must(checks.NewHTTPCheck(/*...*/))
func NewHTTPCheck ¶
func NewHTTPCheck(config HTTPCheckConfig) (check gosundheit.Check, err error)
NewHTTPCheck creates a new http check defined by the given config
func NewHostResolveCheck ¶ added in v0.0.5
func NewHostResolveCheck(host string, minRequiredResults int) gosundheit.Check
NewHostResolveCheck returns a gosundheit.Check that makes sure the provided host can resolve to at least `minRequiredResults` IP address within the timeout specified by the provided context..
func NewPingCheck ¶ added in v0.0.9
func NewPingCheck(name string, pinger Pinger) (gosundheit.Check, error)
NewPingCheck returns a Check that pings using the specified Pinger and fails on context cancellation or ping failure
func NewResolveCheck ¶ added in v0.0.5
func NewResolveCheck(lookupFn LookupFunc, resolveThis string, minRequiredResults int) gosundheit.Check
NewResolveCheck returns a gosundheit.Check that makes sure the `resolveThis` arg can be resolved using the `lookupFn` to at least `minRequiredResults` result, within the timeout specified by the provided context.
Types ¶
type BodyProvider ¶ added in v0.2.0
BodyProvider allows the users to provide a body to the HTTP checks. For example for posting a payload as a check.
type CustomCheck ¶
type CustomCheck struct { // CheckName s the name of the check. CheckName string // CheckFunc is a function that runs a single time check, and returns an error when the check fails, and an optional details object. CheckFunc func(ctx context.Context) (details interface{}, err error) }
CustomCheck is a simple Check implementation if all you need is a functional check
func (*CustomCheck) Execute ¶
func (check *CustomCheck) Execute(ctx context.Context) (details interface{}, err error)
Execute runs the given Checkfunc, and return it's output.
func (*CustomCheck) Name ¶
func (check *CustomCheck) Name() string
Name is the name of the check. Check names must be metric compatible.
type HTTPCheckConfig ¶
type HTTPCheckConfig struct { // CheckName is the health check name - must be a valid metric name. // CheckName is required CheckName string // URL is required valid URL, to be called by the check URL string // Method is the HTTP method to use for this check. // Method is optional and defaults to `GET` if undefined. Method string // Body is an optional request body to be posted to the target URL. Body BodyProvider // ExpectedStatus is the expected response status code, defaults to `200`. ExpectedStatus int // ExpectedBody is optional; if defined, operates as a basic "body should contain <string>". ExpectedBody string // Client is optional; if undefined, a new client will be created using "Timeout". Client *http.Client // Timeout is the timeout used for the HTTP request, defaults to "1s". Timeout time.Duration // Options allow you to configure the HTTP request with arbitrary settings, e.g. add request headers, etc. Options []RequestOption }
HTTPCheckConfig configures a check for the response from a given URL. The only required field is `URL`, which must be a valid URL.
type LookupFunc ¶ added in v0.0.5
LookupFunc is a function that is used for looking up something (in DNS) and return the resolved results count, and a possible error
func NewHostLookup ¶ added in v0.0.5
func NewHostLookup(resolver *net.Resolver) LookupFunc
NewHostLookup creates a LookupFunc that looks up host addresses
type PingContextFunc ¶ added in v0.0.9
PingContextFunc type is an adapter to allow the use of ordinary functions as Pingers.
func NewDialPinger ¶ added in v0.0.9
func NewDialPinger(network, address string) PingContextFunc
NewDialPinger returns a Pinger that pings the specified address
func (PingContextFunc) PingContext ¶ added in v0.0.9
func (f PingContextFunc) PingContext(ctx context.Context) error
PingContext calls f(ctx).
type Pinger ¶ added in v0.0.9
Pinger verifies a resource is still alive. This would normally be a TCP dial check, a db.PingContext() or something similar.
type RequestOption ¶ added in v0.0.8
RequestOption configures the request with arbitrary settings, e.g. add request headers, etc.