feat(grpc-data): H2 consumer history client and deployed-connection history

GrpcDataConnection implements IDataHistoryService (explicitly; ReadHistoryAsync/ReleaseHistoryAsync avoid an overload
clash with ReadAsync): the capabilities probe always asks for history, other calls send it only when the selected
endpoint advertised it; per-call deadline min(remaining, HistoryTimeoutMilliseconds); FAILED_PRECONDITION/UNIMPLEMENTED
=> BadHistoryOperationUnsupported; chunks assembled within the request budget (BadTooManyOperations past it); page
tokens wrapped with the issuing endpoint + serving incarnation so a resumed read never moves; release forwarded. The
deployment lease gates history on the row's HistoryRead bit and carries HistoryTimeout. Decoded capabilities drop
HistoryRead without the history field. X0 tests that used bit 32 as the unknown bit now use a still-reserved bit.
This commit is contained in:
Joseph Doherty
2026-11-23 20:57:35 -05:00
parent d0756bb78e
commit b36c8d8716
10 changed files with 614 additions and 31 deletions
@@ -32,7 +32,7 @@ public sealed class GrpcDataFeatureHeaderClientTests
}
[Fact]
public async Task No_rpc_carries_the_feature_header_in_X0()
public async Task Without_an_advertised_feature_only_the_capabilities_probe_carries_the_header()
{
var handler = new RecordingHandler();
using var manager = new DataConnectionManager("consumer", 1);
@@ -52,20 +52,25 @@ public sealed class GrpcDataFeatureHeaderClientTests
handler.Paths.ShouldContain(p => p.EndsWith("/GetMetadata", StringComparison.Ordinal));
handler.Paths.ShouldContain(p => p.EndsWith("/Read", StringComparison.Ordinal));
handler.Paths.ShouldContain(p => p.EndsWith("/Write", StringComparison.Ordinal));
handler.FeatureHeaders.ShouldBeEmpty();
// H2 (coordinator decision): the probe always asks for what this consumer understands; nothing else carries the
// header, because this origin advertised no history field.
handler.FeatureHeaders.ShouldNotBeEmpty();
handler.FeatureHeaders.ShouldAllBe(x => x == "history");
handler.FeatureHeaderPaths.ShouldAllBe(p => p.EndsWith("/GetCapabilities", StringComparison.Ordinal));
}
private sealed class RecordingHandler : HttpMessageHandler
{
public List<string> Paths { get; } = [];
public List<string> FeatureHeaders { get; } = [];
public List<string> FeatureHeaderPaths { get; } = [];
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var path = request.RequestUri!.AbsolutePath;
lock (Paths)
{
Paths.Add(path);
if (request.Headers.TryGetValues("x-otopcua-data-features", out var values)) FeatureHeaders.AddRange(values);
if (request.Headers.TryGetValues("x-otopcua-data-features", out var values)) { FeatureHeaders.AddRange(values); FeatureHeaderPaths.Add(path); }
}
IMessage message;
if (path.EndsWith("/GetCapabilities", StringComparison.Ordinal))
@@ -79,7 +84,7 @@ public sealed class GrpcDataFeatureHeaderClientTests
{
var wire = DataProtoMapper.EncodeMetadataResponse([new("0", DataItemStatus.Good,
new DataMetadata(View, "x", "tag", DataValueKind.Int32, -1, [], true, DataOperations.Read | DataOperations.Write, 1, null, null, false), null)]);
wire.Items[0].Value.AllowedOperations |= 32u;
wire.Items[0].Value.AllowedOperations |= 64u; // still reserved (32 is understood since H2)
wire.Serving = DataProtoMapper.EncodeServing(Serving); message = wire;
}
else if (path.EndsWith("/Read", StringComparison.Ordinal))