Documentation ¶
Index ¶
- Constants
- Variables
- type Component
- type Handler
- func (h *Handler) Listen(ctx context.Context) error
- func (h *Handler) ListenAndServe(ctx context.Context, port int) error
- func (h *Handler) Livez(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Readyz(w http.ResponseWriter, r *http.Request)
- func (h *Handler) RegisterShutdownFunc(f func())
- func (h *Handler) RegisterShutdownServer(ctx context.Context, f ShutdownAble)
- func (h *Handler) Shutdown(ctx context.Context) error
- type Payload
- type ShutdownAble
Constants ¶
const ( StatusUp = "up" StatusDown = "down" StatusUnknown = "unknown" )
Variables ¶
var ErrDeadlineExceeded = errors.New("observer-initiated shutdown deadline exceeded")
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
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 ¶
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 ¶
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) 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.
type ShutdownAble ¶
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.