INNER CODE UNIT · Go
probeGET
platform-engineering-labs/formae · cmd/bundle-examples/main.go:290
func probeGET(url string) error {
resp, err := httpClient.Get(url)
if err != nil {
return err
}
_, _ = io.Copy(io.Discard, resp.Body)
_ = resp.Body.Close()
if resp.StatusCode != 200 {
return fmt.Errorf("%s", resp.Status)
}
return nil
}
// probeGETWithRetry probes url up to attempts times with exponential backoff
// (base, 2*base, 4*base, ...), returning nil on the first success and the last
// error if all attempts fail.
func probeGETWithRetry(url string, attempts int, base time.Duration) error {
var last error