Skip to content

Commit

Permalink
update transport grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-marvin committed May 11, 2021
1 parent abe9660 commit a14498f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions proxy/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package proxy

import (
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"io"

"golang.org/x/net/context"
Expand Down Expand Up @@ -68,12 +70,12 @@ func (s *handler) handler(srv interface{}, serverStream grpc.ServerStream) error
if err != nil {
return err
}
defer s.director.Release(outCtx, backendConn)
defer s.director.Release(outgoingCtx, backendConn)

clientCtx, clientCancel := context.WithCancel(outgoingCtx)
defer clientCancel()
if _, ok := metadata.FromOutgoingContext(outCtx); !ok {
clientCtx = copyMetadata(clientCtx, outCtx)
if _, ok := metadata.FromOutgoingContext(outgoingCtx); !ok {
clientCtx = copyMetadata(clientCtx, outgoingCtx)
}
// TODO(mwitkow): Add a `forwarded` header to metadata, https://en.wikipedia.org/wiki/X-Forwarded-For.
clientStream, err := grpc.NewClientStream(clientCtx, clientStreamDescForProxying, backendConn, fullMethodName)
Expand Down

0 comments on commit a14498f

Please sign in to comment.