audit, advisories and doctors/setup work
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace StellaOps.Provcache;
|
||||
|
||||
@@ -21,8 +22,18 @@ public static class ProvcacheServiceCollectionExtensions
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
|
||||
var section = configuration.GetSection(ProvcacheOptions.SectionName);
|
||||
|
||||
// Register options
|
||||
services.Configure<ProvcacheOptions>(configuration.GetSection(ProvcacheOptions.SectionName));
|
||||
services.AddOptions<ProvcacheOptions>()
|
||||
.Bind(section)
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
services.AddOptions<LazyFetchHttpOptions>()
|
||||
.Bind(section.GetSection(LazyFetchHttpOptions.SectionName))
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
// Register core services
|
||||
services.AddSingleton<IProvcacheService, ProvcacheService>();
|
||||
@@ -31,6 +42,7 @@ public static class ProvcacheServiceCollectionExtensions
|
||||
services.AddSingleton<WriteBehindQueue>();
|
||||
services.AddSingleton<IWriteBehindQueue>(sp => sp.GetRequiredService<WriteBehindQueue>());
|
||||
services.AddHostedService(sp => sp.GetRequiredService<WriteBehindQueue>());
|
||||
services.AddHttpClient(HttpChunkFetcher.HttpClientName);
|
||||
|
||||
return services;
|
||||
}
|
||||
@@ -49,7 +61,14 @@ public static class ProvcacheServiceCollectionExtensions
|
||||
ArgumentNullException.ThrowIfNull(configure);
|
||||
|
||||
// Register options
|
||||
services.Configure(configure);
|
||||
services.AddOptions<ProvcacheOptions>()
|
||||
.Configure(configure)
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
services.AddOptions<LazyFetchHttpOptions>()
|
||||
.ValidateDataAnnotations()
|
||||
.ValidateOnStart();
|
||||
|
||||
// Register core services
|
||||
services.AddSingleton<IProvcacheService, ProvcacheService>();
|
||||
@@ -58,6 +77,7 @@ public static class ProvcacheServiceCollectionExtensions
|
||||
services.AddSingleton<WriteBehindQueue>();
|
||||
services.AddSingleton<IWriteBehindQueue>(sp => sp.GetRequiredService<WriteBehindQueue>());
|
||||
services.AddHostedService(sp => sp.GetRequiredService<WriteBehindQueue>());
|
||||
services.AddHttpClient(HttpChunkFetcher.HttpClientName);
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user