feat: OPC UA address-space search plumbing — actor + comm + BrowseService (T15)

This commit is contained in:
Joseph Doherty
2026-06-18 02:51:57 -04:00
parent c00c8241b3
commit 74dd26eebd
7 changed files with 468 additions and 0 deletions
@@ -87,4 +87,59 @@ public sealed class BrowseService : IBrowseService
new BrowseFailure(BrowseFailureKind.ServerError, ex.Message));
}
}
/// <inheritdoc/>
public async Task<SearchAddressSpaceResult> SearchAsync(
string siteId,
string connectionName,
string query,
int maxDepth,
int maxResults,
CancellationToken cancellationToken = default)
{
// Same CentralUI-side role guard as BrowseChildrenAsync — sites don't
// enforce envelope-level roles, so the Designer check must happen here
// before any cross-cluster traffic.
var state = await _auth.GetAuthenticationStateAsync();
if (!state.User.HasClaim(JwtTokenService.RoleClaimType, Roles.Designer))
{
return new SearchAddressSpaceResult(
Array.Empty<AddressSpaceMatch>(),
CapReached: false,
new BrowseFailure(BrowseFailureKind.ServerError, "Not authorized."));
}
try
{
return await _communication.SearchAddressSpaceAsync(
siteId,
new SearchAddressSpaceCommand(connectionName, query, maxDepth, maxResults),
cancellationToken);
}
catch (TimeoutException ex)
{
// Akka Ask timed out — the site (or its OPC UA session) didn't answer
// within CommunicationOptions.QueryTimeout. Surface as a typed Timeout
// failure so the picker can render an inline banner.
return new SearchAddressSpaceResult(
Array.Empty<AddressSpaceMatch>(),
CapReached: false,
new BrowseFailure(BrowseFailureKind.Timeout, ex.Message));
}
catch (OperationCanceledException)
{
// Caller-initiated cancel — propagate so Blazor can drop the response
// cleanly. Distinct from Timeout (which the picker renders inline).
throw;
}
catch (Exception ex)
{
// Any other transport / serialization failure: keep the picker alive
// and let the user fall back to manual browse / node-id paste.
return new SearchAddressSpaceResult(
Array.Empty<AddressSpaceMatch>(),
CapReached: false,
new BrowseFailure(BrowseFailureKind.ServerError, ex.Message));
}
}
}