mirror of https://github.com/grpc/grpc-go.git
cleanup: more simplifications (#2574)
This commit is contained in:
parent
4e92c060da
commit
59acad4c45
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
|
|
@ -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}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue