go get -u go.devnw.com/bk/v2@latestVersion 2 changes the API for Bridgekeeper to using a direct function literal
in the New function so that it can accept both the Do and RoundTrip
functions from the http.Client and http.Transport respectively. This
allows for Bridgekeeper to support connections where a custom http.Transport
is may be required, for example, when using a custom TLS configuration.
client := bk.New(
ctx, // Your application context
http.DefaultClient.Do, // Your HTTP Client Do function (http.Client.Do)
time.Millisecond, // Delay between requests
5, // Retry count
10, // Concurrent request limit
http.DefaultClient.Timeout, // Request timeout
)
resp, err := client.Do(http.NewRequest(http.MethodGet, "localhost:5555"))
if err != nil {
log.Fatal(err)
} client := bk.New(
ctx, // Your application context
http.DefaultTransport.RoundTrip, // Your HTTP Transport
time.Millisecond, // Delay between requests
5, // Retry count
10, // Concurrent request limit
http.DefaultClient.Timeout, // Request timeout
)
resp, err := client.RoundTrip(http.NewRequest(http.MethodGet, "localhost:5555"))
if err != nil {
log.Fatal(err)
}NOTE: Bridgekeeper Returns a Do / RoundTrip Compliant HTTP Client