public abstract class Delay extends Object
Parent class of Delay
s and provides factory methods to create them.
Modifier and Type | Method and Description |
---|---|
abstract long |
calculate(long attempt)
Calculate a specific delay based on the attempt passed in.
|
static Delay |
exponential(TimeUnit unit)
Creates a new
ExponentialDelay with default boundaries and factor. |
static Delay |
exponential(TimeUnit unit,
long upper)
Creates a new
ExponentialDelay with custom upper boundary and default factor. |
static Delay |
exponential(TimeUnit unit,
long upper,
long lower)
Creates a new
ExponentialDelay with custom boundaries and default factor. |
static Delay |
exponential(TimeUnit unit,
long upper,
long lower,
long growBy)
Creates a new
ExponentialDelay with custom boundaries and factor. |
static Delay |
fixed(long delay,
TimeUnit unit)
Creates a new
FixedDelay . |
static Delay |
linear(TimeUnit unit)
Creates a new
LinearDelay with no bounds and default factor. |
static Delay |
linear(TimeUnit unit,
long upper)
Creates a new
LinearDelay with a custom upper boundary and the default factor. |
static Delay |
linear(TimeUnit unit,
long upper,
long lower)
Creates a new
LinearDelay with a custom boundaries and the default factor. |
static Delay |
linear(TimeUnit unit,
long upper,
long lower,
long growBy)
Creates a new
LinearDelay with a custom boundaries and factor. |
TimeUnit |
unit()
|
public TimeUnit unit()
public abstract long calculate(long attempt)
Calculate a specific delay based on the attempt passed in.
This method is to be implemented by the child implementations and depending on the params that were set during construction time.
attempt
- the attempt to calculate the delay from.public static Delay fixed(long delay, TimeUnit unit)
Creates a new FixedDelay
.
delay
- the time of the delay.unit
- the unit of the delay.FixedDelay
.public static Delay linear(TimeUnit unit)
Creates a new LinearDelay
with no bounds and default factor.
unit
- the unit of the delay.LinearDelay
.public static Delay linear(TimeUnit unit, long upper)
Creates a new LinearDelay
with a custom upper boundary and the default factor.
unit
- the unit of the delay.upper
- the upper boundary.LinearDelay
.public static Delay linear(TimeUnit unit, long upper, long lower)
Creates a new LinearDelay
with a custom boundaries and the default factor.
unit
- the unit of the delay.upper
- the upper boundary.lower
- the lower boundary.LinearDelay
.public static Delay linear(TimeUnit unit, long upper, long lower, long growBy)
Creates a new LinearDelay
with a custom boundaries and factor.
unit
- the unit of the delay.upper
- the upper boundary.lower
- the lower boundary.growBy
- the multiplication factor.LinearDelay
.public static Delay exponential(TimeUnit unit)
Creates a new ExponentialDelay
with default boundaries and factor.
unit
- the unit of the delay.ExponentialDelay
.public static Delay exponential(TimeUnit unit, long upper)
Creates a new ExponentialDelay
with custom upper boundary and default factor.
unit
- the unit of the delay.upper
- the upper boundary.ExponentialDelay
.public static Delay exponential(TimeUnit unit, long upper, long lower)
Creates a new ExponentialDelay
with custom boundaries and default factor.
unit
- the unit of the delay.upper
- the upper boundary.lower
- the lower boundary.ExponentialDelay
.public static Delay exponential(TimeUnit unit, long upper, long lower, long growBy)
Creates a new ExponentialDelay
with custom boundaries and factor.
unit
- the unit of the delay.upper
- the upper boundary.lower
- the lower boundary.growBy
- the multiplication factor.ExponentialDelay
.Copyright © 2014 Couchbase, Inc.