Changes
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class GenerateAudioWorkflowPathsActivity(
|
||||
ILogger<GenerateAudioWorkflowPathsActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IExecuteActivity<GenerateAudioWorkflowPathsArguments>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Generate-Audio-Workflow-Paths";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<GenerateAudioWorkflowPathsArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(GenerateAudioWorkflowPathsActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
var folderName = Guid.NewGuid().ToString();
|
||||
var sourceFileName = Path.GetFileName(executeContext.Arguments.SourceKeyName);
|
||||
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, folderName);
|
||||
var sourceFilePath = Path.Combine(workingDirectory, sourceFileName);
|
||||
|
||||
Directory.CreateDirectory(workingDirectory);
|
||||
|
||||
logger.LogDebug("Generated audio workflow paths. WorkingDirectory: {WorkingDirectory}, SourceFilePath: {SourceFilePath}",
|
||||
workingDirectory,
|
||||
sourceFilePath);
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.CompletedWithVariables(new Dictionary<string, object>
|
||||
{
|
||||
[RoutingSlipVariableNames.Workflow.TempDirectory] = workingDirectory,
|
||||
[RoutingSlipVariableNames.Audio.WorkingDirectory] = workingDirectory,
|
||||
[RoutingSlipVariableNames.Audio.SourceFilePath] = sourceFilePath,
|
||||
[RoutingSlipVariableNames.Audio.TranscodedDirectory] = workingDirectory
|
||||
});
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error generating audio workflow paths for key {SourceKeyName}",
|
||||
executeContext.Arguments.SourceKeyName);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class TranscodeDashAudioActivity(
|
||||
IAudioTranscoder audioTranscoder,
|
||||
ILogger<TranscodeDashAudioActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<TranscodeDashAudioArguments, TranscodeDashAudioLog>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Transcode-Dash-Audio";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<TranscodeDashAudioArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(TranscodeDashAudioActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
||||
var workingDirectory = executeContext.GetVariable<string>(executeContext.Arguments.WorkingDirectoryVariableName);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(workingDirectory))
|
||||
{
|
||||
throw new InvalidOperationException("Transcode activity requires source file path and working directory variables.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await using var fileStream = File.OpenRead(sourceFilePath);
|
||||
|
||||
var result = await audioTranscoder.TranscodeToDashAsync(
|
||||
fileStream,
|
||||
workingDirectory,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!result.IsSuccess)
|
||||
{
|
||||
var errorMessage = string.Join("; ", result.Errors);
|
||||
logger.LogError("Transcoding failed for file {SourceFilePath}. Errors: {ErrorMessage}",
|
||||
sourceFilePath, errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error during transcoding activity for file {SourceFilePath}",
|
||||
sourceFilePath);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<CompensationResult> Compensate(CompensateContext<TranscodeDashAudioLog> compensateContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(compensateContext.Log.WorkingDirectory))
|
||||
{
|
||||
Directory.Delete(compensateContext.Log.WorkingDirectory, true);
|
||||
}
|
||||
|
||||
return Task.FromResult(compensateContext.Compensated());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating transcoded audio directory {WorkingDirectory}", compensateContext.Log.WorkingDirectory);
|
||||
return Task.FromResult(compensateContext.Failed(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class DownloadFileFromBucketActivity(
|
||||
IStorageHandler storageHandler,
|
||||
ILogger<DownloadFileFromBucketActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<DownloadFileFromBucketArguments, DownloadFileFromBucketLog>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Download-File-From-Bucket";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<DownloadFileFromBucketArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(DownloadFileFromBucketActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
||||
if (string.IsNullOrWhiteSpace(destinationPath))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Download activity requires variable '{executeContext.Arguments.DestinationFilePathVariableName}' with destination file path.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var getFile = await storageHandler.GetFileAsync(
|
||||
executeContext.Arguments.BucketName,
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!getFile.IsSuccess)
|
||||
{
|
||||
var errorMessage = string.Join("; ", getFile.Errors);
|
||||
logger.LogWarning("Failed to download file from bucket. Bucket: {BucketName}, Key: {KeyName}, Errors: {Errors}",
|
||||
executeContext.Arguments.BucketName,
|
||||
executeContext.Arguments.KeyName,
|
||||
errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
var destinationDirectory = Path.GetDirectoryName(destinationPath);
|
||||
if (!string.IsNullOrWhiteSpace(destinationDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
}
|
||||
|
||||
using var fileStream = getFile.Value;
|
||||
if (fileStream.CanSeek)
|
||||
fileStream.Position = 0;
|
||||
|
||||
using var destinationStream = File.Create(destinationPath);
|
||||
await fileStream.CopyToAsync(destinationStream, executeContext.CancellationToken);
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error downloading file from bucket");
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<CompensationResult> Compensate(CompensateContext<DownloadFileFromBucketLog> compensateContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(compensateContext.Log.DestinationFilePath))
|
||||
{
|
||||
File.Delete(compensateContext.Log.DestinationFilePath);
|
||||
}
|
||||
|
||||
return Task.FromResult(compensateContext.Compensated());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating downloaded file {DestinationFilePath}", compensateContext.Log.DestinationFilePath);
|
||||
return Task.FromResult(compensateContext.Failed(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class RemoveFileFromBucketActivity(
|
||||
IStorageHandler storageHandler,
|
||||
ILogger<RemoveFileFromBucketActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IExecuteActivity<RemoveFileFromBucketArguments>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Remove-File";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<RemoveFileFromBucketArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(RemoveFileFromBucketActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
var removeFile = await storageHandler.RemoveFileAsync(
|
||||
executeContext.Arguments.BucketName,
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!removeFile.IsSuccess)
|
||||
{
|
||||
var errorMessage = string.Join("; ", removeFile.Errors);
|
||||
logger.LogWarning("Failed to remove file {KeyName} from bucket {BucketName}. Errors: {Errors}",
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.Arguments.BucketName,
|
||||
errorMessage);
|
||||
}
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error removing file {KeyName} from bucket {BucketName}",
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.Arguments.BucketName);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class TransferFilesToBucket(
|
||||
IStorageHandler storageHandler,
|
||||
ILogger<TransferFilesToBucket> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<TransferFilesToBucketArguments, TransferFilesToBucketLog>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Transfer-Files-To-Bucket";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<TransferFilesToBucketArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(TransferFilesToBucket),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariableName);
|
||||
if (string.IsNullOrWhiteSpace(folderPath))
|
||||
{
|
||||
throw new InvalidOperationException(
|
||||
$"Transfer activity requires variable '{executeContext.Arguments.SourceDirectoryVariableName}' with source directory path.");
|
||||
}
|
||||
|
||||
var destinationKeyName = executeContext.Arguments.DestinationKeyName;
|
||||
if (string.IsNullOrWhiteSpace(destinationKeyName) && !string.IsNullOrWhiteSpace(executeContext.Arguments.DestinationKeyNameVariableName))
|
||||
{
|
||||
destinationKeyName = executeContext.GetVariable<string>(executeContext.Arguments.DestinationKeyNameVariableName);
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(destinationKeyName))
|
||||
{
|
||||
throw new InvalidOperationException("Transfer activity requires a destination key name from arguments or variables.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var uploadedKeys = Directory.GetFiles(folderPath)
|
||||
.Select(file => $"{destinationKeyName}/{Path.GetFileName(file)}")
|
||||
.ToArray();
|
||||
|
||||
var transferFilesResult = await storageHandler.TransferFilesAsync(
|
||||
folderPath,
|
||||
executeContext.Arguments.DestinationBucketName,
|
||||
destinationKeyName,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!transferFilesResult.IsSuccess)
|
||||
{
|
||||
var errorMessage = string.Join("; ", transferFilesResult.Errors);
|
||||
logger.LogWarning("Failed to transfer files from {FolderPath} to bucket {DestinationBucketName}, key {DestinationKeyName}. Errors: {Errors}",
|
||||
folderPath,
|
||||
executeContext.Arguments.DestinationBucketName,
|
||||
destinationKeyName,
|
||||
errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error transferring files from {FolderPath} to bucket {DestinationBucketName}",
|
||||
folderPath,
|
||||
executeContext.Arguments.DestinationBucketName);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<CompensationResult> Compensate(CompensateContext<TransferFilesToBucketLog> compensateContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var uploadedKey in compensateContext.Log.UploadedKeys)
|
||||
{
|
||||
await storageHandler.RemoveFileAsync(
|
||||
compensateContext.Log.DestinationBucketName,
|
||||
uploadedKey,
|
||||
compensateContext.CancellationToken);
|
||||
}
|
||||
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating transferred files to bucket {DestinationBucketName}", compensateContext.Log.DestinationBucketName);
|
||||
return compensateContext.Failed(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class GeneratePictureWorkflowPathsActivity(
|
||||
ILogger<GeneratePictureWorkflowPathsActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IExecuteActivity<GeneratePictureWorkflowPathsArguments>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Generate-Picture-Workflow-Paths";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<GeneratePictureWorkflowPathsArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(GeneratePictureWorkflowPathsActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
var destinationFolderName = Guid.NewGuid().ToString();
|
||||
var originalFileName = Path.GetFileName(executeContext.Arguments.SourceKeyName);
|
||||
var sourceFileExtension = Path.GetExtension(originalFileName);
|
||||
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, destinationFolderName);
|
||||
|
||||
|
||||
var sourceFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
||||
var smallPictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
||||
var mediumPictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
||||
var largePictureFileName = Guid.NewGuid().ToString() + sourceFileExtension;
|
||||
|
||||
var sourceFilePath = Path.Combine(workingDirectory, sourceFileName);
|
||||
var smallPictureFilePath = Path.Combine(workingDirectory, smallPictureFileName);
|
||||
var mediumPictureFilePath = Path.Combine(workingDirectory, mediumPictureFileName);
|
||||
var largePictureFilePath = Path.Combine(workingDirectory, largePictureFileName);
|
||||
|
||||
Directory.CreateDirectory(workingDirectory);
|
||||
|
||||
logger.LogDebug("Generated picture workflow paths. WorkingDirectory: {WorkingDirectory}, SourceFilePath: {SourceFilePath}",
|
||||
workingDirectory,
|
||||
sourceFilePath);
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.CompletedWithVariables(new Dictionary<string, object>
|
||||
{
|
||||
[RoutingSlipVariableNames.Workflow.TempDirectory] = workingDirectory,
|
||||
[RoutingSlipVariableNames.Picture.OriginalFilePath] = sourceFilePath,
|
||||
[RoutingSlipVariableNames.Picture.SmallResizedFilePath] = smallPictureFilePath,
|
||||
[RoutingSlipVariableNames.Picture.MediumResizedFilePath] = mediumPictureFilePath,
|
||||
[RoutingSlipVariableNames.Picture.LargeResizedFilePath] = largePictureFilePath,
|
||||
[RoutingSlipVariableNames.Picture.DestinationFolderName] = destinationFolderName
|
||||
} );
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error generating picture workflow paths for key {SourceKeyName}",
|
||||
executeContext.Arguments.SourceKeyName);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class ResizePictureActivity(
|
||||
IPictureHandler pictureHandler,
|
||||
ILogger<ResizePictureActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<ResizePictureLocalArguments, ResizePictureLog>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Resize-Picture";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<ResizePictureLocalArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(ResizePictureActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
||||
var destinationFilePath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
||||
|
||||
if (string.IsNullOrWhiteSpace(sourceFilePath) || string.IsNullOrWhiteSpace(destinationFilePath))
|
||||
{
|
||||
throw new InvalidOperationException("Resize activity requires source and destination file path variables.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!File.Exists(sourceFilePath))
|
||||
{
|
||||
logger.LogWarning("Source file not found at {SourceFilePath}", sourceFilePath);
|
||||
throw new FileNotFoundException($"Source file not found: {sourceFilePath}");
|
||||
}
|
||||
|
||||
await using var fileStream = File.OpenRead(sourceFilePath);
|
||||
|
||||
var resizedPicture = await pictureHandler.ResizePictureAsync(
|
||||
fileStream,
|
||||
executeContext.Arguments.Width,
|
||||
executeContext.Arguments.Height,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!resizedPicture.IsSuccess)
|
||||
{
|
||||
var errorMessage = string.Join("; ", resizedPicture.Errors);
|
||||
logger.LogError("Failed to resize picture {SourceFilePath} to {Width}x{Height}. Errors: {Errors}",
|
||||
sourceFilePath,
|
||||
executeContext.Arguments.Width,
|
||||
executeContext.Arguments.Height,
|
||||
errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
|
||||
var destinationDirectory = Path.GetDirectoryName(destinationFilePath);
|
||||
if (!string.IsNullOrEmpty(destinationDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(destinationDirectory);
|
||||
}
|
||||
|
||||
await using var destinationStream = File.Create(destinationFilePath);
|
||||
await resizedPicture.Value.CopyToAsync(destinationStream, executeContext.CancellationToken);
|
||||
|
||||
logger.LogDebug("Picture resized from {SourceFilePath} to {DestinationFilePath} ({Width}x{Height})",
|
||||
sourceFilePath,
|
||||
destinationFilePath,
|
||||
executeContext.Arguments.Width,
|
||||
executeContext.Arguments.Height);
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error resizing picture {SourceFilePath}", sourceFilePath);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Task<CompensationResult> Compensate(CompensateContext<ResizePictureLog> compensateContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(compensateContext.Log.DestinationFilePath))
|
||||
{
|
||||
File.Delete(compensateContext.Log.DestinationFilePath);
|
||||
}
|
||||
|
||||
return Task.FromResult(compensateContext.Compensated());
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating resized file {DestinationFilePath}", compensateContext.Log.DestinationFilePath);
|
||||
return Task.FromResult(compensateContext.Failed(exception));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class UpdatePlayListPictureActivity(
|
||||
IDatabase database,
|
||||
ILogger<UpdatePlayListPictureActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<UpdatePlayListPictureArguments, UpdatePlayListPictureLog>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Update-PlayList-Picture";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<UpdatePlayListPictureArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(UpdatePlayListPictureActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
var playList = await database.PlayLists.FindAsync(
|
||||
[executeContext.Arguments.PlayListId],
|
||||
cancellationToken: executeContext.CancellationToken);
|
||||
|
||||
if (playList is null)
|
||||
{
|
||||
logger.LogWarning("PlayList with id {PlayListId} not found",
|
||||
executeContext.Arguments.PlayListId);
|
||||
throw new InvalidOperationException($"PlayList with id {executeContext.Arguments.PlayListId} not found");
|
||||
}
|
||||
|
||||
var log = new UpdatePlayListPictureLog(
|
||||
playList.Id,
|
||||
playList.OriginalPictureKeyName,
|
||||
playList.SmallPictureKeyName,
|
||||
playList.MediumPictureKeyName,
|
||||
playList.LargePictureKeyName);
|
||||
|
||||
playList.OriginalPictureKeyName = executeContext.Arguments.OriginalPictureKeyName;
|
||||
playList.SmallPictureKeyName = executeContext.Arguments.SmallPictureKeyName;
|
||||
playList.MediumPictureKeyName = executeContext.Arguments.MediumPictureKeyName;
|
||||
playList.LargePictureKeyName = executeContext.Arguments.LargePictureKeyName;
|
||||
|
||||
database.PlayLists.Update(playList);
|
||||
await database.SaveChangesAsync(executeContext.CancellationToken);
|
||||
|
||||
logger.LogInformation("Updated PlayList {PlayListId} pictures",
|
||||
executeContext.Arguments.PlayListId);
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error updating PlayList {PlayListId} pictures",
|
||||
executeContext.Arguments.PlayListId);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<CompensationResult> Compensate(CompensateContext<UpdatePlayListPictureLog> compensateContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
var playList = await database.PlayLists.FindAsync(
|
||||
[compensateContext.Log.PlayListId],
|
||||
cancellationToken: compensateContext.CancellationToken);
|
||||
|
||||
if (playList is null)
|
||||
{
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
|
||||
playList.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKeyName;
|
||||
playList.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKeyName;
|
||||
playList.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKeyName;
|
||||
playList.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKeyName;
|
||||
|
||||
database.PlayLists.Update(playList);
|
||||
await database.SaveChangesAsync(compensateContext.CancellationToken);
|
||||
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating PlayList {PlayListId} pictures", compensateContext.Log.PlayListId);
|
||||
return compensateContext.Failed(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Activities
|
||||
{
|
||||
public class UpdateTrackPictureActivity(
|
||||
IDatabase database,
|
||||
ILogger<UpdateTrackPictureActivity> logger,
|
||||
IProcessTrackingStore processTrackingStore)
|
||||
: IActivity<UpdateTrackPictureArguments, UpdateTrackPictureLog>
|
||||
{
|
||||
public const string ExecuteEndpointName = "Update-Track-Picture";
|
||||
|
||||
public async Task<ExecutionResult> Execute(ExecuteContext<UpdateTrackPictureArguments> executeContext)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
"RoutingSlip",
|
||||
executeContext.CorrelationId ?? executeContext.TrackingNumber,
|
||||
executeContext.ConversationId,
|
||||
executeContext.MessageId,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
nameof(UpdateTrackPictureActivity),
|
||||
ProcessStepComponentType.Activity,
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
var track = await database.Tracks.FindAsync(
|
||||
[executeContext.Arguments.TrackId],
|
||||
cancellationToken: executeContext.CancellationToken);
|
||||
|
||||
if (track is null)
|
||||
{
|
||||
logger.LogWarning("Track with id {TrackId} not found",
|
||||
executeContext.Arguments.TrackId);
|
||||
throw new InvalidOperationException($"Track with id {executeContext.Arguments.TrackId} not found");
|
||||
}
|
||||
|
||||
var log = new UpdateTrackPictureLog(
|
||||
track.Id,
|
||||
track.OriginalPictureKeyName,
|
||||
track.SmallPictureKeyName,
|
||||
track.MediumPictureKeyName,
|
||||
track.LargePictureKeyName);
|
||||
|
||||
track.OriginalPictureKeyName = executeContext.Arguments.OriginalPictureKeyName;
|
||||
track.SmallPictureKeyName = executeContext.Arguments.SmallPictureKeyName;
|
||||
track.MediumPictureKeyName = executeContext.Arguments.MediumPictureKeyName;
|
||||
track.LargePictureKeyName = executeContext.Arguments.LargePictureKeyName;
|
||||
|
||||
database.Tracks.Update(track);
|
||||
await database.SaveChangesAsync(executeContext.CancellationToken);
|
||||
|
||||
logger.LogInformation("Updated Track {TrackId} pictures",
|
||||
executeContext.Arguments.TrackId);
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error updating Track {TrackId} pictures",
|
||||
executeContext.Arguments.TrackId);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<CompensationResult> Compensate(CompensateContext<UpdateTrackPictureLog> compensateContext)
|
||||
{
|
||||
try
|
||||
{
|
||||
var track = await database.Tracks.FindAsync(
|
||||
[compensateContext.Log.TrackId],
|
||||
cancellationToken: compensateContext.CancellationToken);
|
||||
|
||||
if (track is null)
|
||||
{
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
|
||||
track.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKeyName;
|
||||
track.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKeyName;
|
||||
track.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKeyName;
|
||||
track.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKeyName;
|
||||
|
||||
database.Tracks.Update(track);
|
||||
await database.SaveChangesAsync(compensateContext.CancellationToken);
|
||||
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating Track {TrackId} pictures", compensateContext.Log.TrackId);
|
||||
return compensateContext.Failed(exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record DownloadFileFromBucketArguments(
|
||||
string BucketName,
|
||||
string KeyName,
|
||||
string DestinationFilePathVariableName);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record GenerateAudioWorkflowPathsArguments(
|
||||
string TemporaryRootDirectory,
|
||||
string SourceKeyName);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record GeneratePictureWorkflowPathsArguments(
|
||||
string TemporaryRootDirectory,
|
||||
string SourceKeyName,
|
||||
string SmallPictureKeyName,
|
||||
string MediumPictureKeyName,
|
||||
string LargePictureKeyName);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record RemoveFileFromBucketArguments(
|
||||
string BucketName,
|
||||
string KeyName);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record ResizePictureLocalArguments(
|
||||
string SourceFilePathVariableName,
|
||||
string DestinationFilePathVariableName,
|
||||
int Width,
|
||||
int Height);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record TranscodeDashAudioArguments(
|
||||
string SourceFilePathVariableName,
|
||||
string WorkingDirectoryVariableName);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record TransferFilesToBucketArguments(
|
||||
string DestinationBucketName,
|
||||
string SourceDirectoryVariableName,
|
||||
string? DestinationKeyName = null,
|
||||
string? DestinationKeyNameVariableName = null);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record UpdatePlayListPictureArguments(
|
||||
Guid PlayListId,
|
||||
string OriginalPictureKeyName,
|
||||
string SmallPictureKeyName,
|
||||
string MediumPictureKeyName,
|
||||
string LargePictureKeyName);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Musify.Infrastructure.Messaging.Activities.Arguments
|
||||
{
|
||||
public record UpdateTrackPictureArguments(
|
||||
Guid TrackId,
|
||||
string OriginalPictureKeyName,
|
||||
string SmallPictureKeyName,
|
||||
string MediumPictureKeyName,
|
||||
string LargePictureKeyName);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Musify.Infrastructure.Messaging.Consumers
|
||||
{
|
||||
internal static class MessagingHelper
|
||||
{
|
||||
internal static Uri BuildExecuteActivityUri(string endpointName) => new($"queue:{endpointName}_execute");
|
||||
|
||||
internal static Uri BuildCompensateActivityUri(string endpointName) => new($"queue:{endpointName}_compensate");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Messaging.RoutingSlip.Builders;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Consumers
|
||||
{
|
||||
public class RemoveFileConsumer(
|
||||
IBus bus,
|
||||
RemoveFileRoutingSlipBuilder routingSlipBuilder)
|
||||
: IConsumer<RemoveFileEvent>
|
||||
{
|
||||
public const string QueueName = "Remove-File";
|
||||
|
||||
public async Task Consume(ConsumeContext<RemoveFileEvent> consumeContext)
|
||||
{
|
||||
var routingSlip = routingSlipBuilder
|
||||
.Build(consumeContext.Message, consumeContext.CorrelationId)
|
||||
.Build();
|
||||
|
||||
await bus.Execute(routingSlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Messaging.RoutingSlip.Builders;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Consumers
|
||||
{
|
||||
public class TranscodeAudioFromTrackConsumer(
|
||||
IBus bus,
|
||||
AudioWorkflowRoutingSlipBuilder routingSlipBuilder)
|
||||
: IConsumer<TranscodeAudioFromTrackEvent>
|
||||
{
|
||||
public const string QueueName = "Transcode-Audio-From-Track";
|
||||
|
||||
public async Task Consume(ConsumeContext<TranscodeAudioFromTrackEvent> consumeContext)
|
||||
{
|
||||
var routingSlip = routingSlipBuilder
|
||||
.Build(consumeContext.Message, consumeContext.CorrelationId)
|
||||
.Build();
|
||||
|
||||
await bus.Execute(routingSlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Messaging.RoutingSlip.Builders;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Consumers
|
||||
{
|
||||
public class UpdatePlayListPictureConsumer(
|
||||
IBus bus,
|
||||
PictureWorkflowRoutingSlipBuilder routingSlipBuilder)
|
||||
: IConsumer<UpdatePlayListPictureEvent>
|
||||
{
|
||||
public const string QueueName = "Update-PlayList-Picture";
|
||||
|
||||
public async Task Consume(ConsumeContext<UpdatePlayListPictureEvent> consumeContext)
|
||||
{
|
||||
var routingSlip = routingSlipBuilder
|
||||
.Build(consumeContext.Message, consumeContext.CorrelationId)
|
||||
.Build();
|
||||
|
||||
await bus.Execute(routingSlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Messaging.RoutingSlip.Builders;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Consumers
|
||||
{
|
||||
public class UpdateTrackPictureConsumer(
|
||||
IBus bus,
|
||||
PictureWorkflowRoutingSlipBuilder routingSlipBuilder)
|
||||
: IConsumer<UpdateTrackPictureEvent>
|
||||
{
|
||||
public const string QueueName = "Update-Track-Picture";
|
||||
|
||||
public async Task Consume(ConsumeContext<UpdateTrackPictureEvent> consumeContext)
|
||||
{
|
||||
var routingSlip = routingSlipBuilder
|
||||
.Build(consumeContext.Message, consumeContext.CorrelationId)
|
||||
.Build();
|
||||
|
||||
await bus.Execute(routingSlip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
using MassTransit;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Musify.Infrastructure.Configuration;
|
||||
using Musify.Infrastructure.Messaging.Activities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
using Musify.Infrastructure.Messaging.Activities.Logs;
|
||||
using Musify.Infrastructure.Messaging.Consumers;
|
||||
using Musify.Infrastructure.Messaging.Filters;
|
||||
using Musify.Infrastructure.Messaging.RoutingSlip.Builders;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging
|
||||
{
|
||||
public static class MessagingDependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddMassTransitClient(this IServiceCollection serviceDescriptors)
|
||||
{
|
||||
serviceDescriptors.AddMassTransit(options =>
|
||||
{
|
||||
options.UsingRabbitMq((busRegistrationContext, busFactoryConfigurator) =>
|
||||
ConfigureRabbitMqHost(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext.GetRequiredService<MessagingConfiguration>()));
|
||||
} );
|
||||
|
||||
return serviceDescriptors;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddMassTransitConsumers(this IServiceCollection serviceDescriptors)
|
||||
{
|
||||
serviceDescriptors.AddScoped<AudioWorkflowRoutingSlipBuilder>();
|
||||
serviceDescriptors.AddScoped<PictureWorkflowRoutingSlipBuilder>();
|
||||
serviceDescriptors.AddScoped<RemoveFileRoutingSlipBuilder>();
|
||||
|
||||
serviceDescriptors.AddMassTransit(options =>
|
||||
{
|
||||
options.AddConsumer<UpdatePlayListPictureConsumer>();
|
||||
options.AddConsumer<RemoveFileConsumer>();
|
||||
options.AddConsumer<TranscodeAudioFromTrackConsumer>();
|
||||
options.AddConsumer<UpdateTrackPictureConsumer>();
|
||||
|
||||
options.AddExecuteActivity<RemoveFileFromBucketActivity, RemoveFileFromBucketArguments>();
|
||||
options.AddExecuteActivity<GenerateAudioWorkflowPathsActivity, GenerateAudioWorkflowPathsArguments>();
|
||||
options.AddExecuteActivity<GeneratePictureWorkflowPathsActivity, GeneratePictureWorkflowPathsArguments>();
|
||||
|
||||
options.AddActivity<ResizePictureActivity, ResizePictureLocalArguments, ResizePictureLog>();
|
||||
options.AddActivity<UpdatePlayListPictureActivity, UpdatePlayListPictureArguments, UpdatePlayListPictureLog>();
|
||||
options.AddActivity<UpdateTrackPictureActivity, UpdateTrackPictureArguments, UpdateTrackPictureLog>();
|
||||
options.AddActivity<DownloadFileFromBucketActivity, DownloadFileFromBucketArguments, DownloadFileFromBucketLog>();
|
||||
options.AddActivity<TranscodeDashAudioActivity, TranscodeDashAudioArguments, TranscodeDashAudioLog>();
|
||||
options.AddActivity<TransferFilesToBucket, TransferFilesToBucketArguments, TransferFilesToBucketLog>();
|
||||
|
||||
options.UsingRabbitMq((busRegistrationContext, busFactoryConfigurator) =>
|
||||
{
|
||||
ConfigureRabbitMqHost(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext.GetRequiredService<MessagingConfiguration>());
|
||||
|
||||
busFactoryConfigurator.UseConsumeFilter(typeof(ProcessTrackingConsumeFilter<>), busRegistrationContext);
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(UpdatePlayListPictureConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<UpdatePlayListPictureConsumer>(busRegistrationContext);
|
||||
} );
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(RemoveFileConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<RemoveFileConsumer>(busRegistrationContext);
|
||||
} );
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(TranscodeAudioFromTrackConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<TranscodeAudioFromTrackConsumer>(busRegistrationContext);
|
||||
} );
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(UpdateTrackPictureConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<UpdateTrackPictureConsumer>(busRegistrationContext);
|
||||
} );
|
||||
|
||||
ConfigureExecuteActivityEndpoint<RemoveFileFromBucketActivity, RemoveFileFromBucketArguments>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
RemoveFileFromBucketActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureExecuteActivityEndpoint<GenerateAudioWorkflowPathsActivity, GenerateAudioWorkflowPathsArguments>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
GenerateAudioWorkflowPathsActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureExecuteActivityEndpoint<GeneratePictureWorkflowPathsActivity, GeneratePictureWorkflowPathsArguments>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
GeneratePictureWorkflowPathsActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureActivityEndpoint<ResizePictureActivity, ResizePictureLocalArguments, ResizePictureLog>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
ResizePictureActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureActivityEndpoint<UpdatePlayListPictureActivity, UpdatePlayListPictureArguments, UpdatePlayListPictureLog>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
UpdatePlayListPictureActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureActivityEndpoint<UpdateTrackPictureActivity, UpdateTrackPictureArguments, UpdateTrackPictureLog>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
UpdateTrackPictureActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureActivityEndpoint<DownloadFileFromBucketActivity, DownloadFileFromBucketArguments, DownloadFileFromBucketLog>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
DownloadFileFromBucketActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureActivityEndpoint<TranscodeDashAudioActivity, TranscodeDashAudioArguments, TranscodeDashAudioLog>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
TranscodeDashAudioActivity.ExecuteEndpointName);
|
||||
|
||||
ConfigureActivityEndpoint<TransferFilesToBucket, TransferFilesToBucketArguments, TransferFilesToBucketLog>(
|
||||
busFactoryConfigurator,
|
||||
busRegistrationContext,
|
||||
TransferFilesToBucket.ExecuteEndpointName);
|
||||
} );
|
||||
} );
|
||||
|
||||
return serviceDescriptors;
|
||||
}
|
||||
|
||||
static void ConfigureRabbitMqHost(
|
||||
IRabbitMqBusFactoryConfigurator busFactoryConfigurator,
|
||||
MessagingConfiguration massTransitConfiguration)
|
||||
{
|
||||
busFactoryConfigurator.Host(massTransitConfiguration.Host, options =>
|
||||
{
|
||||
options.Username(massTransitConfiguration.Username);
|
||||
options.Password(massTransitConfiguration.Password);
|
||||
} );
|
||||
}
|
||||
|
||||
static void ConfigureExecuteActivityEndpoint<TActivity, TArguments>(
|
||||
IRabbitMqBusFactoryConfigurator busFactoryConfigurator,
|
||||
IBusRegistrationContext busRegistrationContext,
|
||||
string endpointName)
|
||||
where TActivity : class, IExecuteActivity<TArguments>
|
||||
where TArguments : class
|
||||
{
|
||||
busFactoryConfigurator.ReceiveEndpoint($"{endpointName}_execute", endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ExecuteActivityHost<TActivity, TArguments>(busRegistrationContext);
|
||||
} );
|
||||
}
|
||||
|
||||
static void ConfigureActivityEndpoint<TActivity, TArguments, TLog>(
|
||||
IRabbitMqBusFactoryConfigurator busFactoryConfigurator,
|
||||
IBusRegistrationContext busRegistrationContext,
|
||||
string endpointName)
|
||||
where TActivity : class, IActivity<TArguments, TLog>
|
||||
where TArguments : class
|
||||
where TLog : class
|
||||
{
|
||||
busFactoryConfigurator.ReceiveEndpoint($"{endpointName}_execute", endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ExecuteActivityHost<TActivity, TArguments>(busRegistrationContext);
|
||||
} );
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint($"{endpointName}_compensate", endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.CompensateActivityHost<TActivity, TLog>(busRegistrationContext);
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging
|
||||
{
|
||||
public class MassTransitEventBus(IPublishEndpoint publishEndpoint)
|
||||
: IEventBus
|
||||
{
|
||||
public async Task PublishAsync<T>(T message, CancellationToken cancellationToken)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(message, nameof(message));
|
||||
|
||||
await publishEndpoint.Publish(message, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Contracts.Infrastructure;
|
||||
using Musify.Domain.Entities;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.Filters
|
||||
{
|
||||
public class ProcessTrackingConsumeFilter<TMessage>(IProcessTrackingStore processTrackingStore)
|
||||
: IFilter<ConsumeContext<TMessage>>
|
||||
where TMessage : class
|
||||
{
|
||||
public async Task Send(ConsumeContext<TMessage> context, IPipe<ConsumeContext<TMessage>> next)
|
||||
{
|
||||
var processId = await processTrackingStore.GetOrCreateProcessAsync(
|
||||
typeof(TMessage).Name,
|
||||
context.CorrelationId ?? context.MessageId,
|
||||
context.ConversationId,
|
||||
context.MessageId,
|
||||
context.CancellationToken);
|
||||
|
||||
var stepId = await processTrackingStore.StartStepAsync(
|
||||
processId,
|
||||
$"{typeof(TMessage).Name}.Consume",
|
||||
ProcessStepComponentType.Consumer,
|
||||
0,
|
||||
context.CancellationToken);
|
||||
|
||||
try
|
||||
{
|
||||
await next.Send(context);
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, context.CancellationToken);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
await processTrackingStore.FailStepAsync(
|
||||
processId,
|
||||
stepId,
|
||||
exception.Message,
|
||||
context.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void Probe(ProbeContext context)
|
||||
{
|
||||
context.CreateFilterScope(nameof(ProcessTrackingConsumeFilter<TMessage>));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,8 @@ namespace Musify.Infrastructure.Messaging.Activities.Logs
|
||||
{
|
||||
public record UpdatePlayListPictureLog(
|
||||
Guid PlayListId,
|
||||
string? PreviousSmallPictureKeyName,
|
||||
string? PreviousMediumPictureKeyName,
|
||||
string? PreviousLargePictureKeyName);
|
||||
string PreviousOriginalPictureKeyName,
|
||||
string PreviousSmallPictureKeyName,
|
||||
string PreviousMediumPictureKeyName,
|
||||
string PreviousLargePictureKeyName);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ namespace Musify.Infrastructure.Messaging.Activities.Logs
|
||||
{
|
||||
public record UpdateTrackPictureLog(
|
||||
Guid TrackId,
|
||||
string? PreviousSmallPictureKeyName,
|
||||
string? PreviousMediumPictureKeyName,
|
||||
string? PreviousLargePictureKeyName);
|
||||
string PreviousOriginalPictureKeyName,
|
||||
string PreviousSmallPictureKeyName,
|
||||
string PreviousMediumPictureKeyName,
|
||||
string PreviousLargePictureKeyName);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
namespace Musify.Infrastructure.Messaging.RoutingSlip
|
||||
{
|
||||
internal static class ActivityNames
|
||||
{
|
||||
internal const string GenerateAudioWorkflowPaths = "GenerateAudioWorkflowPaths";
|
||||
internal const string GeneratePictureWorkflowPaths = "GeneratePictureWorkflowPaths";
|
||||
internal const string DownloadFile = "DownloadFile";
|
||||
internal const string TranscodeAudio = "TranscodeAudio";
|
||||
internal const string ResizeSmall = "ResizeSmall";
|
||||
internal const string ResizeMedium = "ResizeMedium";
|
||||
internal const string ResizeLarge = "ResizeLarge";
|
||||
internal const string UploadFiles = "UploadFiles";
|
||||
internal const string RemoveFile = "RemoveFile";
|
||||
internal const string DeleteOriginal = "DeleteOriginal";
|
||||
internal const string UpdateTrackPicture = "UpdateTrackPicture";
|
||||
internal const string UpdatePlayListPicture = "UpdatePlayListPicture";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Configuration;
|
||||
using Musify.Infrastructure.Messaging.Activities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.RoutingSlip.Builders
|
||||
{
|
||||
public class AudioWorkflowRoutingSlipBuilder(WorkerConfiguration workerConfiguration)
|
||||
{
|
||||
public RoutingSlipBuilder Build(TranscodeAudioFromTrackEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.GenerateAudioWorkflowPaths,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(GenerateAudioWorkflowPathsActivity.ExecuteEndpointName),
|
||||
new GenerateAudioWorkflowPathsArguments(
|
||||
workerConfiguration.Routes.TemporaryFilesDirectory,
|
||||
message.SourceKeyName));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.DownloadFile,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(DownloadFileFromBucketActivity.ExecuteEndpointName),
|
||||
new DownloadFileFromBucketArguments(
|
||||
message.SourceBucketName,
|
||||
message.SourceKeyName,
|
||||
RoutingSlipVariableNames.Audio.SourceFilePath));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.TranscodeAudio,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(TranscodeDashAudioActivity.ExecuteEndpointName),
|
||||
new TranscodeDashAudioArguments(
|
||||
RoutingSlipVariableNames.Audio.SourceFilePath,
|
||||
RoutingSlipVariableNames.Workflow.TempDirectory));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.UploadFiles,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(TransferFilesToBucket.ExecuteEndpointName),
|
||||
new TransferFilesToBucketArguments(
|
||||
message.DestinationBucketName,
|
||||
RoutingSlipVariableNames.Audio.TranscodedDirectory,
|
||||
message.DestinationKeyName));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Configuration;
|
||||
using Musify.Infrastructure.Messaging.Activities;
|
||||
using Musify.Infrastructure.Messaging.Activities.Arguments;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.RoutingSlip.Builders
|
||||
{
|
||||
public class PictureWorkflowRoutingSlipBuilder(WorkerConfiguration workerConfiguration)
|
||||
{
|
||||
public RoutingSlipBuilder Build(UpdateTrackPictureEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = BuildPictureWorkflow(
|
||||
message.SourceBucketName,
|
||||
message.SourceKeyName,
|
||||
message.SmallPictureKeyName,
|
||||
message.SmallPictureWidth,
|
||||
message.SmallPictureHeight,
|
||||
message.MediumPictureKeyName,
|
||||
message.MediumPictureWidth,
|
||||
message.MediumPictureHeight,
|
||||
message.LargePictureKeyName,
|
||||
message.LargePictureWidth,
|
||||
message.LargePictureHeight,
|
||||
correlationId);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.UpdateTrackPicture,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(UpdateTrackPictureActivity.ExecuteEndpointName),
|
||||
new UpdateTrackPictureArguments(
|
||||
message.TrackId,
|
||||
message.SourceKeyName,
|
||||
message.SmallPictureKeyName,
|
||||
message.MediumPictureKeyName,
|
||||
message.LargePictureKeyName));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
|
||||
public RoutingSlipBuilder Build(UpdatePlayListPictureEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = BuildPictureWorkflow(
|
||||
message.SourceBucketName,
|
||||
message.SourceKeyName,
|
||||
message.SmallPictureKeyName,
|
||||
message.SmallPictureWidth,
|
||||
message.SmallPictureHeight,
|
||||
message.MediumPictureKeyName,
|
||||
message.MediumPictureWidth,
|
||||
message.MediumPictureHeight,
|
||||
message.LargePictureKeyName,
|
||||
message.LargePictureWidth,
|
||||
message.LargePictureHeight,
|
||||
correlationId);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.UpdatePlayListPicture,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(UpdatePlayListPictureActivity.ExecuteEndpointName),
|
||||
new UpdatePlayListPictureArguments(
|
||||
message.PlayListId,
|
||||
message.SourceKeyName,
|
||||
message.SmallPictureKeyName,
|
||||
message.MediumPictureKeyName,
|
||||
message.LargePictureKeyName));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
|
||||
RoutingSlipBuilder BuildPictureWorkflow(
|
||||
string sourceBucketName,
|
||||
string sourceKeyName,
|
||||
string smallPictureKeyName,
|
||||
int smallPictureWidth,
|
||||
int smallPictureHeight,
|
||||
string mediumPictureKeyName,
|
||||
int mediumPictureWidth,
|
||||
int mediumPictureHeight,
|
||||
string largePictureKeyName,
|
||||
int largePictureWidth,
|
||||
int largePictureHeight,
|
||||
Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.GeneratePictureWorkflowPaths,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(GeneratePictureWorkflowPathsActivity.ExecuteEndpointName),
|
||||
new GeneratePictureWorkflowPathsArguments(
|
||||
workerConfiguration.Routes.TemporaryFilesDirectory,
|
||||
sourceKeyName,
|
||||
smallPictureKeyName,
|
||||
mediumPictureKeyName,
|
||||
largePictureKeyName));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.DownloadFile,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(DownloadFileFromBucketActivity.ExecuteEndpointName),
|
||||
new DownloadFileFromBucketArguments(
|
||||
sourceBucketName,
|
||||
sourceKeyName,
|
||||
RoutingSlipVariableNames.Picture.OriginalFilePath));
|
||||
|
||||
AddResizeActivity(
|
||||
routingSlipBuilder,
|
||||
ActivityNames.ResizeSmall,
|
||||
RoutingSlipVariableNames.Picture.SmallResizedFilePath,
|
||||
smallPictureWidth,
|
||||
smallPictureHeight);
|
||||
|
||||
AddResizeActivity(
|
||||
routingSlipBuilder,
|
||||
ActivityNames.ResizeMedium,
|
||||
RoutingSlipVariableNames.Picture.MediumResizedFilePath,
|
||||
mediumPictureWidth,
|
||||
mediumPictureHeight);
|
||||
|
||||
AddResizeActivity(
|
||||
routingSlipBuilder,
|
||||
ActivityNames.ResizeLarge,
|
||||
RoutingSlipVariableNames.Picture.LargeResizedFilePath,
|
||||
largePictureWidth,
|
||||
largePictureHeight);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.DeleteOriginal,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(RemoveFileFromBucketActivity.ExecuteEndpointName),
|
||||
new RemoveFileFromBucketArguments(sourceBucketName, sourceKeyName));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.UploadFiles,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(TransferFilesToBucket.ExecuteEndpointName),
|
||||
new TransferFilesToBucketArguments(
|
||||
sourceBucketName,
|
||||
RoutingSlipVariableNames.Workflow.TempDirectory,
|
||||
DestinationKeyNameVariableName: RoutingSlipVariableNames.Picture.DestinationFolderName));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
|
||||
static void AddResizeActivity(
|
||||
RoutingSlipBuilder routingSlipBuilder,
|
||||
string activityName,
|
||||
string destinationFilePathVariableName,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
routingSlipBuilder.AddActivity(
|
||||
activityName,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(ResizePictureActivity.ExecuteEndpointName),
|
||||
new ResizePictureLocalArguments(
|
||||
RoutingSlipVariableNames.Picture.OriginalFilePath,
|
||||
destinationFilePathVariableName,
|
||||
width,
|
||||
height));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using MassTransit;
|
||||
using Musify.Application.Events;
|
||||
using Musify.Infrastructure.Messaging.Activities;
|
||||
|
||||
namespace Musify.Infrastructure.Messaging.RoutingSlip.Builders
|
||||
{
|
||||
public class RemoveFileRoutingSlipBuilder
|
||||
{
|
||||
public RoutingSlipBuilder Build(RemoveFileEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.RemoveFile,
|
||||
Consumers.MessagingHelper.BuildExecuteActivityUri(RemoveFileFromBucketActivity.ExecuteEndpointName),
|
||||
new Activities.Arguments.RemoveFileFromBucketArguments(
|
||||
message.BucketName,
|
||||
message.KeyName));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace Musify.Infrastructure.Messaging
|
||||
{
|
||||
internal static class RoutingSlipVariableNames
|
||||
{
|
||||
internal static class Workflow
|
||||
{
|
||||
internal const string TempDirectory = "Workflow.TempDirectory";
|
||||
internal const string CorrelationId = "Workflow.CorrelationId";
|
||||
}
|
||||
|
||||
internal static class Audio
|
||||
{
|
||||
internal const string SourceFilePath = "Audio.SourceFilePath";
|
||||
internal const string WorkingDirectory = "Audio.WorkingDirectory";
|
||||
internal const string TranscodedDirectory = "Audio.TranscodedDirectory";
|
||||
}
|
||||
|
||||
internal static class Picture
|
||||
{
|
||||
internal const string OriginalFilePath = "Picture.OriginalFilePath";
|
||||
internal const string SmallResizedFilePath = "Picture.SmallResizedFilePath";
|
||||
internal const string MediumResizedFilePath = "Picture.MediumResizedFilePath";
|
||||
internal const string LargeResizedFilePath = "Picture.LargeResizedFilePath";
|
||||
internal const string DestinationFolderName = "Picture.DestinationFolderName";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user