Skip to content
Snippets Groups Projects
Commit 7aaddbf8 authored by ale's avatar ale
Browse files

Add docstrings

parent a1a8e639
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ import (
"github.com/cenkalti/backoff"
)
// NewExponentialBackOff creates a backoff.ExponentialBackOff object
// with our own default values.
func NewExponentialBackOff() *backoff.ExponentialBackOff {
b := backoff.NewExponentialBackOff()
b.InitialInterval = 100 * time.Millisecond
......@@ -16,6 +18,7 @@ func NewExponentialBackOff() *backoff.ExponentialBackOff {
return b
}
// Retry operation op until it succeeds according to the backoff policy b.
func Retry(op backoff.Operation, b backoff.BackOff) error {
innerOp := func() error {
err := op()
......@@ -32,6 +35,10 @@ func Retry(op backoff.Operation, b backoff.BackOff) error {
var errHTTPBackOff = errors.New("http status 503")
// RetryHTTPDo retries an HTTP request until it succeeds, according to
// the backoff policy b. It will retry on temporary network errors and
// upon receiving specific throttling HTTP errors (currently just
// status code 503).
func RetryHTTPDo(client *http.Client, req *http.Request, b backoff.BackOff) (*http.Response, error) {
var resp *http.Response
op := func() error {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment