func (c Client) newRetryTimer(ctx context.Context, maxRetry int, unit time.Duration, cap time.Duration, jitter float64) <-chan int {
	attemptCh := make(chan int)
	exponentialBackoffWait := func(attempt int) time.Duration {
		if jitter < NoJitter {
			jitter = NoJitter
		}
		if jitter > MaxJitter {
			jitter = MaxJitter
		}
		sleep := unit * time.Duration(1<<uint(attempt))
		if sleep > cap {
			sleep = cap
		}
		if jitter != NoJitter {
			sleep -= time.Duration(c.random.Float64() * float64(sleep) * jitter)
		}
		return sleep
	}
	go func() {
		defer close(attemptCh)
		for i := 0; i < maxRetry; i++ {
			select {
			case attemptCh <- i + 1:
			case <-ctx.Done():
				return
			}
			select {
			case <-time.After(exponentialBackoffWait(i)):
			case <-ctx.Done():
				return
			}
		}
	}()
	return attemptCh
}
newRetryTimer creates a timer with exponentially increasing
delays until the maximum retry attempts are reached.
package minio
import (
	"context"
	"net/http"
	"time"
)
var MaxRetry = 10
const MaxJitter = 1.0
const NoJitter = 0.0
const DefaultRetryUnit = time.Second
const DefaultRetryCap = time.Second * 30