func NewExponentialBackoff(initialTimeout, maxTimeout time.Duration, exponentFactor float64) Backoff {
	return &exponentialBackoff{
		exponentFactor: exponentFactor,
		initialTimeout: float64(initialTimeout / time.Millisecond),
		maxTimeout:     float64(maxTimeout / time.Millisecond),
	}
}
NewExponentialBackoff returns an instance of ExponentialBackoff
package backoff
import (
	"math"
	"time"
	"github.com/quan-xie/tuba/util/xtime"
)
type Backoff interface {
	Next(retry int) time.Duration
}
type constantBackoff struct {
	backoffInterval xtime.Duration
}
func NewConstantBackoff(backoffInterval xtime.Duration) Backoff {
	return &constantBackoff{backoffInterval: backoffInterval}
}
func (cb *constantBackoff) Next(retry int) time.Duration {
	if retry <= 0 {
		return 0 * time.Millisecond
	}
	return time.Duration(cb.backoffInterval) * 1 << uint(retry)
}
type exponentialBackoff struct {
	exponentFactor float64
	initialTimeout float64
	maxTimeout     float64
}