corvix.web.storage_provider¶
Process-wide storage backend singleton for the web app.
Production wiring builds a PostgreSQL backend lazily from config on first use
and caches it so its connection pool is reused across requests. Tests inject a
backend directly via set_storage_backend() and reset it to None
afterwards.
Attributes¶
Classes¶
Mutable container for the module-level storage backend. |
Functions¶
|
Inject the storage backend used by route handlers. |
|
Return the injected backend, or lazily build PostgreSQL storage from config. |
Module Contents¶
- class corvix.web.storage_provider._StorageState[source][source]¶
Mutable container for the module-level storage backend.
- backend: corvix.storage.StorageBackend | None = None[source][source]¶
- corvix.web.storage_provider.set_storage_backend(backend: corvix.storage.StorageBackend | None) None[source][source]¶
Inject the storage backend used by route handlers.
Production wiring leaves this unset and the backend is built lazily from config (PostgreSQL is required). Tests inject a backend directly and reset it to
Noneafterwards.
- corvix.web.storage_provider._get_storage() corvix.storage.StorageBackend[source][source]¶
Return the injected backend, or lazily build PostgreSQL storage from config.
The built backend is cached so its connection pool is reused across requests. Building is guarded by a lock so concurrent first requests don’t each create (and leak) a connection pool. Raises
HTTPException(500) when no database is configured.