All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rbuck.retry.FixedInterval Maven / Gradle / Ivy

Go to download

Lets developers make their applications more resilient by adding robust transient fault handling logic. Transient faults are errors that occur because of some temporary condition such as network connectivity issues or service unavailability. Typically, if you retry the operation that resulted in a transient error a short time later, you find that the error has disappeared.

There is a newer version: 1.2
Show newest version
package com.github.rbuck.retry;

/**
 * Represents a fixed interval RetryStrategy whose time interval is fixed.
 *
 * @author Robert Buck ([email protected])
 */
public class FixedInterval implements RetryStrategy {

    private final int maxRetries;
    private final long retryInterval;
    private int retryCount;

    public FixedInterval(int maxRetries, long retryInterval) {
        this.maxRetries = maxRetries;
        this.retryInterval = retryInterval;
    }

    @Override
    public boolean permitsRetry() {
        if (retryCount < maxRetries) {
            retryCount++;
            return true;
        }
        return false;
    }

    @Override
    public long getRetryDelay() {
        return retryInterval;
    }

    @Override
    public int getRetryCount() {
        return retryCount;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy