RateCacheWarmupExtensions Class
Definition
- Namespace
- Bodu.Financial.ExchangeRates
- Assembly
- Bodu.Financial.ExchangeRates.Caching.dll
- Package
- Bodu.Financial.ExchangeRates.Caching 1.0.0
Provides registration of the startup cache warm-up onto an IFinancialServiceBuilder.
public static class RateCacheWarmupExtensions
- Inheritance
-
RateCacheWarmupExtensions
- Inherited Members
Methods
AddRateCacheWarmup(IFinancialServiceBuilder, IConfiguration?, string, Action<RateCacheWarmupOptions>?)
Registers a hosted service that warms every registered caching rate provider at application start, fetching the configured pairs over the configured window through the normal read-through path so the first user request never pays the origin fetch.
public static IFinancialServiceBuilder AddRateCacheWarmup(this IFinancialServiceBuilder builder, IConfiguration? configuration = null, string sectionName = "Financial:RateCacheWarmup", Action<RateCacheWarmupOptions>? configure = null)
Parameters
builderIFinancialServiceBuilderThe financial service builder.
configurationIConfigurationAn optional configuration root or section bound into RateCacheWarmupOptions.
sectionNamestringThe configuration section name. Defaults to
Financial:RateCacheWarmup.configureAction<RateCacheWarmupOptions>An optional callback applied after configuration binding.
Returns
- IFinancialServiceBuilder
The builder, for chaining.
Examples
services.AddFinancialService()
.AddRbaExchangeRates(configuration)
.AddCachedRateProvider<RbaRateProvider>("RBA", configuration)
.AddRateCacheWarmup(configure: warmup =>
{
warmup.Pairs.Add("AUD/USD");
warmup.Pairs.Add("AUD/EUR");
warmup.LookbackDays = 90;
});
Remarks
The warm-up runs in the background after the host starts and never blocks or crashes it: a failing pair is
logged and skipped, and host shutdown cancels the run. It warms every provider registered through
AddCachedRateProvider automatically; aggregation children registered through
AddAggregatedRateProvider are keyed services and are warmed only when named in
Providers. Options are validated at application start.
Exceptions
- ArgumentNullException
Thrown when
builderis null.- ArgumentException
Thrown when
sectionNameis empty or white space.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |