interceptors

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: MIT Imports: 18 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 StreamInterceptors

func StreamInterceptors(conf config.TRISAConfig) grpc.ServerOption

Returns the server option chaining all stream interceptors in the specified order.

func StreamMonitoring

func StreamMonitoring() grpc.StreamServerInterceptor

Monitoring handles both logging and outputing Prometheus metrics (if enabled). These are embedded into the same interceptor so that the monitoring uses the same logging, tracing, and latency -- allowing this to be the outermost interceptor. TODO: add prometheus metrics

func StreamRecovery

func StreamRecovery() grpc.StreamServerInterceptor

Panic recovery logs a panic and stack trace without crashing the server, then converts the panic into a gRPC error to return to the client, keeping the server online. The panic is recovered at any point in the stream handler execution.

func UnaryInterceptors

func UnaryInterceptors(conf config.TRISAConfig) grpc.ServerOption

Returns the server option chaining all unary interceptors in the specified order.

func UnaryMonitoring

func UnaryMonitoring() grpc.UnaryServerInterceptor

Monitoring handles both logging and outputing Prometheus metrics (if enabled). These are embedded into the same interceptor so that the monitoring uses the same logging, tracing, and latency -- allowing this to be the outermost interceptor. TODO: add prometheus metrics

func UnaryRecovery

func UnaryRecovery() grpc.UnaryServerInterceptor

Panic recovery logs a panic and stack trace without crashing the server, then converts the panic into a gRPC error to return to the client, keeping the server online.

Types

type MonitoredStream

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

MonitoredStream wraps a grpc.ServerStream to count the number of messages sent in the stream for logging purposes. It also provides the stream the adapted context.

func (*MonitoredStream) Context

func (s *MonitoredStream) Context() context.Context

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