feat(notification-outbox): per-site KPI request/response message contracts

This commit is contained in:
Joseph Doherty
2026-05-19 05:33:37 -04:00
parent d54c3da291
commit adcab9dcfc
2 changed files with 42 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
using ScadaLink.Commons.Types.Notifications;
namespace ScadaLink.Commons.Messages.Notification;
/// <summary>
@@ -94,3 +96,20 @@ public record NotificationKpiResponse(
int ParkedCount,
int DeliveredLastInterval,
TimeSpan? OldestPendingAge);
/// <summary>
/// Outbox UI -> Central: request for the per-source-site notification outbox KPI breakdown.
/// </summary>
public record PerSiteNotificationKpiRequest(
string CorrelationId);
/// <summary>
/// Central -> Outbox UI: per-site KPI breakdown for the Notification KPIs page.
/// On a repository fault <see cref="Success"/> is <c>false</c>, <see cref="ErrorMessage"/>
/// carries the cause, and <see cref="Sites"/> is empty.
/// </summary>
public record PerSiteNotificationKpiResponse(
string CorrelationId,
bool Success,
string? ErrorMessage,
IReadOnlyList<SiteNotificationKpiSnapshot> Sites);

View File

@@ -1,4 +1,5 @@
using ScadaLink.Commons.Messages.Notification;
using ScadaLink.Commons.Types.Notifications;
namespace ScadaLink.Commons.Tests.Messages;
@@ -187,4 +188,26 @@ public class NotificationMessagesTests
var msg = new NotificationKpiRequest("corr-1");
Assert.Equal("corr-1", msg.CorrelationId);
}
[Fact]
public void PerSiteNotificationKpiRequest_CarriesCorrelationId()
{
var request = new PerSiteNotificationKpiRequest("corr-1");
Assert.Equal("corr-1", request.CorrelationId);
}
[Fact]
public void PerSiteNotificationKpiResponse_CarriesPerSiteSnapshots()
{
var sites = new[]
{
new SiteNotificationKpiSnapshot("plant-a", 3, 1, 0, 10, TimeSpan.FromMinutes(4)),
};
var response = new PerSiteNotificationKpiResponse("corr-1", Success: true, ErrorMessage: null, sites);
Assert.True(response.Success);
Assert.Null(response.ErrorMessage);
Assert.Single(response.Sites);
Assert.Equal("plant-a", response.Sites[0].SourceSiteId);
}
}