feat(infra): add Track processing saga (state machine, phase 1)
Introduce a MassTransit saga state machine that correlates by TrackId and
tracks the two parallel processing slips (picture + audio):
- TrackProcessingStateMachine + EF-persisted TrackProcessingState
(pessimistic concurrency, EntityFrameworkRepository), migration added
- Starts on CreateTrackResourcesEvent; UpdateTrack{Picture,Audio}Activity now
publish TrackPictureProcessed / TrackAudioProcessed on success; when both
arrive the saga finalizes (Ready). Failure transitions to a Failed state
(cleanup wired in the next phase)
- Add LifeCycleStatus.Failed and the four outcome events
Verified: booted the Worker against RabbitMQ + migrated Postgres in Docker;
the saga endpoint 'track-processing-state' is configured and the bus starts
clean.
Build: 0 warnings, 0 errors.
This commit is contained in:
+6
@@ -1,6 +1,7 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Domain.ValueObjects;
|
||||
using Musify.Infrastructure.MassTransit.Arguments;
|
||||
using Musify.Infrastructure.MassTransit.Logs;
|
||||
@@ -9,6 +10,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Pictures
|
||||
{
|
||||
internal class UpdateTrackPictureActivity(
|
||||
IDatabase database,
|
||||
IPublishEndpoint publishEndpoint,
|
||||
ILogger<UpdateTrackPictureActivity> logger)
|
||||
: IActivity<UpdateTrackPictureArguments, UpdateTrackPictureLog>
|
||||
{
|
||||
@@ -55,6 +57,10 @@ namespace Musify.Infrastructure.MassTransit.Activities.Pictures
|
||||
logger.LogInformation("Updated track {TrackId} pictures",
|
||||
executeContext.Arguments.TrackId);
|
||||
|
||||
await publishEndpoint.Publish(
|
||||
new TrackPictureProcessed(executeContext.Arguments.TrackId),
|
||||
executeContext.CancellationToken);
|
||||
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
Reference in New Issue
Block a user