Skip to content

Enhance sender task structure and improve task management - #163

Merged
Flash303 merged 18 commits into
devfrom
rework/worker
Nov 19, 2026
Merged

Flash303 merged 18 commits into
devfrom
rework/worker

Conversation

@Flash303

Copy link
Copy Markdown
Owner

This pull request introduces several improvements and refactorings across the backend, focusing on PostgreSQL connection pool configurability, code quality, and minor API ergonomics. The most significant changes are the introduction of a configurable PostgreSQL pool with environment variable overrides, enhancements to CI checks, and code cleanups leveraging Rust's newer control flow syntax.

Database configuration and ergonomics:

  • Added a new PgPoolConfig struct in backend/crates/repository/src/postgres.rs to allow fine-grained configuration of PostgreSQL connection pool parameters, supporting both API and worker presets, and environment variable overrides for all options. ([backend/crates/repository/src/postgres.rsL16-R158](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-46eb215b827b58c2dca6c0215c910f3e1e34d6da3a0bf7a92bf567a57987bb6fL16-R158))
  • Refactored PostgresRepository to support initialization with custom pool configuration, and updated the REST API entrypoint to use the new configuration mechanism. ([[1]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-46eb215b827b58c2dca6c0215c910f3e1e34d6da3a0bf7a92bf567a57987bb6fR169-R185), [[2]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-2d7afa57cd8a5b308e9974aa8c48235b4246cbd7c470c274369b3a1ed08bd721L21-R21), [[3]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-2d7afa57cd8a5b308e9974aa8c48235b4246cbd7c470c274369b3a1ed08bd721L54-R56))
  • Documented new database pool environment variables in .env.example. ([backend/rest-api/.env.exampleR3-R8](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-e9a8e7a2630720ab0c2d79e754e34e8a4298777feeb69df2e4bf8322fc7bbe9dR3-R8))

Continuous Integration improvements:

  • Enhanced the CI workflow (.github/workflows/ci.yml) to check that generated service worker files are up to date before building, and added Rust formatting and Clippy lints to the backend workflow, enforcing stricter code quality. ([.github/workflows/ci.ymlR36-R65](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-b803fcb7f17ed9235f1e5cb1fcd2f5d3b2838429d4368ae4c57ce4436577f03fR36-R65))

Rust code quality and modern syntax:

  • Refactored multiple conditional blocks to use Rust's new "let chains" syntax for improved readability and conciseness, notably in duplicate detection, server icon retrieval, and claim validation. ([[1]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-da909813f4a9002d62abd0aa2883554c2cfa40634bb007cffcd0af5b34e76fbaL208-L247), [[2]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-6fc865c8bfd6ec7c5f186cf219668282275b6fe3c63a6eebf81a4e7f1225c565R24-L25), [[3]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-4cf94b42294b15de4dfbd6c4c0108a717492062b61b56fcae3dc544ecbdca699L183-L187), [[4]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-758c91bbfa86215950de7a4d4f660b8b4d80909b0b0a4f4a22b0376b081ae289L37-L51))
  • Added a Default implementation for TtlCache to simplify cache instantiation. ([backend/rest-api/src/utils/cache.rsR16-R25](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-758c91bbfa86215950de7a4d4f660b8b4d80909b0b0a4f4a22b0376b081ae289R16-R25))

Minor API and code ergonomics:

  • Changed the save_pings method in the Repository trait and its implementation to accept a slice (&[Record]) instead of a reference to a Vec, improving flexibility. ([[1]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-65309160936c8100b25422230b386e5423926e6ff3ee5678e76c5775ecce7c73L18-R18), [[2]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-46eb215b827b58c2dca6c0215c910f3e1e34d6da3a0bf7a92bf567a57987bb6fL50-R201))
  • Cleaned up and relocated tests for error formatting in backend/rest-api/src/error.rs. ([[1]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-ed129d15399df47d91a647fdc1b8a0257a0cdd9f0c54f8bdc543384135774032L88-L108), [[2]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-ed129d15399df47d91a647fdc1b8a0257a0cdd9f0c54f8bdc543384135774032R136-R156))

Other improvements:

  • Simplified environment variable checks and minor code cleanups in the REST API main function and related modules. ([[1]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-2d7afa57cd8a5b308e9974aa8c48235b4246cbd7c470c274369b3a1ed08bd721L63-R65), [[2]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-2d7afa57cd8a5b308e9974aa8c48235b4246cbd7c470c274369b3a1ed08bd721L80-R87), [[3]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-aaaedb419c10450d5682f996bae006519d4169dd87f3eb0bfe63de55391775d8L33-R33), [[4]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-522a5296124462e42be9c0afe3306c936fd7ab34d49417eca3b1237c94715e4aL14-R14), [[5]](https://github.com/Flash303/minecraft-stats/pull/163/files#diff-73824bc2f5aefa283d0f1ab4eb735df1031d9871fb7d5be90de3a5d376c9c0faR17))

These changes collectively improve code maintainability, configuration flexibility, and quality assurance for the backend.

@Flash303
Flash303 merged commit ffaa215 into dev Nov 19, 2026
4 checks passed
@Flash303
Flash303 deleted the rework/worker branch November 19, 2026 11:01
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