Documentation ¶
Index ¶
- Constants
- Variables
- func ParseHost(host string) (string, string, string, error)
- type CheckDocker
- type CheckGRPC
- type CheckHTTP
- type CheckMonitor
- type CheckNotifier
- type CheckTCP
- type CheckTTL
- type DockerClient
- func (c *DockerClient) Close() error
- func (c *DockerClient) CreateExec(containerID string, cmd []string) (string, error)
- func (c *DockerClient) Host() string
- func (c *DockerClient) InspectExec(containerID, execID string) (int, error)
- func (c *DockerClient) StartExec(containerID, execID string) (*circbuf.Buffer, error)
- type GrpcHealthProbe
Constants ¶
const ( // MinInterval is the minimal interval between // two checks. Do not allow for a interval below this value. // Otherwise we risk fork bombing a system. MinInterval = time.Second // BufSize is the maximum size of the captured // check output. Prevents an enormous buffer // from being captured BufSize = 4 * 1024 // 4KB // UserAgent is the value of the User-Agent header // for HTTP health checks. UserAgent = "Consul Health Check" )
const DefaultDockerHost = "unix:///var/run/docker.sock"
Variables ¶
var ErrGRPCUnhealthy = fmt.Errorf("gRPC application didn't report service healthy")
Functions ¶
Types ¶
type CheckDocker ¶
type CheckDocker struct { Notify CheckNotifier CheckID types.CheckID Script string ScriptArgs []string DockerContainerID string Shell string Interval time.Duration Logger *log.Logger Client *DockerClient // contains filtered or unexported fields }
CheckDocker is used to periodically invoke a script to determine the health of an application running inside a Docker Container. We assume that the script is compatible with nagios plugins and expects the output in the same format.
func (*CheckDocker) Start ¶
func (c *CheckDocker) Start()
func (*CheckDocker) Stop ¶
func (c *CheckDocker) Stop()
type CheckGRPC ¶ added in v1.0.8
type CheckGRPC struct { Notify CheckNotifier CheckID types.CheckID GRPC string Interval time.Duration Timeout time.Duration TLSClientConfig *tls.Config Logger *log.Logger // contains filtered or unexported fields }
CheckGRPC is used to periodically send request to a gRPC server application that implements gRPC health-checking protocol. The check is passing if returned status is SERVING. The check is critical if connection fails or returned status is not SERVING.
type CheckHTTP ¶
type CheckHTTP struct { Notify CheckNotifier CheckID types.CheckID HTTP string Header map[string][]string Method string Interval time.Duration Timeout time.Duration Logger *log.Logger TLSClientConfig *tls.Config // contains filtered or unexported fields }
CheckHTTP is used to periodically make an HTTP request to determine the health of a given check. The check is passing if the response code is 2XX. The check is warning if the response code is 429. The check is critical if the response code is anything else or if the request returns an error
type CheckMonitor ¶
type CheckMonitor struct { Notify CheckNotifier CheckID types.CheckID Script string ScriptArgs []string Interval time.Duration Timeout time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckMonitor is used to periodically invoke a script to determine the health of a given check. It is compatible with nagios plugins and expects the output in the same format.
func (*CheckMonitor) Start ¶
func (c *CheckMonitor) Start()
Start is used to start a check monitor. Monitor runs until stop is called
type CheckNotifier ¶
CheckNotifier interface is used by the CheckMonitor to notify when a check has a status update. The update should take care to be idempotent.
type CheckTCP ¶
type CheckTCP struct { Notify CheckNotifier CheckID types.CheckID TCP string Interval time.Duration Timeout time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckTCP is used to periodically make an TCP/UDP 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
type CheckTTL ¶
type CheckTTL struct { Notify CheckNotifier CheckID types.CheckID TTL time.Duration Logger *log.Logger // contains filtered or unexported fields }
CheckTTL is used to apply a TTL to check status, and enables clients to set the status of a check but upon the TTL expiring, the check status is automatically set to critical.
func (*CheckTTL) SetStatus ¶
SetStatus is used to update the status of the check, and to renew the TTL. If expired, TTL is restarted.
type DockerClient ¶
type DockerClient struct {
// contains filtered or unexported fields
}
DockerClient is a simplified client for the Docker Engine API to execute the health checks and avoid significant dependencies. It also consumes all data returned from the Docker API through a ring buffer with a fixed limit to avoid excessive resource consumption.
func NewDockerClient ¶
func NewDockerClient(host string, maxbuf int64) (*DockerClient, error)
func (*DockerClient) Close ¶
func (c *DockerClient) Close() error
func (*DockerClient) CreateExec ¶
func (c *DockerClient) CreateExec(containerID string, cmd []string) (string, error)
func (*DockerClient) Host ¶
func (c *DockerClient) Host() string
func (*DockerClient) InspectExec ¶
func (c *DockerClient) InspectExec(containerID, execID string) (int, error)
type GrpcHealthProbe ¶ added in v1.0.8
type GrpcHealthProbe struct {
// contains filtered or unexported fields
}
GrpcHealthProbe connects to gRPC application and queries health service for application/service status.
func NewGrpcHealthProbe ¶ added in v1.0.8
func NewGrpcHealthProbe(target string, timeout time.Duration, tlsConfig *tls.Config) *GrpcHealthProbe
NewGrpcHealthProbe constructs GrpcHealthProbe from target string in format server[/service] If service is omitted, health of the entire application is probed
func (*GrpcHealthProbe) Check ¶ added in v1.0.8
func (probe *GrpcHealthProbe) Check() error
Check if the target of this GrpcHealthProbe is healthy If nil is returned, target is healthy, otherwise target is not healthy