Skip to content

Commit

Permalink
unary interceptor isn't necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
andyroyle committed Nov 23, 2018
1 parent d9a4344 commit 4d18669
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 23 deletions.
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"google.golang.org/grpc"
"io"
"log"
"net"
Expand Down Expand Up @@ -36,6 +35,7 @@ import (
grpc_proxy "github.com/mwitkow/grpc-proxy/proxy"
"github.com/pkg/profile"
dmp "github.com/sergi/go-diff/diffmatchpatch"
"google.golang.org/grpc"
)

// version contains the version number
Expand Down Expand Up @@ -158,7 +158,6 @@ func newGrpcProxy(cfg *config.Config, tlscfg *tls.Config) []grpc.ServerOption {
return []grpc.ServerOption{
grpc.CustomCodec(grpc_proxy.Codec()),
grpc.UnknownServiceHandler(handler),
grpc.UnaryInterceptor(proxyInterceptor.Unary),
grpc.StreamInterceptor(proxyInterceptor.Stream),
grpc.StatsHandler(statsHandler),
}
Expand Down
21 changes: 0 additions & 21 deletions proxy/grpc_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,27 +99,6 @@ func (p proxyStream) Context() context.Context {
return p.ctx
}

func (g GrpcProxyInterceptor) Unary(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
target, err := g.lookup(ctx, info.FullMethod)

if err != nil {
return nil, err
}

ctx = context.WithValue(ctx, targetKey{}, target)

start := time.Now()

res, err := handler(ctx, req)

end := time.Now()
dur := end.Sub(start)

target.Timer.Update(dur)

return res, err
}

func (g GrpcProxyInterceptor) Stream(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error {
ctx := stream.Context()

Expand Down

0 comments on commit 4d18669

Please sign in to comment.