middleware

package
v1.14.2 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

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 added in v1.14.0

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

func NewOptionalTransportCredentials added in v1.14.0

func NewOptionalTransportCredentials(creds credentials.TransportCredentials, logger Logger) credentials.TransportCredentials

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 added in v1.14.0

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.

Types

type AuthInterceptor added in v1.14.0

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 added in v1.14.0

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 added in v1.14.0

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 added in v1.14.0

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

LabelledConn wraps a connection and provides extra metadata fields.

type LabelledListener added in v1.14.0

type LabelledListener struct {
	net.Listener
	Protocol Protocol
}

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

func (LabelledListener) Accept added in v1.14.0

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

type Logger

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

type Protocol added in v1.14.0

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