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

@ -48,6 +48,7 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/transport"
)
@ -141,6 +142,7 @@ type callInfo struct {
headerMD metadata.MD
trailerMD metadata.MD
traceInfo traceInfo // in trace.go
peer peer.Peer
}
var defaultCallInfo = callInfo{failFast: true}
@ -183,6 +185,13 @@ func Trailer(md *metadata.MD) CallOption {
})
}
// Peer returns a CallOption that retrieves peer information.
func Peer(peer *peer.Peer) CallOption {
return afterCall(func(c *callInfo) {
*peer = c.peer
})
}
// FailFast configures the action to take when an RPC is attempted on broken
// connections or unreachable servers. If failfast is true, the RPC will fail
// immediately. Otherwise, the RPC client will block the call until a