mirror of
https://github.com/linka-cloud/grpc.git
synced 2024-11-14 23:16:25 +00:00
40 lines
1.3 KiB
Go
40 lines
1.3 KiB
Go
package noop
|
|
|
|
import (
|
|
"context"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"go.linka.cloud/grpc/interceptors"
|
|
)
|
|
|
|
func New() interceptors.Interceptors {
|
|
return &noopInterceptor{}
|
|
}
|
|
|
|
type noopInterceptor struct{}
|
|
|
|
func (m *noopInterceptor) UnaryServerInterceptor() grpc.UnaryServerInterceptor {
|
|
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
|
|
return handler(ctx, req)
|
|
}
|
|
}
|
|
|
|
func (m *noopInterceptor) StreamServerInterceptor() grpc.StreamServerInterceptor {
|
|
return func(srv interface{}, ss grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
|
|
return handler(srv, ss)
|
|
}
|
|
}
|
|
|
|
func (m *noopInterceptor) UnaryClientInterceptor() grpc.UnaryClientInterceptor {
|
|
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
|
|
return invoker(ctx, method, req, reply, cc, opts...)
|
|
}
|
|
}
|
|
|
|
func (m *noopInterceptor) StreamClientInterceptor() grpc.StreamClientInterceptor {
|
|
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
|
|
return streamer(ctx, desc, cc, method, opts...)
|
|
}
|
|
}
|