Skip to content

Commit dccc6b4

Browse files
178inababroady
authored andcommitted
compute/metadata: remove subscribeClient
Since defaultClient and subscribeClient have the same settings, unify to use defaultClient. Fixes #1795 Change-Id: Ia58524ea6d42ca6524c1a7f1b829c5b6731a50c7 Reviewed-on: https://code-review.googlesource.com/c/gocloud/+/52313 Reviewed-by: kokoro <[email protected]> Reviewed-by: Chris Broadfoot <[email protected]>
1 parent b5da5d6 commit dccc6b4

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

compute/metadata/metadata.go

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,24 +61,14 @@ var (
6161
instID = &cachedValue{k: "instance/id", trim: true}
6262
)
6363

64-
var (
65-
defaultClient = &Client{hc: &http.Client{
66-
Transport: &http.Transport{
67-
Dial: (&net.Dialer{
68-
Timeout: 2 * time.Second,
69-
KeepAlive: 30 * time.Second,
70-
}).Dial,
71-
},
72-
}}
73-
subscribeClient = &Client{hc: &http.Client{
74-
Transport: &http.Transport{
75-
Dial: (&net.Dialer{
76-
Timeout: 2 * time.Second,
77-
KeepAlive: 30 * time.Second,
78-
}).Dial,
79-
},
80-
}}
81-
)
64+
var defaultClient = &Client{hc: &http.Client{
65+
Transport: &http.Transport{
66+
Dial: (&net.Dialer{
67+
Timeout: 2 * time.Second,
68+
KeepAlive: 30 * time.Second,
69+
}).Dial,
70+
},
71+
}}
8272

8373
// NotDefinedError is returned when requested metadata is not defined.
8474
//
@@ -205,10 +195,9 @@ func systemInfoSuggestsGCE() bool {
205195
return name == "Google" || name == "Google Compute Engine"
206196
}
207197

208-
// Subscribe calls Client.Subscribe on a client designed for subscribing (one with no
209-
// ResponseHeaderTimeout).
198+
// Subscribe calls Client.Subscribe on the default client.
210199
func Subscribe(suffix string, fn func(v string, ok bool) error) error {
211-
return subscribeClient.Subscribe(suffix, fn)
200+
return defaultClient.Subscribe(suffix, fn)
212201
}
213202

214203
// Get calls Client.Get on the default client.

0 commit comments

Comments
 (0)