fix(dcl): feed ScadaBridge:MxGateway:ClientNamePrefix into the MxGateway client-name fallback (review 2026-10-21 02/U1, 08/O2)

This commit is contained in:
Joseph Doherty
2026-10-22 06:29:05 -04:00
parent f18d3adbfc
commit 3543a7f295
6 changed files with 71 additions and 6 deletions
@@ -29,6 +29,7 @@ public class MxGatewayDataConnection
private readonly ILogger<MxGatewayDataConnection> _logger;
private readonly ISecretResolver? _secretResolver;
private readonly int _supervisoryAdviseParallelism;
private readonly string _clientNamePrefix;
private IMxGatewayClient? _client;
private ConnectionHealth _status = ConnectionHealth.Disconnected;
private CancellationTokenSource? _eventLoopCts;
@@ -79,16 +80,25 @@ public class MxGatewayDataConnection
/// Maximum in-flight supervisory advise commands on the bulk-subscribe path when the
/// endpoint has no write-user context (<c>DataConnectionOptions.MxSupervisoryAdviseParallelism</c>).
/// </param>
/// <param name="clientNamePrefix">
/// Gateway client registration name used when the connection's own <c>ClientName</c> is blank
/// (<c>ScadaBridge:MxGateway:ClientNamePrefix</c>, default <c>scadabridge</c>). Null or blank
/// keeps the <c>scadabridge</c> default.
/// </param>
public MxGatewayDataConnection(
IMxGatewayClientFactory clientFactory,
ILogger<MxGatewayDataConnection> logger,
ISecretResolver? secretResolver = null,
int supervisoryAdviseParallelism = 16)
int supervisoryAdviseParallelism = 16,
string? clientNamePrefix = null)
{
_clientFactory = clientFactory;
_logger = logger;
_secretResolver = secretResolver;
_supervisoryAdviseParallelism = Math.Max(1, supervisoryAdviseParallelism);
_clientNamePrefix = string.IsNullOrWhiteSpace(clientNamePrefix)
? new MxGatewayGlobalOptions().ClientNamePrefix
: clientNamePrefix.Trim();
}
/// <inheritdoc />
@@ -177,7 +187,7 @@ public class MxGatewayDataConnection
await _client.ConnectAsync(new MxGatewayConnectionOptions(
cfg.Endpoint,
apiKey,
string.IsNullOrWhiteSpace(cfg.ClientName) ? "scadabridge" : cfg.ClientName,
string.IsNullOrWhiteSpace(cfg.ClientName) ? _clientNamePrefix : cfg.ClientName,
cfg.WriteUserId,
cfg.UseTls,
string.IsNullOrWhiteSpace(cfg.CaFile) ? null : cfg.CaFile,