Browse Source

client: unexport httpClient interface

Brian Waldon 11 years ago
parent
commit
bac1d2f420
4 changed files with 14 additions and 13 deletions
  1. 6 5
      client/http.go
  2. 2 2
      client/http_test.go
  3. 4 4
      client/keys.go
  4. 2 2
      client/members.go

+ 6 - 5
client/http.go

@@ -37,7 +37,7 @@ var (
 )
 
 func newHTTPClientFactory(tr CancelableTransport) httpClientFactory {
-	return func(ep url.URL) HTTPClient {
+	return func(ep url.URL) httpClient {
 		return &redirectFollowingHTTPClient{
 			max: DefaultMaxRedirects,
 			client: &simpleHTTPClient{
@@ -62,16 +62,17 @@ func New(cfg Config) (SyncableHTTPClient, error) {
 }
 
 type SyncableHTTPClient interface {
-	HTTPClient
 	Sync(context.Context) error
 	Endpoints() []string
+
+	httpClient
 }
 
-type HTTPClient interface {
+type httpClient interface {
 	Do(context.Context, httpAction) (*http.Response, []byte, error)
 }
 
-type httpClientFactory func(url.URL) HTTPClient
+type httpClientFactory func(url.URL) httpClient
 
 type httpAction interface {
 	HTTPRequest(url.URL) *http.Request
@@ -225,7 +226,7 @@ func (c *simpleHTTPClient) Do(ctx context.Context, act httpAction) (*http.Respon
 }
 
 type redirectFollowingHTTPClient struct {
-	client HTTPClient
+	client httpClient
 	max    int
 }
 

+ 2 - 2
client/http_test.go

@@ -62,7 +62,7 @@ func (s *multiStaticHTTPClient) Do(context.Context, httpAction) (*http.Response,
 
 func newStaticHTTPClientFactory(responses []staticHTTPResponse) httpClientFactory {
 	var cur int
-	return func(url.URL) HTTPClient {
+	return func(url.URL) httpClient {
 		r := responses[cur]
 		cur++
 		return &staticHTTPClient{resp: r.resp, err: r.err}
@@ -350,7 +350,7 @@ func TestRedirectedHTTPAction(t *testing.T) {
 func TestRedirectFollowingHTTPClient(t *testing.T) {
 	tests := []struct {
 		max      int
-		client   HTTPClient
+		client   httpClient
 		wantCode int
 		wantErr  error
 	}{

+ 4 - 4
client/keys.go

@@ -47,14 +47,14 @@ var (
 	ErrKeyExists   = errors.New("client: key already exists")
 )
 
-func NewKeysAPI(c HTTPClient) KeysAPI {
+func NewKeysAPI(c SyncableHTTPClient) KeysAPI {
 	return &httpKeysAPI{
 		client: c,
 		prefix: DefaultV2KeysPrefix,
 	}
 }
 
-func NewDiscoveryKeysAPI(c HTTPClient) KeysAPI {
+func NewDiscoveryKeysAPI(c SyncableHTTPClient) KeysAPI {
 	return &httpKeysAPI{
 		client: c,
 		prefix: "",
@@ -117,7 +117,7 @@ func (n *Node) String() string {
 }
 
 type httpKeysAPI struct {
-	client HTTPClient
+	client httpClient
 	prefix string
 }
 
@@ -219,7 +219,7 @@ func (k *httpKeysAPI) Watcher(key string, opts *WatcherOptions) Watcher {
 }
 
 type httpWatcher struct {
-	client   HTTPClient
+	client   httpClient
 	nextWait waitAction
 }
 

+ 2 - 2
client/members.go

@@ -31,7 +31,7 @@ var (
 	DefaultV2MembersPrefix = "/v2/members"
 )
 
-func NewMembersAPI(c HTTPClient) MembersAPI {
+func NewMembersAPI(c SyncableHTTPClient) MembersAPI {
 	return &httpMembersAPI{
 		client: c,
 	}
@@ -44,7 +44,7 @@ type MembersAPI interface {
 }
 
 type httpMembersAPI struct {
-	client HTTPClient
+	client httpClient
 }
 
 func (m *httpMembersAPI) List(ctx context.Context) ([]httptypes.Member, error) {