Skip to content

Commit

Permalink
block for up to a minute
Browse files Browse the repository at this point in the history
  • Loading branch information
rfresh2 committed Nov 4, 2023
1 parent 5366e6d commit 7962b3e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/main/java/vc/live/LiveFeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;

Expand All @@ -49,6 +51,7 @@ public abstract class LiveFeed {
private final Cache<String, AtomicInteger> guildMessageSendFailCountCache = CacheBuilder.newBuilder()
.expireAfterWrite(5, MINUTES)
.build();
private ScheduledFuture<?> processMessageQueueFuture;

public LiveFeed(final RedisClient redisClient,
final GatewayDiscordClient discordClient,
Expand All @@ -64,7 +67,7 @@ public LiveFeed(final RedisClient redisClient,
this.executorService = executorService;
this.objectMapper = objectMapper;
syncChannels();
this.executorService.scheduleWithFixedDelay(this::processMessageQueue, ((int) (Math.random() * 10)), 10, SECONDS);
this.processMessageQueueFuture = this.executorService.scheduleWithFixedDelay(this::processMessageQueue, ((int) (Math.random() * 10)), 10, SECONDS);
inputQueues().forEach(this::monitorQueue);
}

Expand Down Expand Up @@ -154,7 +157,7 @@ protected void processMessageQueue() {
.runOn(Schedulers.parallel())
.flatMap(entry -> processSend(entry, embeds))
.sequential()
.blockLast();
.blockLast(Duration.ofMinutes(1));
} catch (final Throwable e) {
LOGGER.error("Error processing message queue", e);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/vc/process/DiscordPresenceUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Optional<String> getQueueStatus() {

Optional<String> getPlayerCount() {
try {
return Optional.of(String.format("%d Online Players", tabListApi.onlinePlayers().size()));
return Optional.of(String.format("%d Players Online", tabListApi.onlinePlayers().size()));
} catch (final Exception e) {
LOGGER.error("Error getting player count", e);
return Optional.empty();
Expand Down

0 comments on commit 7962b3e

Please sign in to comment.