probe

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

View Source
const (
	StatusUp      = "up"
	StatusDown    = "down"
	StatusUnknown = "unknown"
)

Variables

View Source
var ErrDeadlineExceeded = errors.New("observer-initiated shutdown deadline exceeded")

Functions

This section is empty.

Types

type Component

type Component struct {
	Ok     bool   `json:"ok"`
	Status string `json:"status"`
	Detail string `json:"detail,omitempty"`
}

type Handler

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

func NewHandler

func NewHandler(timeout time.Duration) *Handler

NewHandler creates a new instance of Handler with a specified timeout. A timeout of 0 means that the application will not exit until the observer sends a kill signal.

The handler requires starting with ListenAndServe

func (*Handler) Listen

func (h *Handler) Listen(ctx context.Context) error

Listen waits for SIGTERM and indicates to an observer that new requests shouldn't be sent to this instance.

Only call this if you're managing the HTTP components yourself. Generally you should just use ListenAndServe

func (*Handler) ListenAndServe

func (h *Handler) ListenAndServe(ctx context.Context, port int) error

ListenAndServe starts a http server that serves HTTP requests from an observer (e.g. the kubelet).

This server should only be used for health information and is only shutdown when the application exits (i.e. not gracefully).

Returns an error if the specified deadline has exceeded and indicates that the caller (you) should exit the application using os.Exit

func (*Handler) Livez

func (h *Handler) Livez(w http.ResponseWriter, r *http.Request)

func (*Handler) Readyz

func (h *Handler) Readyz(w http.ResponseWriter, r *http.Request)

func (*Handler) RegisterShutdownFunc

func (h *Handler) RegisterShutdownFunc(f func())

RegisterShutdownFunc adds a user-provided function that needs to be called when the application is interrupted.

Make sure to use RegisterShutdownServer for HTTP servers and http.Server RegisterOnShutdown for http-related shutdown callbacks.

func (*Handler) RegisterShutdownServer

func (h *Handler) RegisterShutdownServer(ctx context.Context, f ShutdownAble)

RegisterShutdownServer adds a http server (or similar) that needs to be shutdown when the application is interrupted.

func (*Handler) Shutdown added in v0.1.1

func (h *Handler) Shutdown(ctx context.Context) error

Shutdown allows the caller to manually request the application to shut down. Generally this should only be used for testing.

type Payload

type Payload struct {
	Component
	Components []Component `json:"components"`
}

type ShutdownAble

type ShutdownAble interface {
	Shutdown(context.Context) error
}

ShutdownAble describes any struct that implements the Shutdown function that http.Server uses.

It only exists to ensure we're not bound to the net/http implementation of the HTTP server.

Jump to

Keyboard shortcuts

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