Skip to content

Async#32

Open
solitaryurt wants to merge 7 commits into
masterfrom
async
Open

Async#32
solitaryurt wants to merge 7 commits into
masterfrom
async

Conversation

@solitaryurt
Copy link
Copy Markdown
Collaborator

No description provided.

- Add AsyncConfig with a 50-thread pool executor for Discord commands
- Annotate recvMessage, recvInteraction, and handleInteraction with @async
- Parallelize Server pings and RCON calls in !showservers
- Optimize db.loadMatch to eliminate O(N) blocking Discord API lookups
- Enable PRAGMA journal_mode=WAL on SQLite connection to prevent DB locks
- Remove synchronized keyword from FtwglApi to allow parallel HTTP calls
…ecution

- Spring AOP proxying for @async was failing to intercept PickupBot
- Injected commandExecutor directly into PickupBot and CommandInitService
- Wrapped recvMessage, recvInteraction, and handleInteraction bodies in commandExecutor.execute() to ensure Discord commands never block JDA threads
…o preserve ordering

- Add a dedicated single-threaded queueExecutor for commands that modify
  game state (add/remove/pick/map/surrender/team etc) so they execute
  in FIFO order, ensuring fairness for players
- Read-only commands (status/last/elo/live/help/showservers etc) still
  use the multi-threaded commandExecutor so they respond instantly
- Determine executor at dispatch time before entering the lambda, so the
  switch statement logic is completely unchanged
- Apply same pattern to button interactions (pick/teaminvite go through
  queueExecutor, stats/season views go through commandExecutor)
- Add @PreDestroy hook to PickupBot that calls db.disconnect() on shutdown
- Database.disconnect() now runs PRAGMA wal_checkpoint(TRUNCATE) before
  closing the connection, flushing all WAL data to the main DB file
- Configure both executors with setWaitForTasksToCompleteOnShutdown(true)
  and 30s termination timeout so in-flight commands finish before the
  database connection is closed
- Remove unused @EnableAsync and @async imports (not needed with manual executor.execute())
- Replace inline FQCNs with proper imports for readability
- Route slash commands through queueExecutor to prevent race conditions on shared state
- Extract MatchSummary data class so Database layer returns plain data instead of DiscordEmbed
- Move Discord embed formatting into PickupLogic.buildMatchEmbed()
@solitaryurt solitaryurt force-pushed the master branch 2 times, most recently from 2f51e33 to 9119e56 Compare April 17, 2026 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant