Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Renamed FailsafeEvent to ExecutionEvent - Implemented ExecutionAttempted and ExecutedCompleted events
- Loading branch information
1 parent
795b91a
commit 45692d5
Showing
14 changed files
with
177 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/net/jodah/failsafe/event/ExecutionAttemptedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.jodah.failsafe.event; | ||
|
||
import net.jodah.failsafe.ExecutionContext; | ||
|
||
/** | ||
* Indicates an execution was attempted. | ||
* | ||
* @param <R> result type | ||
* @author Jonathan Halterman | ||
*/ | ||
public class ExecutionAttemptedEvent<R> extends ExecutionEvent { | ||
private final R result; | ||
private final Throwable failure; | ||
|
||
public ExecutionAttemptedEvent(R result, Throwable failure, ExecutionContext context) { | ||
super(context); | ||
this.result = result; | ||
this.failure = failure; | ||
} | ||
|
||
/** | ||
* Returns the failure that preceeded the event, else {@code null} if there was none. | ||
*/ | ||
public Throwable getLastFailure() { | ||
return failure; | ||
} | ||
|
||
/** | ||
* Returns the result that preceeded the event, else {@code null} if there was none. | ||
*/ | ||
public R getLastResult() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ExecutionAttemptedEvent[" + "result=" + result + ", failure=" + failure + ']'; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/net/jodah/failsafe/event/ExecutionCompletedEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.jodah.failsafe.event; | ||
|
||
import net.jodah.failsafe.ExecutionContext; | ||
|
||
/** | ||
* Indicates an execution was completed. | ||
* | ||
* @param <R> result type | ||
* @author Jonathan Halterman | ||
*/ | ||
public class ExecutionCompletedEvent<R> extends ExecutionEvent { | ||
private final R result; | ||
private final Throwable failure; | ||
|
||
public ExecutionCompletedEvent(R result, Throwable failure, ExecutionContext context) { | ||
super(context); | ||
this.result = result; | ||
this.failure = failure; | ||
} | ||
|
||
/** | ||
* Returns the failure that preceeded the event, else {@code null} if there was none. | ||
*/ | ||
public Throwable getFailure() { | ||
return failure; | ||
} | ||
|
||
/** | ||
* Returns the result that preceeded the event, else {@code null} if there was none. | ||
*/ | ||
public R getResult() { | ||
return result; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "ExecutionCompletedEvent[" + "result=" + result + ", failure=" + failure + ']'; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/net/jodah/failsafe/event/ExecutionEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package net.jodah.failsafe.event; | ||
|
||
import net.jodah.failsafe.ExecutionContext; | ||
|
||
import java.time.Duration; | ||
|
||
/** | ||
* Encapsulates information about a Failsafe execution. | ||
* | ||
* @author Jonathan Halterman | ||
*/ | ||
public class ExecutionEvent { | ||
private final ExecutionContext context; | ||
|
||
public ExecutionEvent(ExecutionContext context) { | ||
this.context = context; | ||
} | ||
|
||
/** | ||
* Returns the elapsed time since initial execution began. | ||
*/ | ||
public Duration getElapsedTime() { | ||
return context.getElapsedTime(); | ||
} | ||
|
||
/** | ||
* Gets the number of executions so far. | ||
*/ | ||
public int getExecutions() { | ||
return context.getExecutions(); | ||
} | ||
|
||
/** | ||
* Returns the time that the initial execution started. | ||
*/ | ||
public Duration getStartTime() { | ||
return context.getStartTime(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.