netflix.ocelli.functions.Retrys Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ocelli-core Show documentation
Show all versions of ocelli-core Show documentation
ocelli-core developed by Netflix
package netflix.ocelli.functions;
import java.util.concurrent.TimeUnit;
import netflix.ocelli.retrys.ExponentialBackoff;
import rx.Observable;
import rx.functions.Func1;
public abstract class Retrys {
public static Func1 ALWAYS_TRUE = new Func1() {
@Override
public Boolean call(Throwable t1) {
return true;
}
};
public static Func1 ALWAYS_FALSE = new Func1() {
@Override
public Boolean call(Throwable t1) {
return false;
}
};
/**
* Exponential backoff
* @param maxRetrys
* @param timeslice
* @param units
* @return
*/
public static Func1, Observable>> exponentialBackoff(final int maxRetrys, final long timeslice, final TimeUnit units) {
return new ExponentialBackoff(maxRetrys, timeslice, -1, units, ALWAYS_TRUE);
}
/**
* Bounded exponential backoff
* @param maxRetrys
* @param timeslice
* @param units
* @return
*/
public static Func1, Observable>> exponentialBackoff(final int maxRetrys, final long timeslice, final TimeUnit units, final long maxDelay) {
return new ExponentialBackoff(maxRetrys, timeslice, maxDelay, units, ALWAYS_TRUE);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy