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, event_manager)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, logger)¶
Create a per-request context and return it.
- Parameters:
request (
Request
)session (
async_scoped_session
)logger (
BoundLogger
)
- Return type:
- async aclose()¶
Clean up the per-process configuration.
This also invalidates the events publishers until
initialize
is called again.- Return type:
- async initialize(config, event_manager)¶
Initialize the process-wide shared context.
- Parameters:
config (
Config
) – Gafaelfawr configuration.event_manager (
EventManager
) – Global event manager.
- Return type: