Adding dial options for PerRPCCredentials (#1225)

* Adding dial options for PerRPCCredentials

* Added tests for PerRPCCredentials

* Post-review updates

* post-review updates
This commit is contained in:
MakMukhi
2017-05-11 11:07:38 -07:00
committed by GitHub
parent 07bd9434fa
commit 88a73d35c9
6 changed files with 184 additions and 9 deletions

View File

@ -46,6 +46,7 @@ import (
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
"google.golang.org/grpc/stats"
@ -141,6 +142,7 @@ type callInfo struct {
trailerMD metadata.MD
peer *peer.Peer
traceInfo traceInfo // in trace.go
creds credentials.PerRPCCredentials
}
var defaultCallInfo = callInfo{failFast: true}
@ -207,6 +209,15 @@ func FailFast(failFast bool) CallOption {
})
}
// PerRPCCredentials returns a CallOption that sets credentials.PerRPCCredentials
// for a call.
func PerRPCCredentials(creds credentials.PerRPCCredentials) CallOption {
return beforeCall(func(c *callInfo) error {
c.creds = creds
return nil
})
}
// The format of the payload: compressed or not?
type payloadFormat uint8