Browse Source

client: rm naked return from httpClusterClient.Do

Brian Waldon 11 years ago
parent
commit
50a9b2d9c8
1 changed files with 8 additions and 6 deletions
  1. 8 6
      client/client.go

+ 8 - 6
client/client.go

@@ -175,7 +175,7 @@ func (c *httpClusterClient) reset(eps []string) error {
 	return nil
 	return nil
 }
 }
 
 
-func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (resp *http.Response, body []byte, err error) {
+func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (*http.Response, []byte, error) {
 	c.RLock()
 	c.RLock()
 	leps := len(c.endpoints)
 	leps := len(c.endpoints)
 	eps := make([]url.URL, leps)
 	eps := make([]url.URL, leps)
@@ -183,15 +183,17 @@ func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (resp *http.
 	c.RUnlock()
 	c.RUnlock()
 
 
 	if leps == 0 {
 	if leps == 0 {
-		err = ErrNoEndpoints
-		return
+		return nil, nil, ErrNoEndpoints
 	}
 	}
 
 
 	if leps != n {
 	if leps != n {
-		err = errors.New("unable to pick endpoint: copy failed")
-		return
+		return nil, nil, errors.New("unable to pick endpoint: copy failed")
 	}
 	}
 
 
+	var resp *http.Response
+	var body []byte
+	var err error
+
 	for _, ep := range eps {
 	for _, ep := range eps {
 		hc := c.clientFactory(ep)
 		hc := c.clientFactory(ep)
 		resp, body, err = hc.Do(ctx, act)
 		resp, body, err = hc.Do(ctx, act)
@@ -207,7 +209,7 @@ func (c *httpClusterClient) Do(ctx context.Context, act httpAction) (resp *http.
 		break
 		break
 	}
 	}
 
 
-	return
+	return resp, body, err
 }
 }
 
 
 func (c *httpClusterClient) Endpoints() []string {
 func (c *httpClusterClient) Endpoints() []string {