The Go implementation of [gRPC](https://grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the [gRPC Quick Start: Go](https://grpc.io/docs/quickstart/go.html) guide.
The Go implementation of [gRPC](https://grpc.io/): A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the [gRPC Quick Start: Go](https://grpc.io/docs/quickstart/go.html) guide.
...
@@ -16,7 +16,8 @@ $ go get -u google.golang.org/grpc
...
@@ -16,7 +16,8 @@ $ go get -u google.golang.org/grpc
Prerequisites
Prerequisites
-------------
-------------
This requires Go 1.7 or later.
This requires Go 1.6 or later. Go 1.7 will be required as of the next gRPC-Go
_"google.golang.org/grpc/balancer/roundrobin"// To register roundrobin.
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/grpclog"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/keepalive"
"google.golang.org/grpc/resolver"
"google.golang.org/grpc/resolver"
_"google.golang.org/grpc/resolver/dns"// To register dns resolver.
_"google.golang.org/grpc/resolver/passthrough"// To register passthrough resolver.
"google.golang.org/grpc/stats"
"google.golang.org/grpc/stats"
"google.golang.org/grpc/transport"
"google.golang.org/grpc/transport"
)
)
...
@@ -48,7 +51,20 @@ var (
...
@@ -48,7 +51,20 @@ var (
// underlying connections within the specified timeout.
// underlying connections within the specified timeout.
// DEPRECATED: Please use context.DeadlineExceeded instead.
// DEPRECATED: Please use context.DeadlineExceeded instead.
ErrClientConnTimeout=errors.New("grpc: timed out when dialing")
ErrClientConnTimeout=errors.New("grpc: timed out when dialing")
// errConnDrain indicates that the connection starts to be drained and does not accept any new RPCs.
errConnDrain=errors.New("grpc: the connection is drained")
// errConnClosing indicates that the connection is closing.
errConnClosing=errors.New("grpc: the connection is closing")
// errConnUnavailable indicates that the connection is unavailable.
errConnUnavailable=errors.New("grpc: the connection is unavailable")
// errBalancerClosed indicates that the balancer is closed.
errBalancerClosed=errors.New("grpc: balancer is closed")
// minimum time to give a connection to complete
minConnectTimeout=20*time.Second
)
// The following errors are returned from Dial and DialContext
var(
// errNoTransportSecurity indicates that there is no transport security
// errNoTransportSecurity indicates that there is no transport security
// being set for ClientConn. Users should either set one or explicitly
// being set for ClientConn. Users should either set one or explicitly
// call WithInsecure DialOption to disable security.
// call WithInsecure DialOption to disable security.
...
@@ -62,16 +78,6 @@ var (
...
@@ -62,16 +78,6 @@ var (
errCredentialsConflict=errors.New("grpc: transport credentials are set for an insecure connection (grpc.WithTransportCredentials() and grpc.WithInsecure() are both called)")
errCredentialsConflict=errors.New("grpc: transport credentials are set for an insecure connection (grpc.WithTransportCredentials() and grpc.WithInsecure() are both called)")
// errNetworkIO indicates that the connection is down due to some network I/O error.
// errNetworkIO indicates that the connection is down due to some network I/O error.
errNetworkIO=errors.New("grpc: failed with network I/O error")
errNetworkIO=errors.New("grpc: failed with network I/O error")
// errConnDrain indicates that the connection starts to be drained and does not accept any new RPCs.
errConnDrain=errors.New("grpc: the connection is drained")
// errConnClosing indicates that the connection is closing.
errConnClosing=errors.New("grpc: the connection is closing")
// errConnUnavailable indicates that the connection is unavailable.
errConnUnavailable=errors.New("grpc: the connection is unavailable")
// errBalancerClosed indicates that the balancer is closed.
errBalancerClosed=errors.New("grpc: balancer is closed")
// minimum time to give a connection to complete
minConnectTimeout=20*time.Second
)
)
// dialOptions configure a Dial call. dialOptions are set by the DialOption
// dialOptions configure a Dial call. dialOptions are set by the DialOption
...
@@ -89,8 +95,14 @@ type dialOptions struct {
...
@@ -89,8 +95,14 @@ type dialOptions struct {
scChan<-chanServiceConfig
scChan<-chanServiceConfig
coptstransport.ConnectOptions
coptstransport.ConnectOptions
callOptions[]CallOption
callOptions[]CallOption
// This is to support v1 balancer.
// This is used by v1 balancer dial option WithBalancer to support v1
// balancer, and also by WithBalancerName dial option.
balancerBuilderbalancer.Builder
balancerBuilderbalancer.Builder
// This is to support grpclb.
resolverBuilderresolver.Builder
// Custom user options for resolver.Build.
resolverBuildUserOptionsinterface{}
waitForHandshakebool
}
}
const(
const(
...
@@ -101,6 +113,15 @@ const (
...
@@ -101,6 +113,15 @@ const (
// DialOption configures how we set up the connection.
// DialOption configures how we set up the connection.
typeDialOptionfunc(*dialOptions)
typeDialOptionfunc(*dialOptions)
// WithWaitForHandshake blocks until the initial settings frame is received from the
// server before assigning RPCs to the connection.
// Experimental API.
funcWithWaitForHandshake()DialOption{
returnfunc(o*dialOptions){
o.waitForHandshake=true
}
}
// WithWriteBufferSize lets you set the size of write buffer, this determines how much data can be batched
// WithWriteBufferSize lets you set the size of write buffer, this determines how much data can be batched
return0,nil,Errorf(codes.ResourceExhausted,"grpc: received message larger than max (%d vs. %d)",length,maxReceiveMessageSize)
return0,nil,status.Errorf(codes.ResourceExhausted,"grpc: received message larger than max length allowed on current machine (%d vs. %d)",length,maxInt)
}
ifint(length)>maxReceiveMessageSize{
return0,nil,status.Errorf(codes.ResourceExhausted,"grpc: received message larger than max (%d vs. %d)",length,maxReceiveMessageSize)
}
}
// TODO(bradfitz,zhaoq): garbage. reuse buffer after proto decoding instead
// TODO(bradfitz,zhaoq): garbage. reuse buffer after proto decoding instead