From 7962b3edead59adfe40be6ce03320b4d4ecdae17 Mon Sep 17 00:00:00 2001 From: rfresh2 <89827146+rfresh2@users.noreply.github.com> Date: Sat, 4 Nov 2023 12:57:11 -0700 Subject: [PATCH] block for up to a minute --- src/main/java/vc/live/LiveFeed.java | 7 +++++-- src/main/java/vc/process/DiscordPresenceUpdater.java | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/vc/live/LiveFeed.java b/src/main/java/vc/live/LiveFeed.java index 1d41bf0..79bc721 100644 --- a/src/main/java/vc/live/LiveFeed.java +++ b/src/main/java/vc/live/LiveFeed.java @@ -22,6 +22,7 @@ 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; @@ -29,6 +30,7 @@ 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; @@ -49,6 +51,7 @@ public abstract class LiveFeed { private final Cache guildMessageSendFailCountCache = CacheBuilder.newBuilder() .expireAfterWrite(5, MINUTES) .build(); + private ScheduledFuture processMessageQueueFuture; public LiveFeed(final RedisClient redisClient, final GatewayDiscordClient discordClient, @@ -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); } @@ -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); } diff --git a/src/main/java/vc/process/DiscordPresenceUpdater.java b/src/main/java/vc/process/DiscordPresenceUpdater.java index 50571b7..3e5ef31 100644 --- a/src/main/java/vc/process/DiscordPresenceUpdater.java +++ b/src/main/java/vc/process/DiscordPresenceUpdater.java @@ -84,7 +84,7 @@ Optional getQueueStatus() { Optional 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();