Remove Go1.6 support (#1492)
This commit is contained in:
@ -1,7 +1,6 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
- 1.6.x
|
|
||||||
- 1.7.x
|
- 1.7.x
|
||||||
- 1.8.x
|
- 1.8.x
|
||||||
- 1.9.x
|
- 1.9.x
|
||||||
|
@ -16,7 +16,7 @@ $ go get -u google.golang.org/grpc
|
|||||||
Prerequisites
|
Prerequisites
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
This requires Go 1.6 or later.
|
This requires Go 1.7 or later.
|
||||||
|
|
||||||
Constraints
|
Constraints
|
||||||
-----------
|
-----------
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
// +build go1.6,!go1.7
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2017 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package benchmark
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
"testing"
|
|
||||||
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/benchmark/stats"
|
|
||||||
)
|
|
||||||
|
|
||||||
func BenchmarkClientStreamc1(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 1, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamc8(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 8, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamc64(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 64, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamc512(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 512, 1, 1, false})
|
|
||||||
}
|
|
||||||
func BenchmarkClientUnaryc1(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 1, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientUnaryc8(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 8, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientUnaryc64(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 64, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientUnaryc512(b *testing.B) {
|
|
||||||
grpc.EnableTracing = true
|
|
||||||
runStream(b, stats.Features{"", true, 0, 0, 0, 512, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamNoTracec1(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 1, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamNoTracec8(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 8, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamNoTracec64(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 64, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientStreamNoTracec512(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 512, 1, 1, false})
|
|
||||||
}
|
|
||||||
func BenchmarkClientUnaryNoTracec1(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 1, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientUnaryNoTracec8(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 8, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientUnaryNoTracec64(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 64, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func BenchmarkClientUnaryNoTracec512(b *testing.B) {
|
|
||||||
grpc.EnableTracing = false
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 512, 1, 1, false})
|
|
||||||
runStream(b, stats.Features{"", false, 0, 0, 0, 512, 1, 1, false})
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestMain(m *testing.M) {
|
|
||||||
os.Exit(stats.RunTestMain(m))
|
|
||||||
}
|
|
@ -378,7 +378,7 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
|||||||
if cc.dopts.copts.Dialer == nil {
|
if cc.dopts.copts.Dialer == nil {
|
||||||
cc.dopts.copts.Dialer = newProxyDialer(
|
cc.dopts.copts.Dialer = newProxyDialer(
|
||||||
func(ctx context.Context, addr string) (net.Conn, error) {
|
func(ctx context.Context, addr string) (net.Conn, error) {
|
||||||
return dialContext(ctx, "tcp", addr)
|
return (&net.Dialer{}).DialContext(ctx, "tcp", addr)
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ For this sample, we've already generated the server and client stubs from [hello
|
|||||||
PREREQUISITES
|
PREREQUISITES
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
- This requires Go 1.5 or later
|
- This requires Go 1.7 or later
|
||||||
- Requires that [GOPATH is set](https://golang.org/doc/code.html#GOPATH)
|
- Requires that [GOPATH is set](https://golang.org/doc/code.html#GOPATH)
|
||||||
|
|
||||||
```
|
```
|
||||||
|
98
go16.go
98
go16.go
@ -1,98 +0,0 @@
|
|||||||
// +build go1.6,!go1.7
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2016 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package grpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
"google.golang.org/grpc/transport"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dialContext connects to the address on the named network.
|
|
||||||
func dialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
||||||
return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address)
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error {
|
|
||||||
req.Cancel = ctx.Done()
|
|
||||||
if err := req.Write(conn); err != nil {
|
|
||||||
return fmt.Errorf("failed to write the HTTP request: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// toRPCErr converts an error into an error from the status package.
|
|
||||||
func toRPCErr(err error) error {
|
|
||||||
if _, ok := status.FromError(err); ok {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
switch e := err.(type) {
|
|
||||||
case transport.StreamError:
|
|
||||||
return status.Error(e.Code, e.Desc)
|
|
||||||
case transport.ConnectionError:
|
|
||||||
return status.Error(codes.Unavailable, e.Desc)
|
|
||||||
default:
|
|
||||||
switch err {
|
|
||||||
case context.DeadlineExceeded:
|
|
||||||
return status.Error(codes.DeadlineExceeded, err.Error())
|
|
||||||
case context.Canceled:
|
|
||||||
return status.Error(codes.Canceled, err.Error())
|
|
||||||
case ErrClientConnClosing:
|
|
||||||
return status.Error(codes.FailedPrecondition, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status.Error(codes.Unknown, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// convertCode converts a standard Go error into its canonical code. Note that
|
|
||||||
// this is only used to translate the error returned by the server applications.
|
|
||||||
func convertCode(err error) codes.Code {
|
|
||||||
switch err {
|
|
||||||
case nil:
|
|
||||||
return codes.OK
|
|
||||||
case io.EOF:
|
|
||||||
return codes.OutOfRange
|
|
||||||
case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF:
|
|
||||||
return codes.FailedPrecondition
|
|
||||||
case os.ErrInvalid:
|
|
||||||
return codes.InvalidArgument
|
|
||||||
case context.Canceled:
|
|
||||||
return codes.Canceled
|
|
||||||
case context.DeadlineExceeded:
|
|
||||||
return codes.DeadlineExceeded
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case os.IsExist(err):
|
|
||||||
return codes.AlreadyExists
|
|
||||||
case os.IsNotExist(err):
|
|
||||||
return codes.NotFound
|
|
||||||
case os.IsPermission(err):
|
|
||||||
return codes.PermissionDenied
|
|
||||||
}
|
|
||||||
return codes.Unknown
|
|
||||||
}
|
|
99
go17.go
99
go17.go
@ -1,99 +0,0 @@
|
|||||||
// +build go1.7
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2016 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package grpc
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
netctx "golang.org/x/net/context"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
"google.golang.org/grpc/transport"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dialContext connects to the address on the named network.
|
|
||||||
func dialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
||||||
return (&net.Dialer{}).DialContext(ctx, network, address)
|
|
||||||
}
|
|
||||||
|
|
||||||
func sendHTTPRequest(ctx context.Context, req *http.Request, conn net.Conn) error {
|
|
||||||
req = req.WithContext(ctx)
|
|
||||||
if err := req.Write(conn); err != nil {
|
|
||||||
return fmt.Errorf("failed to write the HTTP request: %v", err)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// toRPCErr converts an error into an error from the status package.
|
|
||||||
func toRPCErr(err error) error {
|
|
||||||
if _, ok := status.FromError(err); ok {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
switch e := err.(type) {
|
|
||||||
case transport.StreamError:
|
|
||||||
return status.Error(e.Code, e.Desc)
|
|
||||||
case transport.ConnectionError:
|
|
||||||
return status.Error(codes.Unavailable, e.Desc)
|
|
||||||
default:
|
|
||||||
switch err {
|
|
||||||
case context.DeadlineExceeded, netctx.DeadlineExceeded:
|
|
||||||
return status.Error(codes.DeadlineExceeded, err.Error())
|
|
||||||
case context.Canceled, netctx.Canceled:
|
|
||||||
return status.Error(codes.Canceled, err.Error())
|
|
||||||
case ErrClientConnClosing:
|
|
||||||
return status.Error(codes.FailedPrecondition, err.Error())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return status.Error(codes.Unknown, err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
// convertCode converts a standard Go error into its canonical code. Note that
|
|
||||||
// this is only used to translate the error returned by the server applications.
|
|
||||||
func convertCode(err error) codes.Code {
|
|
||||||
switch err {
|
|
||||||
case nil:
|
|
||||||
return codes.OK
|
|
||||||
case io.EOF:
|
|
||||||
return codes.OutOfRange
|
|
||||||
case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF:
|
|
||||||
return codes.FailedPrecondition
|
|
||||||
case os.ErrInvalid:
|
|
||||||
return codes.InvalidArgument
|
|
||||||
case context.Canceled, netctx.Canceled:
|
|
||||||
return codes.Canceled
|
|
||||||
case context.DeadlineExceeded, netctx.DeadlineExceeded:
|
|
||||||
return codes.DeadlineExceeded
|
|
||||||
}
|
|
||||||
switch {
|
|
||||||
case os.IsExist(err):
|
|
||||||
return codes.AlreadyExists
|
|
||||||
case os.IsNotExist(err):
|
|
||||||
return codes.NotFound
|
|
||||||
case os.IsPermission(err):
|
|
||||||
return codes.PermissionDenied
|
|
||||||
}
|
|
||||||
return codes.Unknown
|
|
||||||
}
|
|
@ -1,4 +1,4 @@
|
|||||||
// +build go1.6, !go1.8
|
// +build go1.7, !go1.8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// +build go1.6, !go1.8
|
// +build go1.7, !go1.8
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
3
proxy.go
3
proxy.go
@ -82,7 +82,8 @@ func doHTTPConnectHandshake(ctx context.Context, conn net.Conn, addr string) (_
|
|||||||
Header: map[string][]string{"User-Agent": {grpcUA}},
|
Header: map[string][]string{"User-Agent": {grpcUA}},
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := sendHTTPRequest(ctx, req, conn); err != nil {
|
req = req.WithContext(ctx)
|
||||||
|
if err := req.Write(conn); err != nil {
|
||||||
return nil, fmt.Errorf("failed to write the HTTP request: %v", err)
|
return nil, fmt.Errorf("failed to write the HTTP request: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
53
rpc_util.go
53
rpc_util.go
@ -21,10 +21,12 @@ package grpc
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
|
stdctx "context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math"
|
"math"
|
||||||
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -410,6 +412,57 @@ func updateRPCInfoInContext(ctx context.Context, s rpcInfo) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// toRPCErr converts an error into an error from the status package.
|
||||||
|
func toRPCErr(err error) error {
|
||||||
|
if _, ok := status.FromError(err); ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
switch e := err.(type) {
|
||||||
|
case transport.StreamError:
|
||||||
|
return status.Error(e.Code, e.Desc)
|
||||||
|
case transport.ConnectionError:
|
||||||
|
return status.Error(codes.Unavailable, e.Desc)
|
||||||
|
default:
|
||||||
|
switch err {
|
||||||
|
case context.DeadlineExceeded, stdctx.DeadlineExceeded:
|
||||||
|
return status.Error(codes.DeadlineExceeded, err.Error())
|
||||||
|
case context.Canceled, stdctx.Canceled:
|
||||||
|
return status.Error(codes.Canceled, err.Error())
|
||||||
|
case ErrClientConnClosing:
|
||||||
|
return status.Error(codes.FailedPrecondition, err.Error())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return status.Error(codes.Unknown, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
// convertCode converts a standard Go error into its canonical code. Note that
|
||||||
|
// this is only used to translate the error returned by the server applications.
|
||||||
|
func convertCode(err error) codes.Code {
|
||||||
|
switch err {
|
||||||
|
case nil:
|
||||||
|
return codes.OK
|
||||||
|
case io.EOF:
|
||||||
|
return codes.OutOfRange
|
||||||
|
case io.ErrClosedPipe, io.ErrNoProgress, io.ErrShortBuffer, io.ErrShortWrite, io.ErrUnexpectedEOF:
|
||||||
|
return codes.FailedPrecondition
|
||||||
|
case os.ErrInvalid:
|
||||||
|
return codes.InvalidArgument
|
||||||
|
case context.Canceled, stdctx.Canceled:
|
||||||
|
return codes.Canceled
|
||||||
|
case context.DeadlineExceeded, stdctx.DeadlineExceeded:
|
||||||
|
return codes.DeadlineExceeded
|
||||||
|
}
|
||||||
|
switch {
|
||||||
|
case os.IsExist(err):
|
||||||
|
return codes.AlreadyExists
|
||||||
|
case os.IsNotExist(err):
|
||||||
|
return codes.NotFound
|
||||||
|
case os.IsPermission(err):
|
||||||
|
return codes.PermissionDenied
|
||||||
|
}
|
||||||
|
return codes.Unknown
|
||||||
|
}
|
||||||
|
|
||||||
// Code returns the error code for err if it was produced by the rpc system.
|
// Code returns the error code for err if it was produced by the rpc system.
|
||||||
// Otherwise, it returns codes.Unknown.
|
// Otherwise, it returns codes.Unknown.
|
||||||
//
|
//
|
||||||
|
@ -2874,7 +2874,7 @@ func TestRetry(t *testing.T) {
|
|||||||
defer leakcheck.Check(t)
|
defer leakcheck.Check(t)
|
||||||
for _, e := range listTestEnv() {
|
for _, e := range listTestEnv() {
|
||||||
if e.name == "handler-tls" {
|
if e.name == "handler-tls" {
|
||||||
// In race mode, with go1.6, the test never returns with handler_server.
|
// Fails with RST_STREAM / FLOW_CONTROL_ERROR
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
testRetry(t, e)
|
testRetry(t, e)
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
// +build go1.6,!go1.7
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2016 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package transport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
|
|
||||||
"golang.org/x/net/context"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dialContext connects to the address on the named network.
|
|
||||||
func dialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
||||||
return (&net.Dialer{Cancel: ctx.Done()}).Dial(network, address)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContextErr converts the error from context package into a StreamError.
|
|
||||||
func ContextErr(err error) StreamError {
|
|
||||||
switch err {
|
|
||||||
case context.DeadlineExceeded:
|
|
||||||
return streamErrorf(codes.DeadlineExceeded, "%v", err)
|
|
||||||
case context.Canceled:
|
|
||||||
return streamErrorf(codes.Canceled, "%v", err)
|
|
||||||
}
|
|
||||||
return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err)
|
|
||||||
}
|
|
@ -1,46 +0,0 @@
|
|||||||
// +build go1.7
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2016 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package transport
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"net"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
|
|
||||||
netctx "golang.org/x/net/context"
|
|
||||||
)
|
|
||||||
|
|
||||||
// dialContext connects to the address on the named network.
|
|
||||||
func dialContext(ctx context.Context, network, address string) (net.Conn, error) {
|
|
||||||
return (&net.Dialer{}).DialContext(ctx, network, address)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContextErr converts the error from context package into a StreamError.
|
|
||||||
func ContextErr(err error) StreamError {
|
|
||||||
switch err {
|
|
||||||
case context.DeadlineExceeded, netctx.DeadlineExceeded:
|
|
||||||
return streamErrorf(codes.DeadlineExceeded, "%v", err)
|
|
||||||
case context.Canceled, netctx.Canceled:
|
|
||||||
return streamErrorf(codes.Canceled, "%v", err)
|
|
||||||
}
|
|
||||||
return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err)
|
|
||||||
}
|
|
@ -109,7 +109,7 @@ func dial(ctx context.Context, fn func(context.Context, string) (net.Conn, error
|
|||||||
if fn != nil {
|
if fn != nil {
|
||||||
return fn(ctx, addr)
|
return fn(ctx, addr)
|
||||||
}
|
}
|
||||||
return dialContext(ctx, "tcp", addr)
|
return (&net.Dialer{}).DialContext(ctx, "tcp", addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
func isTemporary(err error) bool {
|
func isTemporary(err error) bool {
|
||||||
@ -148,11 +148,9 @@ func newHTTP2Client(ctx context.Context, addr TargetInfo, opts ConnectOptions, t
|
|||||||
ctx, cancel := context.WithCancel(ctx)
|
ctx, cancel := context.WithCancel(ctx)
|
||||||
connectCtx, connectCancel := context.WithTimeout(ctx, timeout)
|
connectCtx, connectCancel := context.WithTimeout(ctx, timeout)
|
||||||
defer func() {
|
defer func() {
|
||||||
|
connectCancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cancel()
|
cancel()
|
||||||
// Don't call connectCancel in success path due to a race in Go 1.6:
|
|
||||||
// https://github.com/golang/go/issues/15078.
|
|
||||||
connectCancel()
|
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
package transport // import "google.golang.org/grpc/transport"
|
package transport // import "google.golang.org/grpc/transport"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
stdctx "context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
@ -718,6 +719,17 @@ func wait(ctx, tctx context.Context, done, goAway <-chan struct{}, proceed <-cha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContextErr converts the error from context package into a StreamError.
|
||||||
|
func ContextErr(err error) StreamError {
|
||||||
|
switch err {
|
||||||
|
case context.DeadlineExceeded, stdctx.DeadlineExceeded:
|
||||||
|
return streamErrorf(codes.DeadlineExceeded, "%v", err)
|
||||||
|
case context.Canceled, stdctx.Canceled:
|
||||||
|
return streamErrorf(codes.Canceled, "%v", err)
|
||||||
|
}
|
||||||
|
return streamErrorf(codes.Internal, "Unexpected error from context packet: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// GoAwayReason contains the reason for the GoAway frame received.
|
// GoAwayReason contains the reason for the GoAway frame received.
|
||||||
type GoAwayReason uint8
|
type GoAwayReason uint8
|
||||||
|
|
||||||
|
1
vet.sh
1
vet.sh
@ -63,7 +63,6 @@ trap cleanup EXIT
|
|||||||
git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":'
|
git ls-files "*.go" | xargs sed -i 's:"golang.org/x/net/context":"context":'
|
||||||
set +o pipefail
|
set +o pipefail
|
||||||
# TODO: Stop filtering pb.go files once golang/protobuf#214 is fixed.
|
# TODO: Stop filtering pb.go files once golang/protobuf#214 is fixed.
|
||||||
# TODO: Remove clientconn exception once go1.6 support is removed.
|
|
||||||
go tool vet -all . 2>&1 | grep -vF '.pb.go:' | tee /dev/stderr | (! read)
|
go tool vet -all . 2>&1 | grep -vF '.pb.go:' | tee /dev/stderr | (! read)
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
git reset --hard HEAD
|
git reset --hard HEAD
|
||||||
|
Reference in New Issue
Block a user