refactor(jobs): modularize background job handlers
Some checks failed
ci / release-gate (push) Has been cancelled
Some checks failed
ci / release-gate (push) Has been cancelled
This commit is contained in:
@@ -103,11 +103,29 @@ public sealed record BackgroundJobExecutionContext(
|
||||
string JobType,
|
||||
JsonElement Payload);
|
||||
|
||||
public sealed record BackgroundJobHandlerResult(
|
||||
JsonElement Result,
|
||||
Guid? OutputAssetId = null);
|
||||
|
||||
public sealed class BackgroundJobHandlerException(string code, string message, Exception? innerException = null)
|
||||
: Exception(message, innerException)
|
||||
{
|
||||
public string Code { get; } = code;
|
||||
}
|
||||
|
||||
public interface IBackgroundJobHandler
|
||||
{
|
||||
string JobType { get; }
|
||||
|
||||
Task<JsonElement> HandleAsync(
|
||||
Task<BackgroundJobHandlerResult> HandleAsync(
|
||||
BackgroundJobExecutionContext context,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
Task HandleFailureAsync(
|
||||
BackgroundJobExecutionContext context,
|
||||
Exception exception,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user