2021-11-21 13:58:49 +00:00
|
|
|
package interceptors
|
|
|
|
|
|
|
|
import (
|
2022-09-27 15:06:18 +00:00
|
|
|
"context"
|
|
|
|
|
2021-11-21 13:58:49 +00:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ServerInterceptors interface {
|
|
|
|
UnaryServerInterceptor() grpc.UnaryServerInterceptor
|
|
|
|
StreamServerInterceptor() grpc.StreamServerInterceptor
|
|
|
|
}
|
|
|
|
|
|
|
|
type ClientInterceptors interface {
|
|
|
|
UnaryClientInterceptor() grpc.UnaryClientInterceptor
|
|
|
|
StreamClientInterceptor() grpc.StreamClientInterceptor
|
|
|
|
}
|
|
|
|
|
|
|
|
type Interceptors interface {
|
|
|
|
ServerInterceptors
|
|
|
|
ClientInterceptors
|
|
|
|
}
|
2022-09-27 15:06:18 +00:00
|
|
|
|
|
|
|
func NewContextServerStream(ctx context.Context, ss grpc.ServerStream) grpc.ServerStream {
|
|
|
|
return &ContextWrapper{ServerStream: ss, ctx: ctx}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ContextWrapper struct {
|
|
|
|
grpc.ServerStream
|
|
|
|
ctx context.Context
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *ContextWrapper) Context() context.Context {
|
|
|
|
return w.ctx
|
|
|
|
}
|