From aaf2aa396484af3badaab6573d36f22509593e31 Mon Sep 17 00:00:00 2001 From: Adphi Date: Thu, 25 Nov 2021 18:22:57 +0100 Subject: [PATCH] recovery server interceptor --- interceptors/recovery/interceptors.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/interceptors/recovery/interceptors.go b/interceptors/recovery/interceptors.go index 2a5ea86..b8bba13 100644 --- a/interceptors/recovery/interceptors.go +++ b/interceptors/recovery/interceptors.go @@ -3,25 +3,31 @@ package recovery import ( grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery" "google.golang.org/grpc" + + "go.linka.cloud/grpc/interceptors" ) -type interceptors struct { - opts grpc_recovery.Option +func NewInterceptors(opts ...grpc_recovery.Option) interceptors.ServerInterceptors { + return &recovery{opts: opts} } -func (i *interceptors) UnaryServerInterceptor() grpc.UnaryServerInterceptor { - return grpc_recovery.UnaryServerInterceptor(i.opts) +type recovery struct { + opts []grpc_recovery.Option } -func (i *interceptors) StreamServerInterceptor() grpc.StreamServerInterceptor { - return grpc_recovery.StreamServerInterceptor(i.opts) +func (i *recovery) UnaryServerInterceptor() grpc.UnaryServerInterceptor { + return grpc_recovery.UnaryServerInterceptor(i.opts...) } -func (i *interceptors) UnaryClientInterceptor() grpc.UnaryClientInterceptor { +func (i *recovery) StreamServerInterceptor() grpc.StreamServerInterceptor { + return grpc_recovery.StreamServerInterceptor(i.opts...) +} + +func (i *recovery) UnaryClientInterceptor() grpc.UnaryClientInterceptor { panic("not implemented") } -func (i *interceptors) StreamClientInterceptor() grpc.StreamClientInterceptor { +func (i *recovery) StreamClientInterceptor() grpc.StreamClientInterceptor { panic("not implemented") }