Add HikariCP and jOOQ integration#26
Merged
Merged
Conversation
Untested, now adding unit tests
Use a builder to construct StorageMethods to improve readability
# Conflicts: # build.gradle.kts
Warmup SQL database actions (select/update/insert) so that first real actions aren't slow
There was a problem hiding this comment.
Pull request overview
This PR replaces the legacy per-database JDBC dialect implementations with a unified jOOQ-based SQLDialect backed by a HikariCP connection pool, while updating migration logic and adding targeted storage tests.
Changes:
- Introduces a new
xyz.srnyx.annoyingapi.storage.dialects.SQLDialectusing HikariCP + jOOQ; removes the oldstorage/dialects/sql/*dialect classes and theStorageConfig#createConnection()path. - Refactors storage method metadata (
StorageMethod.SQLInfo) and remote-port defaults, and updates DataManager/plugin shutdown to close pooled resources. - Adds tests covering YAML/JSON round-trips, H2 SQL behavior, and migration behavior (including table-name normalization/prefix resolution).
Reviewed changes
Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/java/xyz/srnyx/annoyingapi/storage/StorageTestSupport.java | Adds common test harness for constructing real DataManager instances with specific storage methods. |
| src/test/java/xyz/srnyx/annoyingapi/storage/dialect/YAMLDialectTest.java | Adds YAML dialect round-trip + migration extraction tests. |
| src/test/java/xyz/srnyx/annoyingapi/storage/dialect/JSONDialectTest.java | Adds JSON dialect round-trip + migration extraction tests. |
| src/test/java/xyz/srnyx/annoyingapi/storage/dialect/H2DialectTest.java | Adds SQL dialect tests against H2 for schema creation, upserts, removals, migration extraction, and pool closure. |
| src/test/java/xyz/srnyx/annoyingapi/storage/DataManagerTest.java | Adds DataManager table-name + end-to-end migration/file-swap tests. |
| src/main/java/xyz/srnyx/annoyingapi/storage/StorageMethod.java | Reworks storage-method definition to builder-based config with jOOQ dialect + SQL connection metadata. |
| src/main/java/xyz/srnyx/annoyingapi/storage/StorageConfig.java | Removes direct JDBC connection creation and adjusts remote-port defaulting behavior. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/YAMLDialect.java | Updates bulk-set contract to Map-based API, adds getStats(), and fixes migration data table-name resolution through the new manager. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/JSONDialect.java | Updates bulk-set contract to Map-based API, adds getStats(), and fixes migration data table-name resolution through the new manager. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/Dialect.java | Normalizes table/key casing at entry points, changes bulk-set return type to List<FailedSet>, and adds Stats. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/SQLDialect.java | New pooled/jOOQ SQL implementation including schema creation and migration extraction. |
| src/main/java/xyz/srnyx/annoyingapi/storage/DataManager.java | Updates remote-prefix logic and closes pooled datasource on migration. |
| src/main/java/xyz/srnyx/annoyingapi/stats/StatsHelper.java | Removes stats helper class (logic moved into loaders). |
| src/main/java/xyz/srnyx/annoyingapi/stats/loader/FastStatsLoader.java | Adds storage cache metrics via new Dialect.Stats and refactors common metric collection/flush behavior. |
| src/main/java/xyz/srnyx/annoyingapi/options/DataOptions.java | Deprecates entity-related API and ensures table-configuration calls enable data options automatically. |
| src/main/java/xyz/srnyx/annoyingapi/file/okaeri/migration/S0002_Remote_connection_null_port.java | Updates migration to use the new SQL default-port source (method.sqlInfo). |
| src/main/java/xyz/srnyx/annoyingapi/AnnoyingPlugin.java | Updates shutdown/reload paths to close pooled datasource; updates SQL table creation + adds jOOQ warmup. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/sql/SQLDialect.java | Removes legacy JDBC SQL dialect base class. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/sql/SQLiteDialect.java | Removes legacy SQLite JDBC dialect. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/sql/H2Dialect.java | Removes legacy H2 JDBC dialect. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/sql/MySQLDialect.java | Removes legacy MySQL JDBC dialect. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/sql/MariaDBDialect.java | Removes legacy MariaDB JDBC dialect. |
| src/main/java/xyz/srnyx/annoyingapi/storage/dialects/sql/PostgreSQLDialect.java | Removes legacy PostgreSQL JDBC dialect. |
| build.gradle.kts | Adds runtime library entries for HikariCP + jOOQ and updates H2 version used by runtime library handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Copilot <198982749+Copilot@users.noreply.github.com>
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.
Use HikariCP and jOOQ for SQL dialects to improve connection management (pooling) and remove need for custom SQL dialect/statement definitions.
This also makes it WAY easier to make custom SQL executions in consumers (if desired).
Resolves #24