Source code for cadrumo.entrypoints.exchange_rate_composition
"""Host composition of the live exchange-rate source.A host process decides where currency conversions read their rates. Everyinstalled frontend uses the ECB reference rates, and binds them through this oneseam so no projection imports the outbound adapter itself."""from__future__importannotationsfromcollections.abcimportGeneratorfromcontextlibimportcontextmanagerfromtypingimportTYPE_CHECKINGifTYPE_CHECKING:from..domain.currency.serviceimportExchangeRateProviderdef_ecb_rate_provider()->ExchangeRateProvider:# Resolved on first conversion so a session that never converts does not# import the ECB adapter and the settings stack it reads.from..adapters.outbound.fx.ecb_providerimportdefault_ecb_rate_providerreturndefault_ecb_rate_provider()
[docs]@contextmanagerdeflive_exchange_rate_composition()->Generator[None]:"""Bind the ECB reference-rate provider for the enclosed host session."""from..application.exchange_rate_providerimportbind_exchange_rate_provider_factorywithbind_exchange_rate_provider_factory(_ecb_rate_provider):yield