-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from sterlp/apply-retry-delay
apply a delay on an error
- Loading branch information
Showing
7 changed files
with
51 additions
and
7 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
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
17 changes: 17 additions & 0 deletions
17
spring/src/main/java/org/sterl/pmw/quartz/job/RetryDelayStrategy.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,17 @@ | ||
package org.sterl.pmw.quartz.job; | ||
|
||
import java.time.Duration; | ||
|
||
import org.sterl.pmw.exception.WorkflowException; | ||
|
||
@FunctionalInterface | ||
public interface RetryDelayStrategy { | ||
RetryDelayStrategy NO_DELAY = (c, e) -> Duration.ZERO; | ||
RetryDelayStrategy LINEAR_DELAY = (c, e) -> Duration.ofMinutes(c + 1); | ||
RetryDelayStrategy EXPONENTIAL_DELAY = (c, e) -> Duration.ofMinutes((long)Math.pow(c + 1, 2)); | ||
|
||
/** | ||
* By default a linear retry strategy, adding one minute for each failed try. | ||
*/ | ||
Duration retryAt(int stepRetryCount, WorkflowException.WorkflowFailedDoRetryException error); | ||
} |
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