]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blobdiff - vendor/google.golang.org/grpc/balancer.go
Upgrade to 0.12
[github/fretlink/terraform-provider-statuscake.git] / vendor / google.golang.org / grpc / balancer.go
index cde472c8120a7f978b6b908e50c5cd30a8109bde..a78e702baee3e06c4179f8cb399d774ff489a194 100644 (file)
 package grpc
 
 import (
-       "fmt"
+       "context"
        "net"
        "sync"
 
-       "golang.org/x/net/context"
        "google.golang.org/grpc/codes"
        "google.golang.org/grpc/credentials"
        "google.golang.org/grpc/grpclog"
        "google.golang.org/grpc/naming"
+       "google.golang.org/grpc/status"
 )
 
 // Address represents a server the client connects to.
-// This is the EXPERIMENTAL API and may be changed or extended in the future.
+//
+// Deprecated: please use package balancer.
 type Address struct {
        // Addr is the server address on which a connection will be established.
        Addr string
@@ -41,6 +42,8 @@ type Address struct {
 }
 
 // BalancerConfig specifies the configurations for Balancer.
+//
+// Deprecated: please use package balancer.
 type BalancerConfig struct {
        // DialCreds is the transport credential the Balancer implementation can
        // use to dial to a remote load balancer server. The Balancer implementations
@@ -53,7 +56,8 @@ type BalancerConfig struct {
 }
 
 // BalancerGetOptions configures a Get call.
-// This is the EXPERIMENTAL API and may be changed or extended in the future.
+//
+// Deprecated: please use package balancer.
 type BalancerGetOptions struct {
        // BlockingWait specifies whether Get should block when there is no
        // connected address.
@@ -61,7 +65,8 @@ type BalancerGetOptions struct {
 }
 
 // Balancer chooses network addresses for RPCs.
-// This is the EXPERIMENTAL API and may be changed or extended in the future.
+//
+// Deprecated: please use package balancer.
 type Balancer interface {
        // Start does the initialization work to bootstrap a Balancer. For example,
        // this function may start the name resolution and watch the updates. It will
@@ -112,28 +117,10 @@ type Balancer interface {
        Close() error
 }
 
-// downErr implements net.Error. It is constructed by gRPC internals and passed to the down
-// call of Balancer.
-type downErr struct {
-       timeout   bool
-       temporary bool
-       desc      string
-}
-
-func (e downErr) Error() string   { return e.desc }
-func (e downErr) Timeout() bool   { return e.timeout }
-func (e downErr) Temporary() bool { return e.temporary }
-
-func downErrorf(timeout, temporary bool, format string, a ...interface{}) downErr {
-       return downErr{
-               timeout:   timeout,
-               temporary: temporary,
-               desc:      fmt.Sprintf(format, a...),
-       }
-}
-
 // RoundRobin returns a Balancer that selects addresses round-robin. It uses r to watch
 // the name resolution updates and updates the addresses available correspondingly.
+//
+// Deprecated: please use package balancer/roundrobin.
 func RoundRobin(r naming.Resolver) Balancer {
        return &roundRobin{r: r}
 }
@@ -310,7 +297,7 @@ func (rr *roundRobin) Get(ctx context.Context, opts BalancerGetOptions) (addr Ad
        if !opts.BlockingWait {
                if len(rr.addrs) == 0 {
                        rr.mu.Unlock()
-                       err = Errorf(codes.Unavailable, "there is no address available")
+                       err = status.Errorf(codes.Unavailable, "there is no address available")
                        return
                }
                // Returns the next addr on rr.addrs for failfast RPCs.
@@ -395,3 +382,10 @@ func (rr *roundRobin) Close() error {
        }
        return nil
 }
+
+// pickFirst is used to test multi-addresses in one addrConn in which all addresses share the same addrConn.
+// It is a wrapper around roundRobin balancer. The logic of all methods works fine because balancer.Get()
+// returns the only address Up by resetTransport().
+type pickFirst struct {
+       *roundRobin
+}