Compare commits

..

No commits in common. "ab51cfb0c525b1a99c15286748c5ad0531832d17" and "80f33b6dbc379ffed8f4abd25746176e64334704" have entirely different histories.

2 changed files with 4 additions and 11 deletions

View file

@ -1,8 +1,6 @@
package de.hhhammer.dchat.discord.ws.connection;
import de.hhhammer.dchat.discord.ws.Retryer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.Duration;
import java.time.LocalTime;
@ -10,7 +8,8 @@ import java.util.Timer;
import java.util.concurrent.atomic.AtomicInteger;
public final class BackoffRetryer implements Retryer {
private static final Logger logger = LoggerFactory.getLogger(BackoffRetryer.class);
private static final int delayInSeconds = 10;
private static final int backoffMultiplier = 2;
private final AtomicInteger tries = new AtomicInteger();
private final int maxRetries;
private LocalTime lastRetry = null;
@ -25,14 +24,8 @@ public final class BackoffRetryer implements Retryer {
public int nextRetryInSeconds() {
// reset retry on successful connection for more than 5 minutes.
final int successfulTimeInMinute = 5;
if (lastRetry != null && LocalTime.now().minusMinutes(lastRetry.getMinute()).getMinute() > successfulTimeInMinute) {
logger.info("Resetting retry backoff: connection was successful for more than {} minutes", successfulTimeInMinute);
tries.set(0);
}
if (lastRetry != null && LocalTime.now().minusMinutes(lastRetry.getMinute()).getMinute() > 5) tries.set(0);
final int currentTry = tries.getAndIncrement();
final int delayInSeconds = 10;
final int backoffMultiplier = 2;
int seconds = delayInSeconds;
for (int i = 0; i < currentTry; i++) {
seconds = seconds * backoffMultiplier;

View file

@ -5,7 +5,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class ResumeConnector {
private static final Logger logger = LoggerFactory.getLogger(ResumeConnector.class);
private static Logger logger = LoggerFactory.getLogger(ResumeConnector.class);
private final String initGatewayUrl;
private final String token;