Skip to content

Commit

Permalink
Merge branch 'payload_rework' of https://github.com/Project-MONAI/mon…
Browse files Browse the repository at this point in the history
  • Loading branch information
lillie-dae committed Sep 6, 2023
2 parents 4060e52 + e4221f8 commit 9e7c670
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
10 changes: 7 additions & 3 deletions src/Api/Storage/Payload.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ public enum PayloadState
/// <summary>
/// Payload is ready to be published to the message broker.
/// </summary>
Notify
Notify,

/// <summary>
/// Payload has finished uploading.
/// </summary>
UploadComplete
}

public const int MAX_RETRY = 3;
Expand Down Expand Up @@ -89,15 +94,14 @@ public TimeSpan Elapsed
public int FilesFailedToUpload { get => Files.Count(p => p.IsUploadFailed); }

public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId,
DataOrigin dataTrigger, uint timeout, PatientDetails? patientDetails) : this(key, correlationId, workflowInstanceId, taskId, dataTrigger, timeout)
DataOrigin dataTrigger, uint timeout, PatientDetails? patientDetails) : this(key, correlationId, workflowInstanceId, taskId, dataTrigger, timeout)
{
if (patientDetails is not null)
{
PatientDetails = patientDetails;
}
}


public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, DataOrigin dataTrigger, uint timeout)
{
Guard.Against.NullOrWhiteSpace(key, nameof(key));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ private async Task DeletePayload(Payload payload, CancellationToken cancellation
{
Guard.Against.Null(payload, nameof(payload));

// NDS removed delete, replaced with new status of complete. so we can query the payload data from WFM
// TODO add config and cleanup methods that run on background thread/process

var scope = _serviceScopeFactory.CreateScope();
var repository = scope.ServiceProvider.GetService<IPayloadRepository>() ?? throw new ServiceNotFoundException(nameof(IPayloadRepository));
await repository.RemoveAsync(payload, cancellationToken).ConfigureAwait(false);
payload.State = Payload.PayloadState.UploadComplete;
await repository.UpdateAsync(payload, cancellationToken).ConfigureAwait(false);
}

private async Task NotifyPayloadReady(Payload payload)
Expand Down

0 comments on commit 9e7c670

Please sign in to comment.