handlers

package
v0.0.0-...-74c4be5 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 6 Imported by: 8

Documentation

Overview

Package handlers holds useful HTTP handler implementations.

Index

Constants

This section is empty.

Variables

Error sets up a handler suitable for use with the ErrorHandler field on httputil's reverse proxy, which logs /proc/net/sockstat data.

Functions

This section is empty.

Types

type Drainer

type Drainer struct {
	// Mutex guards the initialization and resets of the timer
	sync.RWMutex

	// HealthCheck is an optional health check that is performed until the drain signal is received.
	// When unspecified, a "200 OK" is returned, otherwise this function is invoked.
	HealthCheck http.HandlerFunc

	// Inner is the http.Handler to which we delegate actual requests.
	Inner http.Handler

	// QuietPeriod is the duration that must elapse without any requests
	// after Drain is called before it may return.
	QuietPeriod time.Duration

	// HealthCheckUAPrefixes are the additional user agent prefixes that trigger the
	// drainer's health check
	HealthCheckUAPrefixes []string
	// contains filtered or unexported fields
}

Drainer wraps an inner http.Handler to support responding to kubelet probes and KProbes with a "200 OK" until the handler is told to Drain, or Drainer will optionally run the HealthCheck if it is defined. When the Drainer is told to Drain, it will immediately start to fail probes with a "500 shutting down", and the call will block until no requests have been received for QuietPeriod (defaults to network.DefaultDrainTimeout).

func (*Drainer) Drain

func (d *Drainer) Drain()

Drain blocks until QuietPeriod has elapsed since the last request, starting when this is invoked.

func (*Drainer) Reset

func (d *Drainer) Reset()

Reset interrupts Drain and clears the drainers internal state Thus further calls to Drain will block and wait for the entire QuietPeriod

func (*Drainer) ServeHTTP

func (d *Drainer) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler

Jump to

Keyboard shortcuts

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