feat(notification-outbox): per-site KPI request/response message contracts
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
using ScadaLink.Commons.Types.Notifications;
|
||||||
|
|
||||||
namespace ScadaLink.Commons.Messages.Notification;
|
namespace ScadaLink.Commons.Messages.Notification;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -94,3 +96,20 @@ public record NotificationKpiResponse(
|
|||||||
int ParkedCount,
|
int ParkedCount,
|
||||||
int DeliveredLastInterval,
|
int DeliveredLastInterval,
|
||||||
TimeSpan? OldestPendingAge);
|
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);
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ScadaLink.Commons.Messages.Notification;
|
using ScadaLink.Commons.Messages.Notification;
|
||||||
|
using ScadaLink.Commons.Types.Notifications;
|
||||||
|
|
||||||
namespace ScadaLink.Commons.Tests.Messages;
|
namespace ScadaLink.Commons.Tests.Messages;
|
||||||
|
|
||||||
@@ -187,4 +188,26 @@ public class NotificationMessagesTests
|
|||||||
var msg = new NotificationKpiRequest("corr-1");
|
var msg = new NotificationKpiRequest("corr-1");
|
||||||
Assert.Equal("corr-1", msg.CorrelationId);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user