Added calloption to retrieve peer information

This commit is contained in:
Mahak Mukhi
2017-02-07 10:41:32 -08:00
parent 21f8ed3094
commit 794873f0a2
2 changed files with 13 additions and 0 deletions

View File

@ -42,6 +42,7 @@ import (
"golang.org/x/net/context"
"golang.org/x/net/trace"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/transport"
)
@ -85,6 +86,9 @@ func recvResponse(ctx context.Context, dopts dialOptions, t transport.ClientTran
dopts.copts.StatsHandler.HandleRPC(ctx, inPayload)
}
c.trailerMD = stream.Trailer()
if peer, ok := peer.FromContext(stream.Context()); ok {
c.peer = *peer
}
return nil
}