Skip to content

Commit

Permalink
Merge pull request mwitkow#2 from daniellowtw/master
Browse files Browse the repository at this point in the history
Fix compatibility with latest grpc library
  • Loading branch information
Michal Witkowski authored Jul 25, 2016
2 parents 52be0a5 + e5c3df5 commit 07aeac1
Show file tree
Hide file tree
Showing 4 changed files with 739 additions and 45 deletions.
4 changes: 2 additions & 2 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

type options struct {
creds credentials.Credentials
creds credentials.TransportCredentials
logger grpclog.Logger
maxConcurrentStreams uint32
}
Expand All @@ -43,7 +43,7 @@ func MaxConcurrentStreams(n uint32) ProxyOption {
}

// Creds returns a ProxyOption that sets credentials for server connections.
func Creds(c credentials.Credentials) ProxyOption {
func Creds(c credentials.TransportCredentials) ProxyOption {
return func(o *options) {
o.creds = c
}
Expand Down
11 changes: 11 additions & 0 deletions patch/get_transport.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package grpc

import (
"golang.org/x/net/context"
"google.golang.org/grpc/transport"
)

// GetTransport returns the balancer of the connection.
func (cc *ClientConn) GetTransport(ctx context.Context) (transport.ClientTransport, func(), error) {
return cc.getTransport(ctx, BalancerGetOptions{})
}
7 changes: 4 additions & 3 deletions proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *Proxy) Serve(lis net.Listener) error {
return err
}
var authInfo credentials.AuthInfo = nil
if creds, ok := s.opts.creds.(credentials.TransportAuthenticator); ok {
if creds, ok := s.opts.creds.(credentials.TransportCredentials); ok {
var conn net.Conn
conn, authInfo, err = creds.ServerHandshake(c)
if err != nil {
Expand Down Expand Up @@ -206,8 +206,9 @@ func backendTransportStream(director StreamDirector, ctx context.Context) (trans
return nil, nil, grpc.Errorf(codes.Aborted, "cant dial to backend: %v", err)
}
}
// TODO(michal): ClientConn.Picker() IS NOT IN UPSTREAM GRPC! https://github.com/grpc/grpc-go/pull/397
backendTrans, err := grpcConn.Picker().Pick(ctx)
// TODO(michal): ClientConn.GetTransport() IS NOT IN UPSTREAM GRPC!
// To make this work, copy patch/get_transport.go to google.golang.org/grpc/
backendTrans, _, err := grpcConn.GetTransport(ctx)
frontendStream, _ := transport.StreamFromContext(ctx)
callHdr := &transport.CallHdr{
Method: frontendStream.Method(),
Expand Down
Loading

0 comments on commit 07aeac1

Please sign in to comment.