handlers

package
v0.0.0-...-f66d3e9 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateReplicas

func CalculateReplicas(alert requests.PrometheusInnerAlert, currentReplicas uint64, maxReplicas uint64, minReplicas uint64, scalingFactor uint64) uint64

CalculateReplicas decides what replica count to set depending on current/desired amount

func DecorateWithCORS

func DecorateWithCORS(upstream http.Handler, allowedHost string) http.Handler

DecorateWithCORS decorate a handler with CORS-injecting middleware

func HealthzHandler

func HealthzHandler(w http.ResponseWriter, r *http.Request)

HealthzHandler healthz hanlder for mertics server

func MakeAlertHandler

func MakeAlertHandler(service scaling.ServiceQuery, defaultNamespace string) http.HandlerFunc

MakeAlertHandler handles alerts from Prometheus Alertmanager

func MakeCallIDMiddleware

func MakeCallIDMiddleware(next http.HandlerFunc) http.HandlerFunc

MakeCallIDMiddleware middleware tags a request with a uid

func MakeExternalAuthHandler

func MakeExternalAuthHandler(next http.HandlerFunc, upstreamTimeout time.Duration, upstreamURL string, passBody bool) http.HandlerFunc

MakeExternalAuthHandler make an authentication proxy handler

func MakeForwardingProxyHandler

func MakeForwardingProxyHandler(proxy *types.HTTPClientReverseProxy,
	notifiers []HTTPNotifier,
	baseURLResolver middleware.BaseURLResolver,
	urlPathTransformer middleware.URLPathTransformer,
	serviceAuthInjector middleware.AuthInjector) http.HandlerFunc

MakeForwardingProxyHandler create a handler which forwards HTTP requests

func MakeInfoHandler

func MakeInfoHandler(h http.Handler) http.HandlerFunc

MakeInfoHandler is responsible for display component version information

func MakeNotifierWrapper

func MakeNotifierWrapper(next http.HandlerFunc, notifiers []HTTPNotifier) http.HandlerFunc

MakeNotifierWrapper wraps a http.HandlerFunc in an interceptor to pass to HTTPNotifier

func MakeProbeHandler

func MakeProbeHandler(prober probing.FunctionProber, cache probing.ProbeCacher, resolver middleware.BaseURLResolver, next http.HandlerFunc, defaultNamespace string) http.HandlerFunc

func MakeQueuedProxy

func MakeQueuedProxy(metrics metrics.MetricOptions, queuer ftypes.RequestQueuer, pathTransformer middleware.URLPathTransformer, defaultNS string, functionQuery scaling.FunctionQuery) http.HandlerFunc

MakeQueuedProxy accepts work onto a queue

func MakeScalingHandler

func MakeScalingHandler(next http.HandlerFunc, scaler scaling.FunctionScaler, config scaling.ScalingConfig, defaultNamespace string) http.HandlerFunc

MakeScalingHandler creates handler which can scale a function from zero to N replica(s). After scaling the next http.HandlerFunc will be called. If the function is not ready after the configured amount of attempts / queries then next will not be invoked and a status will be returned to the client.

func NewLogHandlerFunc

func NewLogHandlerFunc(logProvider url.URL, timeout time.Duration) http.HandlerFunc

NewLogHandlerFunc creates and http HandlerFunc from the supplied log Requestor.

Types

type CORSHandler

type CORSHandler struct {
	Upstream    *http.Handler
	AllowedHost string
}

CORSHandler set custom CORS instructions for the store.

func (CORSHandler) ServeHTTP

func (c CORSHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HTTPNotifier

type HTTPNotifier interface {
	Notify(method string, URL string, originalURL string, statusCode int, event string, duration time.Duration)
}

HTTPNotifier notify about HTTP request/response

type LoggingNotifier

type LoggingNotifier struct {
}

LoggingNotifier notifies a log about a request

func (LoggingNotifier) Notify

func (LoggingNotifier) Notify(method string, URL string, originalURL string, statusCode int, event string, duration time.Duration)

Notify the LoggingNotifier about a request

type PrometheusFunctionNotifier

type PrometheusFunctionNotifier struct {
	Metrics *metrics.MetricOptions
	//FunctionNamespace default namespace of the function
	FunctionNamespace string
}

PrometheusFunctionNotifier records metrics to Prometheus

func (PrometheusFunctionNotifier) Notify

func (p PrometheusFunctionNotifier) Notify(method string, URL string, originalURL string, statusCode int, event string, duration time.Duration)

Notify records metrics in Prometheus

type PrometheusServiceNotifier

type PrometheusServiceNotifier struct {
	ServiceMetrics *metrics.ServiceMetricOptions
}

PrometheusServiceNotifier notifier for core service endpoints

func (PrometheusServiceNotifier) Notify

func (psn PrometheusServiceNotifier) Notify(method string, URL string, originalURL string, statusCode int, event string, duration time.Duration)

Notify about service metrics

Jump to

Keyboard shortcuts

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