Skip to content

Commit

Permalink
more retries
Browse files Browse the repository at this point in the history
  • Loading branch information
zeekoe committed Dec 18, 2023
1 parent b6b8fe1 commit 28b6361
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/github/zeekoe/bluebird/Retryer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.github.zeekoe.bluebird;

import java.time.LocalDateTime;

public class Retryer<T extends Runnable> {
private static final int MAX_RETRY_COUNT = 3;
private static final int MAX_RETRY_COUNT = 5;
private final T runnable;
private int retryCount;

Expand All @@ -20,7 +22,7 @@ public void startRunning() {
retryCount = 1;
} catch (Exception e) {
retryCount++;
System.out.println("Exception, retry count: " + retryCount);
System.out.println(LocalDateTime.now() + ": Exception, retry count: " + retryCount);
System.out.println(e.getMessage());
}
if (retryCount <= MAX_RETRY_COUNT) {
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/com/github/zeekoe/bluebird/RetryerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ void retryerTest() {
verify(spy).sleep(30_000);
verify(spy).sleep(120_000);
verify(spy).sleep(270_000);
verify(spy).sleep(480_000);
verify(spy).sleep(750_000);
}

@Test
Expand Down

0 comments on commit 28b6361

Please sign in to comment.