-
Notifications
You must be signed in to change notification settings - Fork 14
/
Directive.java
51 lines (44 loc) · 1.38 KB
/
Directive.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package net.jodah.sarge;
import net.jodah.sarge.internal.RetryDirective;
import java.time.Duration;
/**
* Determine how failures should be handled.
*
* @author Jonathan Halterman
*/
public class Directive {
/**
* Resume supervision, re-throwing the failure from the point of invocation if a result is
* expected.
*/
public static final Directive Resume = new Directive() {
@Override
public String toString() {
return "Resume Directive";
}
};
/** Re-throws the failure from the point of invocation. */
public static final Directive Rethrow = new Directive() {
@Override
public String toString() {
return "Rethrow Directive";
}
};
/** Escalates the failure to the supervisor of the supervisor. */
public static final Directive Escalate = new Directive() {
@Override
public String toString() {
return "Escalate Directive";
}
};
/** Retries the method invocation. */
public static Directive Retry(int maxRetries, Duration retryWindow) {
return new RetryDirective(maxRetries, retryWindow);
}
/** Retries the method invocation. */
public static Directive Retry(int maxRetries, Duration retryWindow,
Duration initialRetryInterval, double backoffExponent, Duration maxRetryInterval) {
return new RetryDirective(maxRetries, retryWindow, initialRetryInterval, backoffExponent,
maxRetryInterval);
}
}