feat(kpi): K3 — KpiHistory project + options/validator + AddKpiHistory
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using ZB.MOM.WW.Configuration;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.KpiHistory;
|
||||
|
||||
/// <summary>
|
||||
/// Composition root for the KPI History (#26, M6) component.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// <para>
|
||||
/// K3 scaffolds the component: it binds and validates
|
||||
/// <see cref="KpiHistoryOptions"/>. The recorder actor itself is created via
|
||||
/// <c>Props</c> in the Host on the active central node (K4/K5), not registered
|
||||
/// here — mirroring the Notification Outbox (#21) singleton wiring.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
public static class ServiceCollectionExtensions
|
||||
{
|
||||
/// <summary>Configuration section bound to <see cref="KpiHistoryOptions"/>.</summary>
|
||||
public const string OptionsSection = "ScadaBridge:KpiHistory";
|
||||
|
||||
/// <summary>
|
||||
/// Registers the KPI History (#26) component services: the validated
|
||||
/// <see cref="KpiHistoryOptions"/> binding. Idempotent re-registration of the
|
||||
/// validator is handled by the shared <c>AddValidatedOptions</c> helper
|
||||
/// (<c>TryAddEnumerable</c>); the options binding itself is call-once per
|
||||
/// <see cref="IServiceCollection"/>.
|
||||
/// </summary>
|
||||
/// <param name="services">The service collection to register into.</param>
|
||||
/// <param name="configuration">Application configuration used to bind <see cref="KpiHistoryOptions"/>.</param>
|
||||
/// <returns>The same <see cref="IServiceCollection"/> for chaining.</returns>
|
||||
public static IServiceCollection AddKpiHistory(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
ArgumentNullException.ThrowIfNull(configuration);
|
||||
|
||||
// Binds the "ScadaBridge:KpiHistory" section, registers the validator,
|
||||
// and enables ValidateOnStart in one call — same shape as AddAuditLog.
|
||||
services.AddValidatedOptions<KpiHistoryOptions, KpiHistoryOptionsValidator>(configuration, OptionsSection);
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user