heartbeat

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HealthCheckSource

type HealthCheckSource struct {
	// contains filtered or unexported fields
}

HealthCheckSource is a thread-safe HealthCheckSource based on heartbeats. This is used to monitor if some process is continuously running by receiving heartbeats (pings) with timeouts. Heartbeats are submitted manually using the Heartbeat or the HeartbeatIfSuccess functions. If no heartbeats are observed within the last heartbeatTimeout time frame, returns unhealthy. Otherwise, returns healthy. A startup grace period can also be specified, where the check will return repairing if no heartbeats were observed but the source was created within the last startupTimeout time frame.

func MustNewHealthCheckSource

func MustNewHealthCheckSource(checkType health.CheckType, heartbeatTimeout time.Duration) *HealthCheckSource

MustNewHealthCheckSource creates a HealthCheckSource with the specified heartbeatTimeout and zero as startupTimeout. The returning HealthCheckResult is of type checkType. Panics if heartbeatTimeout is non-positive. Should only be used in instances where the inputs are statically defined and known to be valid.

func MustNewHealthCheckSourceWithStartupGracePeriod

func MustNewHealthCheckSourceWithStartupGracePeriod(checkType health.CheckType, heartbeatTimeout, startupTimeout time.Duration) *HealthCheckSource

MustNewHealthCheckSourceWithStartupGracePeriod creates a HealthCheckSource with the specified heartbeatTimeout and startupTimeout. The returning HealthCheckResult is of type checkType. Panics if heartbeatTimeout is non-positive or if startupTimeout is negative. Should only be used in instances where the inputs are statically defined and known to be valid.

func NewHealthCheckSource

func NewHealthCheckSource(checkType health.CheckType, heartbeatTimeout time.Duration) (*HealthCheckSource, error)

NewHealthCheckSource creates a HealthCheckSource with the specified heartbeatTimeout and zero as startupTimeout. The returning HealthCheckResult is of type checkType. Returns an error if heartbeatTimeout is non-positive.

func NewHealthCheckSourceWithStartupGracePeriod

func NewHealthCheckSourceWithStartupGracePeriod(checkType health.CheckType, heartbeatTimeout, startupTimeout time.Duration) (*HealthCheckSource, error)

NewHealthCheckSourceWithStartupGracePeriod creates a HealthCheckSource with the specified heartbeatTimeout and startupTimeout. The returning HealthCheckResult is of type checkType. Returns an error if heartbeatTimeout is non-positive or if startupTimeout is negative.

func (*HealthCheckSource) HealthStatus

HealthStatus constructs a HealthStatus object based on the submitted heartbeats. First checks if there were any heartbeats submitted. If there were any heartbeats submitted, checks if the latest one was submitted within the last heartbeatTimeout time frame. If it was, returns healthy. If not, returns unhealthy. If there were no heartbeats submitted, checks if the source started within the last startupTimeout time frame. If it was, returns repairing. If not, returns unhealthy.

func (*HealthCheckSource) Heartbeat

func (h *HealthCheckSource) Heartbeat()

Heartbeat submits a heartbeat.

func (*HealthCheckSource) HeartbeatIfSuccess

func (h *HealthCheckSource) HeartbeatIfSuccess(err error)

HeartbeatIfSuccess submits a heartbeat if err is nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL