ContextDependency#
- class gafaelfawr.dependencies.context.ContextDependency#
Bases:
object
Provide a per-request context as a FastAPI dependency.
Each request gets a
RequestContext
. To save overhead, the portions of the context that are shared by all requests are collected into the single process-globalProcessContext
and reused with each request.Attributes Summary
The underlying process context, primarily for use in tests.
Methods Summary
__call__
(request[, session, logger])Create a per-request context and return it.
aclose
()Clean up the per-process configuration.
initialize
(config)Initialize the process-wide shared context.
Attributes Documentation
- process_context#
The underlying process context, primarily for use in tests.
Methods Documentation
- async __call__(request, session=Depends(DatabaseSessionDependency), logger=Depends(LoggerDependency))#
Create a per-request context and return it.
- Parameters:
request (
Request
) –session (
async_scoped_session
, default:Depends(DatabaseSessionDependency)
) –logger (
BoundLogger
, default:Depends(LoggerDependency)
) –
- Return type: