Repository navigation
feat: provide settings to the database engine through the container - #67
Merged
Merged
Conversation
The engine takes Settings from ioc.Config.settings, so a test can override settings instead of relying on the module-level instance.
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.
Brings chat-app in line with modern-python/litestar-sqlalchemy-template#81 and modern-python/fastapi-sqlalchemy-template#104: the database engine gets its settings from the container instead of the module-level
settings.Changes
ioc.Config.settingsis a cachedFactory(Settings).create_database_engine(settings: Settings)is autowired by type, the same waydatabase_sessionalready gets its engine.Config.settingsoverridden builds an engine with the overridden pool size.settingsexplicitly.Configgroup and says which code still reads the global.Design notes
derivehere. It only helps when components need different values from the same settings. No modern-di bump is needed.app/api/auth.pybuildsjwt_cookie_authat import time, before any container exists, so it keeps reading the global, as do__main__,migrations/env.pyandbuild_app.Testing
just test: 155 passed, 100% coverage. ruff and ty are clean.