feat(notification-outbox): CommunicationService per-site KPI accessor
This commit is contained in:
@@ -281,6 +281,13 @@ public class CommunicationService
|
|||||||
return await GetNotificationOutbox().Ask<NotificationKpiResponse>(
|
return await GetNotificationOutbox().Ask<NotificationKpiResponse>(
|
||||||
request, _options.QueryTimeout, cancellationToken);
|
request, _options.QueryTimeout, cancellationToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<PerSiteNotificationKpiResponse> GetPerSiteNotificationKpisAsync(
|
||||||
|
PerSiteNotificationKpiRequest request, CancellationToken cancellationToken = default)
|
||||||
|
{
|
||||||
|
return await GetNotificationOutbox().Ask<PerSiteNotificationKpiResponse>(
|
||||||
|
request, _options.QueryTimeout, cancellationToken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Microsoft.Extensions.Logging.Abstractions;
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using ScadaLink.Commons.Messages.Deployment;
|
using ScadaLink.Commons.Messages.Deployment;
|
||||||
using ScadaLink.Commons.Messages.Notification;
|
using ScadaLink.Commons.Messages.Notification;
|
||||||
|
using ScadaLink.Commons.Types.Notifications;
|
||||||
|
|
||||||
namespace ScadaLink.Communication.Tests;
|
namespace ScadaLink.Communication.Tests;
|
||||||
|
|
||||||
@@ -209,6 +210,32 @@ public class CommunicationServiceTests : TestKit
|
|||||||
Assert.Equal(3, result.QueueDepth);
|
Assert.Equal(3, result.QueueDepth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task GetPerSiteNotificationKpisAsync_AsksOutboxProxyDirectly()
|
||||||
|
{
|
||||||
|
var service = new CommunicationService(
|
||||||
|
Options.Create(new CommunicationOptions()),
|
||||||
|
NullLogger<CommunicationService>.Instance);
|
||||||
|
var probe = CreateTestProbe();
|
||||||
|
service.SetNotificationOutbox(probe.Ref);
|
||||||
|
|
||||||
|
var request = new PerSiteNotificationKpiRequest("corr-ps");
|
||||||
|
var task = service.GetPerSiteNotificationKpisAsync(request);
|
||||||
|
|
||||||
|
var received = probe.ExpectMsg<PerSiteNotificationKpiRequest>();
|
||||||
|
Assert.Same(request, received);
|
||||||
|
var reply = new PerSiteNotificationKpiResponse(
|
||||||
|
"corr-ps", true, null,
|
||||||
|
new[] { new SiteNotificationKpiSnapshot("plant-a", 2, 0, 0, 5, null) });
|
||||||
|
probe.Reply(reply);
|
||||||
|
|
||||||
|
var result = await task;
|
||||||
|
Assert.Same(reply, result);
|
||||||
|
Assert.True(result.Success);
|
||||||
|
Assert.Single(result.Sites);
|
||||||
|
Assert.Equal("plant-a", result.Sites[0].SourceSiteId);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Stand-in for CentralCommunicationActor: verifies the message is wrapped
|
/// Stand-in for CentralCommunicationActor: verifies the message is wrapped
|
||||||
/// in a SiteEnvelope targeting the requested site and replies with a typed
|
/// in a SiteEnvelope targeting the requested site and replies with a typed
|
||||||
|
|||||||
Reference in New Issue
Block a user