interceptors

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMethod

func ParseMethod(method string) (string, string)

func StreamMaintenance

func StreamMaintenance(conf config.Config) grpc.StreamServerInterceptor

The stream maintenance interceptor simply returns an unavailable error. If the server is not in maintenance mode when the interceptor is created this method returns nil.

func StreamMonitoring

func StreamMonitoring(conf config.Config) grpc.StreamServerInterceptor

Monitoring does double duty, handling Prometheus metrics, and logging with zerolog. These are piled into the same interceptor so that the monitoring uses the same latency and tagging constructs and so that this interceptor can be the outermost interceptor for stream calls. NOTE: Sentry is excluded from stream monitoring because we do not work to minimize the duration of stream processing but rather to maximize it in Ensign.

func StreamRecovery

func StreamRecovery(conf config.Config) grpc.StreamServerInterceptor

Panic recovery logs the panic to Sentry if it is enabled and then converts the panic into a gRPC error to return to the client; this allows the server to stay online.

func StreamType

func StreamType(info *grpc.MethodInfo) string

func UnaryMaintenance

func UnaryMaintenance(conf config.Config) grpc.UnaryServerInterceptor

The maintenance interceptor only allows Status endpoint to be queried and returns a service unavailable error otherwise. If the server is not in maintenance mode when the interceptor is created this method returns nil.

func UnaryMonitoring

func UnaryMonitoring(conf config.Config) grpc.UnaryServerInterceptor

Monitoring does triple duty, handling Sentry tracking, Prometheus metrics, and logging with zerolog. These are piled into the same interceptor so that the monitoring uses the same latency and tagging constructs and so that this interceptor can be the outermost interceptor for unary calls.

func UnaryRecovery

func UnaryRecovery(conf config.Config) grpc.UnaryServerInterceptor

Panic recovery logs the panic to Sentry if it is enabled and then converts the panic into a gRPC error to return to the client; this allows the server to stay online.

Types

type MonitoredStream

type MonitoredStream struct {
	grpc.ServerStream
	// contains filtered or unexported fields
}

MonitoredStream wraps a grpc.ServerStream allowing it to increment Sent and Recv message counters when they are called by the application.

func (*MonitoredStream) RecvMsg

func (s *MonitoredStream) RecvMsg(m interface{}) (err error)

Increment the number of received messages if there is no error on Recv.

func (*MonitoredStream) SendMsg

func (s *MonitoredStream) SendMsg(m interface{}) (err error)

Increment the number of sent messages if there is no error on Send.

Jump to

Keyboard shortcuts

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