Skip to content

Commit

Permalink
Rename FailsafePolicy -> Policy
Browse files Browse the repository at this point in the history
  • Loading branch information
jhalterman committed Dec 27, 2018
1 parent 5068800 commit c3da210
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/jodah/failsafe/AbstractExecution.java
Expand Up @@ -54,7 +54,7 @@ public abstract class AbstractExecution extends ExecutionContext {
next = buildPolicyExecutor(config.fallback, next);
} else {
// Add policies in user-defined order
ListIterator<FailsafePolicy> policyIterator = config.policies.listIterator(config.policies.size());
ListIterator<Policy> policyIterator = config.policies.listIterator(config.policies.size());
while (policyIterator.hasPrevious())
next = buildPolicyExecutor(policyIterator.previous(), next);
}
Expand All @@ -67,7 +67,7 @@ void inject(Callable<?> callable) {
this.callable = (Callable<Object>) callable;
}

private PolicyExecutor buildPolicyExecutor(FailsafePolicy policy, PolicyExecutor next) {
private PolicyExecutor buildPolicyExecutor(Policy policy, PolicyExecutor next) {
PolicyExecutor policyExecutor = policy.toExecutor();
policyExecutor.execution = this;
policyExecutor.eventHandler = eventHandler;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/jodah/failsafe/AsyncFailsafe.java
Expand Up @@ -23,7 +23,7 @@
import java.util.function.Function;

/**
* Performs asynchronous executions with failures handled according to a configured {@link FailsafePolicy).
* Performs asynchronous executions with failures handled according to a configured {@link Policy).
*
* @author Jonathan Halterman
* @param <R> listener result type
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/jodah/failsafe/CircuitBreaker.java
Expand Up @@ -38,7 +38,7 @@
* @author Jonathan Halterman
*/
@SuppressWarnings("WeakerAccess")
public class CircuitBreaker implements FailsafePolicy {
public class CircuitBreaker implements Policy {
/** Writes guarded by "this" */
private final AtomicReference<CircuitState> state = new AtomicReference<>();
private final AtomicInteger currentExecutions = new AtomicInteger();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/jodah/failsafe/Execution.java
Expand Up @@ -33,7 +33,7 @@ public class Execution extends AbstractExecution {
* @throws NullPointerException if {@code policies} is null
* @throws IllegalArgumentException if {@code policies} is empty
*/
public Execution(FailsafePolicy... policies) {
public Execution(Policy... policies) {
super(new FailsafeConfig<Object, FailsafeConfig<Object, ?>>(Arrays.asList(Assert.notNull(policies, "policies"))));
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/jodah/failsafe/Failsafe.java
Expand Up @@ -55,7 +55,7 @@ public static <T> SyncFailsafe<T> with(CircuitBreaker circuitBreaker) {
* @throws NullPointerException if {@code policies} is null
* @throws IllegalArgumentException if {@code policies} is empty
*/
public static <T> SyncFailsafe<T> with(FailsafePolicy... policies) {
public static <T> SyncFailsafe<T> with(Policy... policies) {
Assert.notNull(policies, "policies");
Assert.isTrue(policies.length > 0, "At least one policy must be supplied");
return new SyncFailsafe<>(Arrays.asList(policies));
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/jodah/failsafe/FailsafeConfig.java
Expand Up @@ -37,13 +37,13 @@ public class FailsafeConfig<R, F> {
CircuitBreaker circuitBreaker;
Fallback fallback;
/** Policies sorted outer-most first */
List<FailsafePolicy> policies;
List<Policy> policies;
ListenerRegistry<R> listeners = new ListenerRegistry<>();

FailsafeConfig() {
}

FailsafeConfig(List<FailsafePolicy> policies) {
FailsafeConfig(List<Policy> policies) {
Assert.isTrue(policies.size() > 0, "At least one policy must be supplied");
this.policies = policies;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/jodah/failsafe/Fallback.java
Expand Up @@ -22,11 +22,11 @@
import java.util.concurrent.Callable;

/**
* A FailsafePolicy that handles failures using a fallback.
* A Policy that handles failures using a fallback.
*
* @author Jonathan Halterman
*/
public class Fallback implements FailsafePolicy {
public class Fallback implements Policy {
private final CheckedBiFunction<Object, Throwable, Object> fallback;

/**
Expand Down
Expand Up @@ -22,6 +22,6 @@
*
* @author Jonathan Halterman
*/
public interface FailsafePolicy {
public interface Policy {
PolicyExecutor toExecutor();
}
2 changes: 1 addition & 1 deletion src/main/java/net/jodah/failsafe/RetryPolicy.java
Expand Up @@ -41,7 +41,7 @@
* @author Jonathan Halterman
*/
@SuppressWarnings("WeakerAccess")
public class RetryPolicy implements FailsafePolicy {
public class RetryPolicy implements Policy {
/**
* A functional interface for computing delays between retries in conjunction with {@link #withDelay(DelayFunction)}.
*
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/jodah/failsafe/SyncFailsafe.java
Expand Up @@ -28,7 +28,7 @@
import java.util.function.Function;

/**
* Performs synchronous executions with failures handled according to a configured {@link FailsafePolicy).
* Performs synchronous executions with failures handled according to a configured {@link Policy).
*
* @author Jonathan Halterman
* @param <R> listener result type
Expand All @@ -42,7 +42,7 @@ public class SyncFailsafe<R> extends FailsafeConfig<R, SyncFailsafe<R>> {
this.retryPolicy = retryPolicy;
}

SyncFailsafe(List<FailsafePolicy> policies) {
SyncFailsafe(List<Policy> policies) {
super(policies);
}

Expand Down

0 comments on commit c3da210

Please sign in to comment.