fix(historian-gateway): wire dormant GatewayTagProvisioner + provisioning observability/docs
PR #423 shipped GatewayTagProvisioner + unit tests but never registered it in DI nor passed it into the AddressSpaceApplier, so deploying historized tags used the no-op NullHistorianProvisioning and never called the gateway's EnsureTags (confirmed live on wonder-app-vd03: zero EnsureTags calls on a historized deploy). Addresses HISTORIAN-GATEWAY-INTEGRATION-ISSUES.md. Issue 1 (wire provisioner): - Runtime: AddHistorianProvisioning extension (gated on ServerHistorian:Enabled, mirrors AddServerHistorian) + NullHistorianProvisioning TryAdd default in AddOtOpcUaRuntime; WithOtOpcUaRuntimeActors resolves IHistorianProvisioning and passes it into the applier. - Gateway driver: GatewayHistorian.CreateProvisioner factory (mirrors CreateDataSource). - Host: Program.cs calls AddHistorianProvisioning after AddServerHistorian. - Tests: AddHistorianProvisioningTests (config-gated registration + the register->resolve->applier->EnsureTags chain). Issue 2 (observability): AddressSpaceApplier logs the provisioning tally on every successful dispatch (was gated behind Failed/Skipped > 0), including dispatched=N so a dispatched=N/requested=0 line flags the dormant no-op. +2 tests. Issue 3 (30s HistoryRead on unprovisioned tags): root coupling fixed by Issue 1; documented the CallTimeout knob + coupling. Default left at 30s pending the multi-data-point investigation the issue requests (lowering risks truncating legitimate large reads). Issue 4 (docs): docs/Historian.md gains a "Tag auto-provisioning (EnsureTags)" section and CLAUDE.md a wiring/gating note (both stress ServerHistorian:Enabled). Sibling scadaproj/CLAUDE.md carries no false claim -> unchanged. Pre-existing Serilog observation: anchor CWD to AppContext.BaseDirectory before AddZbSerilog so the relative file sink stops landing in C:\Windows\System32 under the Windows-service CWD. Builds 0-error; Runtime.Tests 355, OpcUaServer.Tests 329, Gateway.Tests 99 (+4 live-skipped) all green.
This commit is contained in:
+36
@@ -78,4 +78,40 @@ public static class GatewayHistorian
|
||||
HistorianGatewayClientAdapter.Create(options, loggerFactory),
|
||||
logger);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Builds a <see cref="GatewayTagProvisioner"/> over a lazily connected
|
||||
/// <see cref="HistorianGatewayClientAdapter"/> mapped from the bound
|
||||
/// <see cref="ServerHistorianOptions"/> — the <b>same single gateway</b> the read path
|
||||
/// (<see cref="CreateDataSource"/>) and alarm-write path (<see cref="CreateAlarmWriter"/>) target. The
|
||||
/// Host's <c>AddHistorianProvisioning</c> wiring supplies this as the concrete
|
||||
/// <see cref="IHistorianProvisioning"/> the <c>AddressSpaceApplier</c> calls (non-blocking
|
||||
/// <c>EnsureTags</c>) when a deploy adds historized tags, so a brand-new historized tag exists in the
|
||||
/// historian before the recorder's <c>WriteLiveValues</c> land. Resolves an <see cref="ILoggerFactory"/>
|
||||
/// and the provisioner's <see cref="ILogger{TCategoryName}"/> from <paramref name="services"/>, falling
|
||||
/// back to the null implementations when absent. Performs no network I/O — the underlying channel dials
|
||||
/// on first <c>EnsureTags</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Like <see cref="CreateAlarmWriter"/>, this constructs its <b>own</b>
|
||||
/// <see cref="HistorianGatewayClientAdapter"/> — a separate gRPC channel to the same gateway. A second
|
||||
/// channel to a co-located sidecar is cheap (the gateway pools the historian sessions server-side), and
|
||||
/// it keeps each path's channel lifetime clean and independent.
|
||||
/// </remarks>
|
||||
/// <param name="options">The bound <c>ServerHistorian</c> configuration (endpoint, key, TLS posture).</param>
|
||||
/// <param name="services">The resolving service provider (used only to locate logging services).</param>
|
||||
/// <returns>The gateway-backed <see cref="IHistorianProvisioning"/>.</returns>
|
||||
public static IHistorianProvisioning CreateProvisioner(ServerHistorianOptions options, IServiceProvider services)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(options);
|
||||
ArgumentNullException.ThrowIfNull(services);
|
||||
|
||||
var loggerFactory = services.GetService<ILoggerFactory>() ?? NullLoggerFactory.Instance;
|
||||
var logger = services.GetService<ILogger<GatewayTagProvisioner>>()
|
||||
?? NullLogger<GatewayTagProvisioner>.Instance;
|
||||
|
||||
return new GatewayTagProvisioner(
|
||||
HistorianGatewayClientAdapter.Create(options, loggerFactory),
|
||||
logger);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user