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
}
Checker provides the possibility to register several CheckerProbe and execute them.
func (*Checker) Check ¶
func (c *Checker) Check(ctx context.Context, kind ProbeKind) *CheckerResult
Check executes all the registered probes for a ProbeKind, passes a context.Context to each of them, and returns a CheckerResult. The CheckerResult is successful if all probes executed with success.
func (*Checker) Probes ¶
func (c *Checker) Probes(kinds ...ProbeKind) []CheckerProbe
Probes returns the list of CheckerProbe registered for the provided list of ProbeKind. If no ProbeKind is provided, probes matching all kinds will be returned.
func (*Checker) RegisterProbe ¶
func (c *Checker) RegisterProbe(probe CheckerProbe, kinds ...ProbeKind) *Checker
RegisterProbe registers a CheckerProbe for an optional list of ProbeKind. If no ProbeKind is provided, the CheckerProbe will be registered for all kinds.
type CheckerFactory ¶
type CheckerFactory interface {
Create(options ...CheckerOption) (*Checker, error)
}
CheckerFactory is the interface for Checker factories.
func NewDefaultCheckerFactory ¶
func NewDefaultCheckerFactory() CheckerFactory
NewDefaultCheckerFactory returns a DefaultCheckerFactory, implementing CheckerFactory.
type CheckerOption ¶
type CheckerOption func(o *Options)
CheckerOption are functional options for the CheckerFactory implementations.
func WithProbe ¶
func WithProbe(probe CheckerProbe, kinds ...ProbeKind) CheckerOption
WithProbe is used to register a CheckerProbe for an optional list of ProbeKind. If no ProbeKind was provided, the CheckerProbe will be registered for all kinds.
type CheckerProbe ¶
type CheckerProbe interface { Name() string Check(ctx context.Context) *CheckerProbeResult }
CheckerProbe is the interface for the probes executed by the Checker.
type CheckerProbeRegistration ¶
type CheckerProbeRegistration struct {
// contains filtered or unexported fields
}
CheckerProbeRegistration represents a registration of a CheckerProbe in the Checker.
func NewCheckerProbeRegistration ¶
func NewCheckerProbeRegistration(probe CheckerProbe, kinds ...ProbeKind) *CheckerProbeRegistration
NewCheckerProbeRegistration returns a CheckerProbeRegistration, and accepts a CheckerProbe and an optional list of ProbeKind. If no ProbeKind is provided, the CheckerProbe will be registered to be executed on all kinds of checks.
func (*CheckerProbeRegistration) Kinds ¶
func (r *CheckerProbeRegistration) Kinds() []ProbeKind
Kinds returns the list of ProbeKind of the CheckerProbeRegistration.
func (*CheckerProbeRegistration) Match ¶
func (r *CheckerProbeRegistration) Match(kinds ...ProbeKind) bool
Match returns true if the CheckerProbeRegistration match any of the provided ProbeKind list.
func (*CheckerProbeRegistration) Probe ¶
func (r *CheckerProbeRegistration) Probe() CheckerProbe
Probe returns the CheckerProbe of the CheckerProbeRegistration.
type CheckerProbeResult ¶
CheckerProbeResult is the result of a CheckerProbe execution.
func NewCheckerProbeResult ¶
func NewCheckerProbeResult(success bool, message string) *CheckerProbeResult
NewCheckerProbeResult returns a CheckerProbeResult, with a probe execution status and feedback message.
type CheckerResult ¶
type CheckerResult struct { Success bool `json:"success"` ProbesResults map[string]*CheckerProbeResult `json:"probes"` }
CheckerResult is the result of a Checker check. It contains a global status, and a list of CheckerProbeResult corresponding to each probe execution.
type DefaultCheckerFactory ¶
type DefaultCheckerFactory struct{}
DefaultCheckerFactory is the default CheckerFactory implementation.
func (*DefaultCheckerFactory) Create ¶
func (f *DefaultCheckerFactory) Create(options ...CheckerOption) (*Checker, error)
Create returns a new Checker, and accepts a list of CheckerOption. For example:
checker, _ := healthcheck.NewDefaultCheckerFactory().Create( healthcheck.WithProbe(NewSomeProbe()), // registers for startup, readiness and liveness healthcheck.WithProbe(NewOtherProbe(), healthcheck.Liveness), // registers for liveness only )
type Options ¶
type Options struct {
Registrations map[string]*CheckerProbeRegistration
}
Options are options for the CheckerFactory implementations.
func DefaultCheckerOptions ¶
func DefaultCheckerOptions() Options
DefaultCheckerOptions are the default options used in the DefaultCheckerFactory.