app.composition¶
Composition root: wires settings, configuration, storage and services.
This is the only module that names concrete implementations (the
PostgreSQL store, the default source type registry) and the only place
that hands the process environment to the configuration loader, which
resolves secrets referenced by env var name in catalog.yaml.
Both the FastAPI lifespan (app.main) and the CLI
(app.cli) build their object graph here.
CatalogRuntime is the startup state kept on app.state and
read by routes through get_catalog_runtime(). Read routes get
their storage provider through the get_store_provider()
dependency, which tests override with a provider bound to the test
database, exactly like app.config.get_settings().
Public API: SyncStatus, CatalogRuntime,
load_catalog(), build_store_provider(),
build_polling_service(), start_catalog(),
log_problems(), get_catalog_runtime(),
get_store_provider().
- class app.composition.SyncStatus(*values)¶
Bases:
StrEnumOutcome of the startup registration sync.
- SYNCED = 'synced'¶
- SKIPPED = 'skipped'¶
- FAILED = 'failed'¶
- class app.composition.CatalogRuntime(config, sync)¶
Bases:
objectStartup state of the catalog.
- Parameters:
config (
CatalogConfig) – Loaded configuration.sync (
SyncStatus) – Outcome of the registration sync.
- config: CatalogConfig¶
- sync: SyncStatus¶
- app.composition.load_catalog(settings)¶
Load
catalog.yamlwith the default source types.Network sources use the shared outbound TLS context (
app.tls.ssl_context_from_settings()).- Parameters:
settings (
Settings) – Application settings.- Return type:
- Returns:
The configuration (never raises for bad content).
- Raises:
app.errors.ConfigurationError – If an extra CA path (
ADRIANO_EXTRA_CA_CERTS) cannot be loaded.
- app.composition.build_store_provider(settings)¶
Build the storage provider for the configured database.
- Parameters:
settings (
Settings) – Application settings.- Return type:
- Returns:
The provider.
- app.composition.build_polling_service(provider, config)¶
Build the polling service.
- Parameters:
provider (
CatalogStoreProvider) – Storage provider.config (
CatalogConfig) – Loaded configuration.
- Return type:
- Returns:
The service.
- app.composition.log_problems(config)¶
Log every configuration problem (messages are secret-free).
- Parameters:
config (
CatalogConfig) – Loaded configuration.- Return type:
- app.composition.start_catalog(settings)¶
Load the configuration and sync registrations; never fails startup.
- Parameters:
settings (
Settings) – Application settings.- Return type:
- Returns:
The runtime state.
- app.composition.get_catalog_runtime(request)¶
FastAPI dependency: the startup state, if the lifespan ran.
- Parameters:
request (
Request) – Current request.- Return type:
- Returns:
The runtime state, or
None.
- app.composition.get_store_provider(settings=Depends(dependency=<functools._lru_cache_wrapper object>, use_cache=True, scope=None))¶
FastAPI dependency: the storage provider for the configured database.
Routers depend on this (never on a concrete store implementation), so tests can override it – or override
app.config.get_settings()to point it at the test database, as every other test already does.- Parameters:
settings (
Settings) – Application settings, injected for overriding.- Return type:
- Returns:
The provider.