fix(host,deployment-manager,communication): repair cross-module DI regressions from batch 1-2
- DeploymentManager-008: revert IConfiguration overload (violated OptionsTests component-convention); Host now binds the ScadaLink:DeploymentManager section - SiteStreamGrpcServer: make test-only int ctor internal so DI sees one public ctor (resolves ambiguous-constructor failure in SiteCompositionRootTests) - Host site composition-root test config: supply Cluster:SeedNodes for the new ClusterOptionsValidator
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ScadaLink.DeploymentManager;
|
||||
@@ -7,37 +6,26 @@ public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration section that <see cref="DeploymentManagerOptions"/> is bound to.
|
||||
/// The Host binds this section to <c>appsettings.json</c> (see
|
||||
/// <c>Program.cs</c>); component libraries do not depend on
|
||||
/// <c>IConfiguration</c> directly, consistent with the Options-pattern
|
||||
/// convention enforced by <c>OptionsTests</c>.
|
||||
/// </summary>
|
||||
public const string OptionsSection = "ScadaLink:DeploymentManager";
|
||||
|
||||
/// <summary>
|
||||
/// Registers the Deployment Manager services and binds
|
||||
/// <see cref="DeploymentManagerOptions"/> to the
|
||||
/// <see cref="OptionsSection"/> configuration section, consistent with the
|
||||
/// Options-pattern convention ("Per-component configuration via
|
||||
/// appsettings.json sections bound to options classes").
|
||||
/// </summary>
|
||||
public static IServiceCollection AddDeploymentManager(
|
||||
this IServiceCollection services,
|
||||
IConfiguration configuration)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
|
||||
// DeploymentManager-008: bind the options class so the operation-lock
|
||||
// and artifact-deployment timeouts are tunable via appsettings.json.
|
||||
services.Configure<DeploymentManagerOptions>(configuration.GetSection(OptionsSection));
|
||||
return services.AddDeploymentManager();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers the Deployment Manager services without binding options to
|
||||
/// configuration. <see cref="DeploymentManagerOptions"/> falls back to its
|
||||
/// declared defaults unless configured elsewhere. Prefer the
|
||||
/// <see cref="AddDeploymentManager(IServiceCollection, IConfiguration)"/>
|
||||
/// overload so the options are bound to <c>appsettings.json</c>.
|
||||
/// Registers the Deployment Manager services. <see cref="DeploymentManagerOptions"/>
|
||||
/// is registered via <see cref="OptionsServiceCollectionExtensions.AddOptions"/> so
|
||||
/// <c>IOptions<DeploymentManagerOptions></c> is always resolvable; the Host
|
||||
/// binds <see cref="OptionsSection"/> to configuration so the operation-lock and
|
||||
/// artifact-deployment timeouts are tunable via <c>appsettings.json</c>.
|
||||
/// </summary>
|
||||
public static IServiceCollection AddDeploymentManager(this IServiceCollection services)
|
||||
{
|
||||
// DeploymentManager-008: ensure the options class is always resolvable.
|
||||
// The Host binds OptionsSection to appsettings.json; absent that binding
|
||||
// the declared option-class defaults apply.
|
||||
services.AddOptions<DeploymentManagerOptions>();
|
||||
services.AddSingleton<OperationLockManager>();
|
||||
services.AddScoped<IFlatteningPipeline, FlatteningPipeline>();
|
||||
services.AddScoped<DeploymentService>();
|
||||
|
||||
Reference in New Issue
Block a user