cleanup: more simplifications (#2574)

This commit is contained in:
Doug Fawley 2019-01-16 13:07:56 -08:00 committed by GitHub
parent 4e92c060da
commit 59acad4c45
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 19 deletions

View File

@ -173,10 +173,7 @@ func (s *rpcStats) equal(o *rpcStats) bool {
defer s.mu.Unlock()
o.mu.Lock()
defer o.mu.Unlock()
if !mapsEqual(s.numCallsDropped, o.numCallsDropped) {
return false
}
return true
return mapsEqual(s.numCallsDropped, o.numCallsDropped)
}
type remoteBalancer struct {

View File

@ -96,10 +96,7 @@ func valid(authorization []string) bool {
// Perform the token validation here. For the sake of this example, the code
// here forgoes any of the usual OAuth2 token validation and instead checks
// for a token matching an arbitrary string.
if token != "some-secret-token" {
return false
}
return true
return token == "some-secret-token"
}
// ensureValidToken ensures a valid token exists within a request's metadata. If

View File

@ -89,10 +89,7 @@ func valid(authorization []string) bool {
// Perform the token validation here. For the sake of this example, the code
// here forgoes any of the usual OAuth2 token validation and instead checks
// for a token matching an arbitrary string.
if token != "some-secret-token" {
return false
}
return true
return token == "some-secret-token"
}
func unaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {

View File

@ -111,7 +111,7 @@ type exampleResolver struct {
func (r *exampleResolver) start() {
addrStrs := r.addrsStore[r.target.Endpoint]
addrs := make([]resolver.Address, len(addrStrs), len(addrStrs))
addrs := make([]resolver.Address, len(addrStrs))
for i, s := range addrStrs {
addrs[i] = resolver.Address{Addr: s}
}

View File

@ -119,7 +119,7 @@ type exampleResolver struct {
func (r *exampleResolver) start() {
addrStrs := r.addrsStore[r.target.Endpoint]
addrs := make([]resolver.Address, len(addrStrs), len(addrStrs))
addrs := make([]resolver.Address, len(addrStrs))
for i, s := range addrStrs {
addrs[i] = resolver.Address{Addr: s}
}

View File

@ -377,10 +377,7 @@ func metadataKeyOmit(key string) bool {
case "grpc-trace-bin": // grpc-trace-bin is special because it's visiable to users.
return false
}
if strings.HasPrefix(key, "grpc-") {
return true
}
return false
return strings.HasPrefix(key, "grpc-")
}
func mdToMetadataProto(md metadata.MD) *pb.Metadata {

View File

@ -834,7 +834,7 @@ func doServerSideInitiatedFailedStreamWithClientBreakFlowControl(tc testpb.TestS
}
// sleep here to make sure header frame being sent before the data frame we write directly below.
time.Sleep(10 * time.Millisecond)
payload := make([]byte, 65537, 65537)
payload := make([]byte, 65537)
dw.getRawConnWrapper().writeRawFrame(http2.FrameData, 0, tc.(*testServiceClientWrapper).getCurrentStreamID(), payload)
if _, err := stream.Recv(); err == nil || status.Code(err) != codes.ResourceExhausted {
t.Fatalf("%v.Recv() = %v, want error code: %v", stream, err, codes.ResourceExhausted)