server

package
v0.0.0-...-18e1ab8 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClusterID

func ClusterID(logger log.Logger, key string, next http.HandlerFunc) http.HandlerFunc

ClusterID is a HTTP middleware that extracts the cluster's ID and passes it on via context.

func ClusterIDFromContext

func ClusterIDFromContext(ctx context.Context) (string, bool)

ClusterIDFromContext returns the clusterID from the context.

func ForwardHandler

func ForwardHandler(logger log.Logger, forwardURL *url.URL, tenantID string, client *http.Client) http.HandlerFunc

ForwardHandler gets a request containing metric families and converts it to a remote write request forwarding it to the upstream at fowardURL.

func InstrumentedHandler

func InstrumentedHandler(handlerName string, next http.Handler) http.Handler

InstrumentedHandler is an HTTP middleware that monitors HTTP requests and responses.

func Ratelimit

func Ratelimit(logger log.Logger, limit time.Duration, now func() time.Time, next http.HandlerFunc) http.HandlerFunc

Ratelimit is a middleware that rate limits requests based on a cluster ID.

func RequestLogger

func RequestLogger(logger log.Logger) func(http.Handler) http.Handler

RequestLogger is a middleware that logs requests.

func Snappy

func Snappy(next http.HandlerFunc) http.HandlerFunc

Snappy checks HTTP headers and if Content-Ecoding is snappy it decodes the request body.

func Validate

func Validate(logger log.Logger, baseTransforms metricfamily.Transformer, maxAge time.Duration, limitBytes int64, now func() time.Time, next http.HandlerFunc) http.HandlerFunc

Validate the payload of a request against given and required rules.

func WithClusterID

func WithClusterID(ctx context.Context, clusterID string) context.Context

WithClusterID puts the clusterID into the given context.

Types

type AccessLogResponseWriter

type AccessLogResponseWriter struct {
	http.ResponseWriter
	StatusCode int
}

AccessLogResponseWriter wrps the responseWriter to capture the HTTP status code.

func (*AccessLogResponseWriter) WriteHeader

func (a *AccessLogResponseWriter) WriteHeader(code int)

type ErrWriteLimitReached

type ErrWriteLimitReached string

ErrWriteLimitReached is an error that is returned when a cluster has sent too many requests.

func (ErrWriteLimitReached) Error

func (e ErrWriteLimitReached) Error() string

type PartitionedMetrics

type PartitionedMetrics struct {
	ClusterID string
	Families  []*clientmodel.MetricFamily
}

Jump to

Keyboard shortcuts

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