Documentation
¶
Overview ¶
Package recovery is a middleware that recovers from panics and logs the panic message.
`recovery` are interceptors that recover from gRPC handler panics.
Server Side Recovery Middleware ¶
By default a panic will be converted into a gRPC error with `code.Internal`.
Handling can be customised by providing an alternate recovery function.
Please see examples for simple examples of use.
Example (Initialization) ¶
Initialization shows an initialization sequence with a custom recovery handler func.
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func StreamServerInterceptor ¶
func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor
StreamServerInterceptor returns a new streaming server interceptor for panic recovery.
func UnaryServerInterceptor ¶
func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor
UnaryServerInterceptor returns a new unary server interceptor for panic recovery.
Types ¶
type Option ¶
type Option func(*options)
func WithRecoveryHandler ¶
func WithRecoveryHandler(f RecoveryHandlerFunc) Option
WithRecoveryHandler customizes the function for recovering from a panic.
func WithRecoveryHandlerContext ¶
func WithRecoveryHandlerContext(f RecoveryHandlerFuncContext) Option
WithRecoveryHandlerContext customizes the function for recovering from a panic.
type PanicError ¶
func (*PanicError) Error ¶
func (e *PanicError) Error() string
type RecoveryHandlerFunc ¶
RecoveryHandlerFunc is a function that recovers from the panic `p` by returning an `error`.