Documentation
¶
Index ¶
Constants ¶
const UrlPathValue = "{probeType}"
UrlPathValue is the constant key used to extract the probe type from a request's URL path parameters.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cause ¶
type Cause = string
Cause is a type alias for string, often used to provide reasons or explanations within validation contexts.
const EmptyCause Cause = ""
EmptyCause represents an empty string for Cause, signifying the absence of a specific reason or explanation.
type HttpHandler ¶
type HttpHandler struct {
// contains filtered or unexported fields
}
HttpHandler serves as an HTTP handler for processing health probe requests based on the Manager's registered probes.
func NewHttpHandler ¶
func NewHttpHandler(manager *Manager) *HttpHandler
NewHttpHandler creates and returns a new instance of HttpHandler with the provided Manager.
func (*HttpHandler) ServeHTTP ¶
func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles incoming HTTP requests and returns the status of the specified health probe type.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides functionality to manage and monitor health probes for applications through a registry.
func NewManager ¶
func NewManager() *Manager
NewManager creates and returns a new instance of Manager with an initialized probe registry.
func (*Manager) CheckProbe ¶
CheckProbe checks the status of the specified health probe type and returns true if the probe passes, otherwise false.
func (*Manager) RegisterProbe ¶
func (m *Manager) RegisterProbe(probeTypo ProbeType, probe ValidityChecker)
RegisterProbe registers a health probe of the specified type with the provided state retriever in the registry.
type Probe ¶
type Probe struct {
// contains filtered or unexported fields
}
Probe represents a thread-safe structure for tracking validation state and cause.
func NewProbeWithCause ¶
NewProbeWithCause creates a new probe with the specified initial state.
type ProbeType ¶
type ProbeType int
ProbeType defines an integer-based enumeration representing different types of health probes for applications.
type ValidityChecker ¶
type ValidityChecker interface { // IsValid validates the current state of an object, returning a boolean indicating validity and a string explaining the reason. IsValid() (bool, Cause) }
ValidityChecker represents an interface for objects capable of validating their state and returning a boolean result. It is used for health checks or determining the validity of various entities within the system.