mirror of
https://github.com/lldap/lldap.git
synced 2026-04-25 16:25:55 +03:00
[PR #1248] [CLOSED] server: DB Connection Pool configuration #1207
Labels
No labels
backend
blocked
bug
cleanup
dependencies
docker
documentation
duplicate
enhancement
enhancement
frontend
github_actions
good first issue
help wanted
help wanted
integration
invalid
ldap
pull-request
question
rust
rust
tests
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/lldap-lldap#1207
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/lldap/lldap/pull/1248
Author: @thielj
Created: 8/20/2025
Status: ❌ Closed
Base:
main← Head:main📄 Description
Alrighty, I tried my Rust hat with some help from AI. Go easy on me.
Automatic summary follows at the end.
Reference: Discussions
What still needs to be done is migrating database_url (or LLDAP_DATABASE_URL) from existing setups to the new db_options.url (LLDAP_DB_OPTIONS__URL). I tried to implement this but couldn't get my head around the
mutstuff to promote the deprecated field to the new struct if theurlfield there isNone. There's a// TODOcomment somewhere this may fit. Your help here is very much appreciated.The new configuration also affects the examples and in particular the default configuration file in docker that sets LLDAP_DATABASE_URL explicitly. I haven't touched these yet to keep the scope small.
I decided to increase max_connections default for SQLite. Async/await should benefit from this. If not, it shouldn't matter as the pool only creates one connection initially and everything else on demand. For non-SQLite databases, I defaulted this to min(5), max(10).
I've also defaulted the connection timeout to 3 seconds. This should help improve responsiveness if a remote DB isn't reachable.
Finally, I made the DB log level dependent on the verbose flag using either Debug or Info.
This pull request refactors how database connection options are configured and used in the server. Instead of relying on a single
database_urlfield, it introduces a newDbOptionsstruct to group all database-related settings, making configuration more flexible and future-proof. The changes affect CLI argument parsing, configuration management, and database connection setup.Configuration improvements:
DbOptsstruct inserver/src/cli.rsto handle database connection options via CLI, including URL, connection pool sizes, timeouts, and lifetimes. ([server/src/cli.rsR215-R242](diffhunk://#diff-7626d972d62203e5dc68698a3ac2adcef8ea1642b095870c93945da03324cfb6R215-R242))Configurationinserver/src/configuration.rs) to use a newDbOptionsfield instead of a singledatabase_url, withdatabase_urlnow deprecated. ([server/src/configuration.rsL115-R142](diffhunk://#diff-40bbcf477684ac3a8b76a2303a5f4e2e63214f4044f97cd1bef0eb4aad086606L115-R142))ConfigOverriderforDbOpts, allowing CLI/database environment overrides to be correctly applied to the configuration. ([[1]](diffhunk://#diff-40bbcf477684ac3a8b76a2303a5f4e2e63214f4044f97cd1bef0eb4aad086606R507-R529),[[2]](diffhunk://#diff-40bbcf477684ac3a8b76a2303a5f4e2e63214f4044f97cd1bef0eb4aad086606R479))database_urlfield is used, guiding users to switch todb_options. ([server/src/configuration.rsR686-R690](diffhunk://#diff-40bbcf477684ac3a8b76a2303a5f4e2e63214f4044f97cd1bef0eb4aad086606R686-R690))Database connection logic updates:
server/src/main.rsto use all options fromDbOptions, including pool limits and timeouts, and made logging level configurable based on verbosity. ([server/src/main.rsL104-R145](diffhunk://#diff-01fd5002f7585d6f2b853a8c83e6c0a1acb2b16b6e6f8f581fb3365377d331bcL104-R145))DbOptionsinstead of justDatabaseUrl, including insetup_sql_tablesand related server setup functions. ([[1]](diffhunk://#diff-01fd5002f7585d6f2b853a8c83e6c0a1acb2b16b6e6f8f581fb3365377d331bcL104-R145),[[2]](diffhunk://#diff-01fd5002f7585d6f2b853a8c83e6c0a1acb2b16b6e6f8f581fb3365377d331bcL278-R292))These changes make database configuration more robust and extensible, and prepare for future enhancements or backend changes.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.