handlers

package
v0.0.0-...-6fe3ecb Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateReplicas

func CalculateReplicas(status string, 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 MakeForwardingProxyHandler

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

NOTE: 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 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

Jump to

Keyboard shortcuts

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