Database and Scalability Optimizations - #7
Merged
Merged
Conversation
Introduces GuildDataAccess and MessageDataAccess classes using JOOQ for database operations. Updates pom.xml to include the JOOQ dependency and modifies .gitignore to exclude the .idea directory. These changes provide structured data access for guild and message management, including registration, retrieval, and message encryption.
Replaces direct SQL operations in DatabaseConnector with dedicated data access classes (GuildDataAccess, MessageDataAccess) using jOOQ DSL. Updates all listeners and related classes to use the new data access methods, improving modularity and maintainability. Adds AuthorAndMessageEntity for structured message retrieval.
Updated the deleteMessage method to parse the messageId string to a Long before using it in the where clause. This ensures correct type matching for the MESSAGE_ID_COLUMN in the database.
Refactored MessageDataAccess to use asynchronous database operations with executeAsync and added error logging using Tinylog. Updated MessageLogListener to handle null AuthorAndMessageEntity and removed unnecessary printStackTrace calls for cleaner error handling.
Replaces direct JDBC connections with HikariCP
Switched to JDK24 from 21. Refactored MessageDataAccess to use synchronous database operations instead of async
This reverts commit 544095d.
Replaces asynchronous database operations with synchronous calls in MessageDataAccess, removing Tinylog error handling. In MessageLogListener, introduces a virtual thread pool to offload database operations and removes try-catch blocks and logging
Moved and renamed several listener classes to better organize them under 'commandlisteners' and 'loglisteners' packages. Updated package-info files and adjusted all relevant imports in FireRun.java to reflect the new structure. This improves code organization and clarity by grouping listeners according to their responsibilities.
All event listeners handling blocking I/O now accept an Executor for I/O operations, and FireRun provides a shared virtual thread pool to each listener. This improves concurrency and resource management by running blocking operations off the main thread. Minor TODO comments for logging were also added in data access classes.
Introduces Guava's Striped locks and an AtomicLong to ensure thread-safe operations on messages in MessageLogListener. Database operations for logging, updating, and deleting messages are now wrapped in a lock per message ID to prevent race conditions. Guava dependency added to pom.xml.
Marked key fields as final in several listener classes to ensure immutability. Simplified the bitmask map keys in GuildSystemChannelFlagResolver and PermissionResolver by replacing '1L << 0' with '1L'.
Replaces custom POJO with Java record for AuthorAndMessageEntity, adds Objects.requireNonNull assertions throughout listeners for improved null safety, and updates integer parsing to use primitive int in TypeResolver. Also removes unnecessary SQLException handling in main and database connector constructors, and applies minor code cleanups and assertion checks for better reliability and readability.
Updated the embed field to display both VIEW_AUDIT_LOGS and MANAGE_SERVER permissions for the bot integration role, providing clearer visibility of required permissions.
Deleted TODO comments about adding logging in GuildDataAccess and MessageDataAccess classes. No functional changes were made.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add JOOQ-based data access classes for guilds and messages
Add HikariCP connection pooling
Refactor listeners to use shared virtual thread pool
Add per-message locking to MessageLogListener
Add null safety and refactor for modern Java features
Add MANAGE_SERVER as a necessary permission