deps¶
Documentation for the deps module.
Application dependency providers generators.
This module contains functions to create dependency providers for services and filters.
You should not have modify this module very often and should only be invoked under normal usage.
- class app.lib.deps.DependencyCache(*args: Any, **kwargs: Any)[source]¶
Bases:
object
Simple dependency cache for the application. This is used to help memoize dependencies that are generated dynamically.
- app.lib.deps.create_filter_dependencies(config: ~advanced_alchemy.extensions.litestar.providers.FilterConfig, dep_defaults: ~advanced_alchemy.extensions.litestar.providers.DependencyDefaults = <advanced_alchemy.extensions.litestar.providers.DependencyDefaults object>) dict[str, Provide] [source]¶
Create a dependency provider for the combined filter function.
- Parameters:
config – FilterConfig instance with desired settings.
dep_defaults – Dependency defaults to use for the filter dependencies
- Returns:
A dependency provider function for the combined filter function.
- app.lib.deps.create_service_dependencies(service_class: type[AsyncServiceT_co | SyncServiceT_co], /, key: str, statement: Optional[Select[tuple[ModelT]]] = None, config: Optional[Union[SQLAlchemyAsyncConfig, SQLAlchemySyncConfig]] = None, error_messages: Optional[Union[ErrorMessages, EmptyType]] = <class 'advanced_alchemy.utils.dataclass.Empty'>, load: Optional[LoadSpec] = None, execution_options: Optional[dict[str, Any]] = None, filters: Optional[FilterConfig] = None, uniquify: bool | None = None, count_with_window_function: bool | None = None, dep_defaults: DependencyDefaults = <advanced_alchemy.extensions.litestar.providers.DependencyDefaults object>) dict[str, Provide] [source]¶
Create a dependency provider for the combined filter function.
- Parameters:
key – The key to use for the dependency provider.
service_class – The service class to create a dependency provider for.
statement – The statement to use for the service.
config – The configuration to use for the service.
error_messages – The error messages to use for the service.
load – The load spec to use for the service.
execution_options – The execution options to use for the service.
filters – The filter configuration to use for the service.
uniquify – Whether to uniquify the service.
count_with_window_function – Whether to count with a window function.
dep_defaults – The dependency defaults to use for the service.
- Returns:
A dictionary of dependency providers for the service.
- app.lib.deps.create_service_provider(service_class: type[AsyncServiceT_co | SyncServiceT_co], /, statement: Optional[Select[tuple[ModelT]]] = None, config: Optional[Union[SQLAlchemyAsyncConfig, SQLAlchemySyncConfig]] = None, error_messages: Optional[Union[ErrorMessages, EmptyType]] = <class 'advanced_alchemy.utils.dataclass.Empty'>, load: Optional[LoadSpec] = None, execution_options: Optional[dict[str, Any]] = None, uniquify: bool | None = None, count_with_window_function: bool | None = None) Callable[[...], AsyncGenerator[AsyncServiceT_co, None] | Generator[SyncServiceT_co, None, None]] [source]¶
Create a dependency provider for a service.