[FA-misc] Add IJobStatusUpdate event contract and publishing helper
This commit is contained in:
@@ -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