Documentation ¶
Index ¶
Constants ¶
const ( // MinInterval is the minimal interval between // two checks. Do not allow for an interval below this value. // Otherwise, we risk fork bombing a system. MinInterval = time.Second // DefaultBufSize is the maximum size of the captured // check output by default. Prevents an enormous buffer // from being captured DefaultBufSize = 4 * 1024 // 4KB // UserAgent is the value of the User-Agent header // for HTTP health checks. UserAgent = "Orbit Health Checker" )
const ( // HealthAny is special, and is used as a wild card, // not as a specific state. HealthAny = "any" HealthPassing = "passing" HealthWarning = "warning" HealthCritical = "critical" HealthMaint = "maintenance" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Buffer ¶
type Buffer struct {
// contains filtered or unexported fields
}
Buffer implements a circular buffer. It is a fixed size, and new writes overwrite older data, such that for a buffer of size N, for any amount of writes, only the last N bytes are retained.
func (*Buffer) Bytes ¶
Bytes provides a slice of the bytes written. This slice should not be written to.
func (*Buffer) TotalWritten ¶
TotalWritten provides the total number of bytes written
type CheckHTTP ¶
type CheckHTTP struct { HTTP string Header map[string][]string Method string Body string Interval time.Duration Timeout time.Duration Logger *zap.SugaredLogger TLSClientConfig *tls.Config OutputMaxSize int StatusHandler *StatusHandler DisableRedirects bool // Set if checks are exposed through Connect proxies // If set, this is the target of check() ProxyHTTP string // contains filtered or unexported fields }
type CheckNotifier ¶
type CheckNotifier interface {
UpdateCheck(status, output string)
}
type CheckTCP ¶
type CheckTCP struct { ServiceID string TCP string Interval time.Duration Timeout time.Duration Logger *zap.SugaredLogger TLSClientConfig *tls.Config StatusHandler *StatusHandler // contains filtered or unexported fields }
CheckTCP is used to periodically make a TCP connection to determine the health of a given check. The check is passing if the connection succeeds The check is critical if the connection returns an error Supports failures_before_critical and success_before_passing.
type CheckType ¶
type CheckType struct { Name string Notes string Status string ScriptArgs []string HTTP string H2PING string H2PingUseTLS bool Header map[string][]string Method string Body string DisableRedirects bool TCP string TCPUseTLS bool UDP string Interval time.Duration AliasNode string AliasService string DockerContainerID string Shell string GRPC string GRPCUseTLS bool OSService string TLSServerName string TLSSkipVerify bool Timeout time.Duration TTL time.Duration SuccessBeforePassing int FailuresBeforeWarning int FailuresBeforeCritical int // Definition fields used when exposing checks through a proxy ProxyHTTP string ProxyGRPC string // DeregisterCriticalServiceAfter, if >0, will cause the associated // service, if any, to be deregistered if this check is critical for // longer than this duration. DeregisterCriticalServiceAfter time.Duration OutputMaxSize int }
type CheckUDP ¶
type CheckUDP struct { ServiceID string UDP string Message string Interval time.Duration Timeout time.Duration Logger *zap.SugaredLogger StatusHandler *StatusHandler // contains filtered or unexported fields }
CheckUDP is used to periodically send a UDP datagram to determine the health of a given check. The check is passing if the connection succeeds, the response is bytes.Equal to the bytes passed in or if the error returned is a timeout error The check is critical if: the connection succeeds but the response is not equal to the bytes passed in, the connection succeeds but the error returned is not a timeout error or the connection fails
type HealthCheck ¶
type HealthCheck struct { Node string CheckID string Name string Notes string Status string Output string ServiceID string ServiceName string ServiceTags []string Type string Namespace string `json:",omitempty"` Partition string `json:",omitempty"` ExposedPort int PeerName string `json:",omitempty"` Definition HealthCheckDefinition CreateIndex uint64 ModifyIndex uint64 }
HealthCheck is used to represent a single check
type HealthCheckDefinition ¶
type HealthCheckDefinition struct { HTTP string Header map[string][]string Method string Body string TLSServerName string TLSSkipVerify bool TCP string TCPUseTLS bool UDP string GRPC string OSService string GRPCUseTLS bool TimeoutDuration time.Duration `json:"-"` IntervalDuration time.Duration `json:"-"` DeregisterCriticalServiceAfterDuration time.Duration `json:"-"` }
HealthCheckDefinition is used to store the details about a health check's execution.
type StatusHandler ¶
type StatusHandler struct {
// contains filtered or unexported fields
}
func NewStatusHandler ¶
func NewStatusHandler(inner CheckNotifier, logger *zap.SugaredLogger, successBeforePassing, failuresBeforeWarning, failuresBeforeCritical int) *StatusHandler
NewStatusHandler set counters values to threshold in order to immediately update status after first check.