397d3c5c4f
Rename across every client surface using each language's idiomatic convention:
* .NET clients/dotnet/MxGateway.Client[.Cli|.Tests]/
-> clients/dotnet/ZB.MOM.WW.MxGateway.Client[.Cli|.Tests]/
namespaces -> ZB.MOM.WW.MxGateway.Client[.Cli|.Tests]
contracts ProjectReference repointed to ZB.MOM.WW.MxGateway.Contracts
sln migrated to slnx (dotnet sln migrate)
* Python src/mxgateway -> src/zb_mom_ww_mxgateway
src/mxgateway_cli -> src/zb_mom_ww_mxgateway_cli
distribution: mxaccess-gateway-client -> zb-mom-ww-mxaccess-gateway-client
* Rust crate: mxgateway-client -> zb-mom-ww-mxgateway-client
build.rs proto path repointed
* Java subprojects: mxgateway-{client,cli} -> zb-mom-ww-mxgateway-{client,cli}
packages com.dohertylan.mxgateway -> com.zb.mom.ww.mxgateway
group com.dohertylan.mxgateway -> com.zb.mom.ww.mxgateway
rootProject mxaccessgw-java -> zb-mom-ww-mxaccessgw-java
* Go generate-proto.ps1 proto path repointed; module path and
package mxgateway kept (Go convention).
* proto-inputs.json: generatedOutputs.python updated to new package path.
* scripts/run-client-e2e-tests.ps1: Java CLI install path + gradle task
updated to zb-mom-ww-mxgateway-cli.
CLI binary names (mxgw, mxgw-py, mxgw-go, mxgateway-cli) and wire-level
identifiers (MXGATEWAY_* env vars, the mxgw_<id>_<secret> API key
prefix, protobuf package names like mxaccess_gateway.v1, all MXAccess
references) intentionally NOT renamed.
Fix pre-existing alarms-over-gateway breaks unblocked by the rename:
* mxaccess_gateway.proto: add missing public message QueryActiveAlarmsRequest
{session_id, client_correlation_id, alarm_filter_prefix} and missing
rpc QueryActiveAlarms(QueryActiveAlarmsRequest) returns
(stream ActiveAlarmSnapshot). All four typed clients referenced
these but they were absent from the proto.
* MxAccessGatewayService.QueryActiveAlarms: implement the new RPC on
the server, streaming from IGatewayAlarmService.CurrentAlarms with
optional alarm_filter_prefix filter.
* clients/dotnet/.../DiscoverHierarchyOptions.cs: add the hand-written
.NET POCO that wraps DiscoverHierarchyRequest (referenced by
GalaxyRepositoryClient.DiscoverHierarchyAsync but never authored).
* Drop retired session_id field references from
AcknowledgeAlarmRequest/AcknowledgeAlarmReply test fixtures across
.NET, Rust, Go, and Python clients.
* Rust integration test: add the missing stream_alarms impl on the
fake MxAccessGateway server (the trait gained the method, fake
didn't).
* Rust CLI test: bump expected gatewayProtocolVersion 2 -> 3.
Regenerated artifacts updated in this commit:
* src/ZB.MOM.WW.MxGateway.Contracts/Generated/{MxaccessGateway,MxaccessGatewayGrpc}.cs
* clients/python/src/zb_mom_ww_mxgateway/generated/*_pb2{,_grpc}.py
* clients/go/internal/generated/*.pb.go
(C# regenerated by Grpc.Tools on contracts build; Python and Go via
their generate-proto.ps1 scripts; Rust regenerates from .proto via
tonic-build at compile time so no checked-in artefact.)
Verification: 472 server tests, 275 worker tests (9 dev-rig skipped),
18 integration tests (live MxAccess + LDAP + Galaxy), 57 .NET client
tests, 32 Rust workspace tests, 39 Python tests, all Go packages, and
gradle build for Java all pass.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
131 lines
4.1 KiB
C#
131 lines
4.1 KiB
C#
using Microsoft.Extensions.Logging;
|
|
|
|
namespace ZB.MOM.WW.MxGateway.Client;
|
|
|
|
/// <summary>
|
|
/// Configures the gRPC channel used by the .NET MXAccess Gateway client.
|
|
/// </summary>
|
|
public sealed class MxGatewayClientOptions
|
|
{
|
|
/// <summary>
|
|
/// Gets the gateway endpoint URI (required).
|
|
/// </summary>
|
|
public required Uri Endpoint { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the API key for gateway authentication (required).
|
|
/// </summary>
|
|
public required string ApiKey { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets a value indicating whether to use TLS for the gateway connection.
|
|
/// </summary>
|
|
public bool UseTls { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the path to a CA certificate file for custom certificate validation.
|
|
/// </summary>
|
|
public string? CaCertificatePath { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the server name override for SNI during TLS handshake.
|
|
/// </summary>
|
|
public string? ServerNameOverride { get; init; }
|
|
|
|
/// <summary>
|
|
/// Gets the timeout for establishing connection to the gateway.
|
|
/// </summary>
|
|
public TimeSpan ConnectTimeout { get; init; } = TimeSpan.FromSeconds(10);
|
|
|
|
/// <summary>
|
|
/// Gets the default timeout for unary gRPC calls.
|
|
/// </summary>
|
|
public TimeSpan DefaultCallTimeout { get; init; } = TimeSpan.FromSeconds(30);
|
|
|
|
/// <summary>
|
|
/// Gets the optional timeout for streaming gRPC calls.
|
|
/// </summary>
|
|
public TimeSpan? StreamTimeout { get; init; }
|
|
|
|
public int MaxGrpcMessageBytes { get; init; } = 16 * 1024 * 1024;
|
|
|
|
/// <summary>
|
|
/// Gets the retry configuration for safe unary calls.
|
|
/// </summary>
|
|
public MxGatewayClientRetryOptions Retry { get; init; } = new();
|
|
|
|
/// <summary>
|
|
/// Gets the logger factory for diagnostic logging.
|
|
/// </summary>
|
|
public ILoggerFactory? LoggerFactory { get; init; }
|
|
|
|
/// <summary>
|
|
/// Validates the client options for consistency and correctness.
|
|
/// </summary>
|
|
/// <exception cref="ArgumentNullException">Endpoint is null.</exception>
|
|
/// <exception cref="ArgumentException">Options are invalid or inconsistent.</exception>
|
|
/// <exception cref="ArgumentOutOfRangeException">Timeout values are not greater than zero.</exception>
|
|
public void Validate()
|
|
{
|
|
ArgumentNullException.ThrowIfNull(Endpoint);
|
|
|
|
if (!Endpoint.IsAbsoluteUri)
|
|
{
|
|
throw new ArgumentException(
|
|
"The gateway endpoint must be an absolute URI.",
|
|
nameof(Endpoint));
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(ApiKey))
|
|
{
|
|
throw new ArgumentException(
|
|
"The gateway API key must not be empty.",
|
|
nameof(ApiKey));
|
|
}
|
|
|
|
if (ConnectTimeout <= TimeSpan.Zero)
|
|
{
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(ConnectTimeout),
|
|
"The connect timeout must be greater than zero.");
|
|
}
|
|
|
|
if (DefaultCallTimeout <= TimeSpan.Zero)
|
|
{
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(DefaultCallTimeout),
|
|
"The default call timeout must be greater than zero.");
|
|
}
|
|
|
|
if (StreamTimeout is not null && StreamTimeout <= TimeSpan.Zero)
|
|
{
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(StreamTimeout),
|
|
"The stream timeout must be greater than zero when configured.");
|
|
}
|
|
|
|
if (MaxGrpcMessageBytes <= 0)
|
|
{
|
|
throw new ArgumentOutOfRangeException(
|
|
nameof(MaxGrpcMessageBytes),
|
|
"The maximum gRPC message size must be greater than zero.");
|
|
}
|
|
|
|
if (UseTls && Endpoint.Scheme != Uri.UriSchemeHttps)
|
|
{
|
|
throw new ArgumentException(
|
|
"UseTls requires an https gateway endpoint.",
|
|
nameof(Endpoint));
|
|
}
|
|
|
|
if (!UseTls && Endpoint.Scheme == Uri.UriSchemeHttps)
|
|
{
|
|
throw new ArgumentException(
|
|
"An https gateway endpoint requires UseTls.",
|
|
nameof(Endpoint));
|
|
}
|
|
|
|
Retry.Validate();
|
|
}
|
|
}
|