37 lines
1.5 KiB
C#
37 lines
1.5 KiB
C#
using ZB.MOM.WW.ScadaBridge.Commons.Messages.DebugView;
|
|
using ZB.MOM.WW.ScadaBridge.Communication;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.CentralUI.Services;
|
|
|
|
/// <summary>
|
|
/// Default <see cref="IInstanceSnapshotClient"/> — a thin facade over the
|
|
/// existing single-shot
|
|
/// <see cref="CommunicationService.RequestDebugSnapshotAsync"/> Ask (the same
|
|
/// Deployer-gated snapshot path the CLI <c>debug snapshot</c> command and the
|
|
/// Debug View use). Each call issues one <see cref="DebugSnapshotRequest"/>
|
|
/// with a fresh correlation id.
|
|
/// </summary>
|
|
public sealed class CommunicationInstanceSnapshotClient : IInstanceSnapshotClient
|
|
{
|
|
private readonly CommunicationService _communication;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="CommunicationInstanceSnapshotClient"/> class.
|
|
/// </summary>
|
|
/// <param name="communication">Central-side cluster communication service.</param>
|
|
public CommunicationInstanceSnapshotClient(CommunicationService communication)
|
|
{
|
|
_communication = communication ?? throw new ArgumentNullException(nameof(communication));
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public Task<DebugViewSnapshot> GetSnapshotAsync(
|
|
string siteIdentifier,
|
|
string instanceUniqueName,
|
|
CancellationToken cancellationToken = default)
|
|
{
|
|
var request = new DebugSnapshotRequest(instanceUniqueName, Guid.NewGuid().ToString("N"));
|
|
return _communication.RequestDebugSnapshotAsync(siteIdentifier, request, cancellationToken);
|
|
}
|
|
}
|