-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #926 from dlcs/feature/batchCompletedNotification
Adding ability for engine to notify on batch completion
- Loading branch information
Showing
16 changed files
with
262 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/protagonist/DLCS.AWS/SNS/BatchCompletedNotification.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using DLCS.Model.Assets; | ||
|
||
namespace DLCS.AWS.SNS; | ||
|
||
public class BatchCompletedNotification | ||
{ | ||
public int Id { get; private set; } | ||
|
||
public int CustomerId { get; private set; } | ||
|
||
public int Total { get; private set; } | ||
|
||
public int Success { get; private set; } | ||
|
||
public int Errors { get; private set; } | ||
|
||
public bool Superseded { get; private set; } | ||
|
||
public DateTime Started { get; private set; } | ||
|
||
public DateTime? Finished { get; private set; } | ||
|
||
public BatchCompletedNotification(Batch completedBatch) | ||
{ | ||
Id = completedBatch.Id; | ||
CustomerId = completedBatch.Customer; | ||
Total = completedBatch.Count; | ||
Success = completedBatch.Completed; | ||
Errors = completedBatch.Errors; | ||
Superseded = completedBatch.Superseded; | ||
Started = completedBatch.Submitted; | ||
Finished = completedBatch.Finished; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/protagonist/DLCS.AWS/SNS/Messaging/BatchCompletedNotificationSender.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using DLCS.Model.Assets; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace DLCS.AWS.SNS.Messaging; | ||
|
||
public class BatchCompletedNotificationSender : IBatchCompletedNotificationSender | ||
{ | ||
private readonly ITopicPublisher topicPublisher; | ||
private readonly ILogger<BatchCompletedNotificationSender> logger; | ||
|
||
public BatchCompletedNotificationSender(ITopicPublisher topicPublisher, | ||
ILogger<BatchCompletedNotificationSender> logger) | ||
{ | ||
this.topicPublisher = topicPublisher; | ||
this.logger = logger; | ||
} | ||
|
||
public async Task SendBatchCompletedMessage(Batch batch, CancellationToken cancellationToken = default) | ||
{ | ||
logger.LogDebug("Sending notification of creation of batch {Batch}", batch.Id); | ||
|
||
var batchCompletedNotification = new BatchCompletedNotification(batch); | ||
await topicPublisher.PublishToBatchCompletedTopic(batchCompletedNotification, cancellationToken); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/protagonist/DLCS.AWS/SNS/Messaging/IBatchCompletedNotificationSender.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using DLCS.Model.Assets; | ||
|
||
namespace DLCS.AWS.SNS.Messaging; | ||
|
||
public interface IBatchCompletedNotificationSender | ||
{ | ||
/// <summary> | ||
/// Broadcast batch completed notification | ||
/// </summary> | ||
Task SendBatchCompletedMessage(Batch completedBatch, CancellationToken cancellationToken = default); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.