Skip to content

Commit 0287536

Browse files
committed
refactor: improve variable naming and log message
1 parent 66aa74d commit 0287536

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

application/src/main/java/org/togetherjava/tjbot/features/dynamicvc/DynamicVoiceListener.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ public class DynamicVoiceListener extends VoiceReceiverAdapter {
5757
private final Map<String, AtomicBoolean> activeQueuesMap = new HashMap<>();
5858

5959
/** Boolean to track if events from all queues should be handled at a slower rate. */
60-
private final AtomicBoolean slowmode = new AtomicBoolean(false);
60+
private final AtomicBoolean voiceActivityCongestion = new AtomicBoolean(false);
6161
private final Executor eventQueueExecutor =
6262
CompletableFuture.delayedExecutor(1L, TimeUnit.SECONDS);
63-
private static final int SLOWMODE_THRESHOLD = 5;
63+
private static final int CONGESTION_THRESHOLD = 5;
6464

6565
/**
6666
* Initializes a new {@link DynamicVoiceListener} with the specified configuration.
@@ -97,14 +97,18 @@ private void insertEventToQueue(GuildVoiceUpdateEvent event, String channelTopic
9797
}
9898

9999
eventQueue.add(event);
100-
slowmode.set(eventQueue.size() >= SLOWMODE_THRESHOLD);
100+
voiceActivityCongestion.set(eventQueue.size() >= CONGESTION_THRESHOLD);
101101

102102
if (activeQueuesMap.get(channelTopic).get()) {
103103
return;
104104
}
105105

106-
if (slowmode.get()) {
107-
logger.info("Running with slowmode");
106+
if (voiceActivityCongestion.get()) {
107+
final String logMessage = String.format(
108+
"Congestion detected in the event queue of voice channel '%s', responding to event %s asynchronously.",
109+
channelTopic, event);
110+
111+
logger.info(logMessage);
108112
CompletableFuture.runAsync(() -> processEventFromQueue(channelTopic),
109113
eventQueueExecutor);
110114
return;

0 commit comments

Comments
 (0)