Browse Source

Merge pull request #5521 from heyitsanthony/clientv3-hide-retrydial

clientv3: hide retry dial api
Anthony Romano 9 years ago
parent
commit
fb64c8ccfe
2 changed files with 8 additions and 7 deletions
  1. 5 5
      clientv3/client.go
  2. 3 2
      clientv3/config.go

+ 5 - 5
clientv3/client.go

@@ -76,8 +76,8 @@ type Client struct {
 
 // New creates a new etcdv3 client from a given configuration.
 func New(cfg Config) (*Client, error) {
-	if cfg.RetryDialer == nil {
-		cfg.RetryDialer = dialEndpointList
+	if cfg.retryDialer == nil {
+		cfg.retryDialer = dialEndpointList
 	}
 	if len(cfg.Endpoints) == 0 {
 		return nil, ErrNoAvailableEndpoints
@@ -227,7 +227,7 @@ func WithRequireLeader(ctx context.Context) context.Context {
 
 func newClient(cfg *Config) (*Client, error) {
 	if cfg == nil {
-		cfg = &Config{RetryDialer: dialEndpointList}
+		cfg = &Config{retryDialer: dialEndpointList}
 	}
 	var creds *credentials.TransportAuthenticator
 	if cfg.TLS != nil {
@@ -237,7 +237,7 @@ func newClient(cfg *Config) (*Client, error) {
 
 	// use a temporary skeleton client to bootstrap first connection
 	ctx, cancel := context.WithCancel(context.TODO())
-	conn, err := cfg.RetryDialer(&Client{cfg: *cfg, creds: creds, ctx: ctx, Username: cfg.Username, Password: cfg.Password})
+	conn, err := cfg.retryDialer(&Client{cfg: *cfg, creds: creds, ctx: ctx, Username: cfg.Username, Password: cfg.Password})
 	if err != nil {
 		return nil, err
 	}
@@ -301,7 +301,7 @@ func (c *Client) retryConnection(err error) (newConn *grpc.ClientConn, dialErr e
 		return nil, c.ctx.Err()
 	}
 
-	c.conn, dialErr = c.cfg.RetryDialer(c)
+	c.conn, dialErr = c.cfg.retryDialer(c)
 	if dialErr != nil {
 		c.errors = append(c.errors, dialErr)
 	}

+ 3 - 2
clientv3/config.go

@@ -32,8 +32,9 @@ type Config struct {
 	// Endpoints is a list of URLs
 	Endpoints []string
 
-	// RetryDialer chooses the next endpoint to use
-	RetryDialer EndpointDialer
+	// retryDialer chooses the next endpoint to use
+	// keep private until the grpc rebalancer is sorted out
+	retryDialer EndpointDialer
 
 	// DialTimeout is the timeout for failing to establish a connection.
 	DialTimeout time.Duration