middleware

package
v1.16.109 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Overview

generated by protoc-gen-consul-rate-limit; DO NOT EDIT.

Index

Constants

View Source
const AllowedPeerEndpointPrefix = "/hashicorp.consul.internal.peerstream.PeerStreamService/"

Variables

View Source
var StatsCounters = []prometheus.CounterDefinition{
	{
		Name: []string{"grpc", "client", "request", "count"},
		Help: "Counts the number of gRPC requests made by the client agent to a Consul server.",
	},
	{
		Name: []string{"grpc", "server", "request", "count"},
		Help: "Counts the number of gRPC requests received by the server.",
	},
	{
		Name: []string{"grpc", "client", "connection", "count"},
		Help: "Counts the number of new gRPC connections opened by the client agent to a Consul server.",
	},
	{
		Name: []string{"grpc", "server", "connection", "count"},
		Help: "Counts the number of new gRPC connections received by the server.",
	},
	{
		Name: []string{"grpc", "server", "stream", "count"},
		Help: "Counts the number of new gRPC streams received by the server.",
	},
}
View Source
var StatsGauges = []prometheus.GaugeDefinition{
	{
		Name: []string{"grpc", "server", "connections"},
		Help: "Measures the number of active gRPC connections open on the server.",
	},
	{
		Name: []string{"grpc", "client", "connections"},
		Help: "Measures the number of active gRPC connections open from the client agent to any Consul servers.",
	},
	{
		Name: []string{"grpc", "server", "streams"},
		Help: "Measures the number of active gRPC streams handled by the server.",
	},
}

Functions

func NewActiveStreamCounter

func NewActiveStreamCounter(m *metrics.Metrics, labels []metrics.Label) *activeStreamCounter

func NewPanicHandler

func NewPanicHandler(logger Logger) recovery.RecoveryHandlerFunc

NewPanicHandler returns a recovery.RecoveryHandlerFunc closure function to handle panic in GRPC server's handlers.

func NewStatsHandler

func NewStatsHandler(m *metrics.Metrics, labels []metrics.Label) *statsHandler

func PanicHandlerMiddlewareOpts

func PanicHandlerMiddlewareOpts(logger Logger) []recovery.Option

PanicHandlerMiddlewareOpts returns the []recovery.Option containing recovery handler function.

func ServerRateLimiterMiddleware

func ServerRateLimiterMiddleware(limiter rate.RequestLimitsHandler, panicHandler recovery.RecoveryHandlerFunc, logger Logger) tap.ServerInHandle

ServerRateLimiterMiddleware implements a ServerInHandle function to perform RPC rate limiting at the cheapest possible point (before the full request has been decoded).

Types

type AuthInterceptor

type AuthInterceptor struct {
	TLS    *tlsutil.Configurator
	Logger Logger
}

AuthInterceptor provides gRPC interceptors for restricting endpoint access based on SNI. If the connection is plaintext, this filter will not activate, and the connection will be allowed to proceed.

func (*AuthInterceptor) InterceptStream

func (a *AuthInterceptor) InterceptStream(
	srv interface{},
	ss grpc.ServerStream,
	info *grpc.StreamServerInfo,
	handler grpc.StreamHandler,
) error

InterceptUnary prevents streaming gRPC calls from calling certain endpoints, based on the SNI information.

func (*AuthInterceptor) InterceptUnary

func (a *AuthInterceptor) InterceptUnary(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

InterceptUnary prevents non-streaming gRPC calls from calling certain endpoints, based on the SNI information.

type LabelledConn

type LabelledConn struct {
	net.Conn
	// contains filtered or unexported fields
}

LabelledConn wraps a connection and provides extra metadata fields.

type LabelledListener

type LabelledListener struct {
	net.Listener
	Protocol Protocol
}

LabelledListener wraps a listener and attaches pre-specified fields to each spawned connection.

func (LabelledListener) Accept

func (l LabelledListener) Accept() (net.Conn, error)

type Logger

type Logger interface {
	Error(string, ...interface{})
	Warn(string, ...interface{})
}

type Protocol

type Protocol int
var (
	ProtocolPlaintext Protocol = 0
	ProtocolTLS       Protocol = 1
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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