Compare commits
4 Commits
epic/FA-mi
...
c25f59a4b4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c25f59a4b4 | ||
|
|
be1ebbea39 | ||
| 67521d6530 | |||
| 3820cb3af9 |
9
FictionArchive.Common/Enums/JobStatus.cs
Normal file
9
FictionArchive.Common/Enums/JobStatus.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace FictionArchive.Common.Enums;
|
||||
|
||||
public enum JobStatus
|
||||
{
|
||||
Failed = -1,
|
||||
Pending = 0,
|
||||
InProgress = 1,
|
||||
Completed = 2
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Contracts.Events;
|
||||
|
||||
public interface IJobStatusUpdate
|
||||
{
|
||||
Guid JobId { get; }
|
||||
Guid? ParentJobId { get; }
|
||||
string JobType { get; }
|
||||
string DisplayName { get; }
|
||||
JobStatus Status { get; }
|
||||
string? ErrorMessage { get; }
|
||||
Dictionary<string, string>? Metadata { get; }
|
||||
}
|
||||
|
||||
public record JobStatusUpdate(
|
||||
Guid JobId,
|
||||
Guid? ParentJobId,
|
||||
string JobType,
|
||||
string DisplayName,
|
||||
JobStatus Status,
|
||||
string? ErrorMessage,
|
||||
Dictionary<string, string>? Metadata) : IJobStatusUpdate;
|
||||
@@ -0,0 +1,20 @@
|
||||
using FictionArchive.Common.Enums;
|
||||
using FictionArchive.Service.Shared.Contracts.Events;
|
||||
using MassTransit;
|
||||
|
||||
namespace FictionArchive.Service.Shared.Extensions;
|
||||
|
||||
public static class JobStatusPublisher
|
||||
{
|
||||
public static Task ReportJobStatus(
|
||||
this IPublishEndpoint endpoint,
|
||||
Guid jobId,
|
||||
string jobType,
|
||||
string displayName,
|
||||
JobStatus status,
|
||||
Guid? parentJobId = null,
|
||||
string? errorMessage = null,
|
||||
Dictionary<string, string>? metadata = null)
|
||||
=> endpoint.Publish<IJobStatusUpdate>(new JobStatusUpdate(
|
||||
jobId, parentJobId, jobType, displayName, status, errorMessage, metadata));
|
||||
}
|
||||
Reference in New Issue
Block a user