Rename variables
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
namespace Musify.Application.Events
|
||||
{
|
||||
public record ImageSize(
|
||||
string SavePath,
|
||||
int Width,
|
||||
int Height);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Musify.Application.Events
|
||||
{
|
||||
public record RemoveFileEvent(
|
||||
string BucketName,
|
||||
string KeyName);
|
||||
string Bucket,
|
||||
string Key);
|
||||
}
|
||||
@@ -2,15 +2,9 @@
|
||||
{
|
||||
public record UpdatePlayListPictureEvent(
|
||||
Guid PlayListId,
|
||||
string SourceBucketName,
|
||||
string SourceKeyName,
|
||||
string SmallPictureRoute,
|
||||
int SmallPictureWidth,
|
||||
int SmallPictureHeight,
|
||||
string MediumPictureRoute,
|
||||
int MediumPictureWidth,
|
||||
int MediumPictureHeight,
|
||||
string LargePictureRoute,
|
||||
int LargePictureWidth,
|
||||
int LargePictureHeight);
|
||||
string Bucket,
|
||||
string SourceKey,
|
||||
ImageSize Small,
|
||||
ImageSize Medium,
|
||||
ImageSize Large);
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
{
|
||||
public record UpdateTrackAudioEvent(
|
||||
Guid TrackId,
|
||||
string SourceBucketName,
|
||||
string SourceKeyName,
|
||||
string DestinationBucketName,
|
||||
string DestinationFolderKeyName);
|
||||
string SourceBucket,
|
||||
string SourceKey,
|
||||
string DestinationBucket,
|
||||
string DestinationFolderKey);
|
||||
}
|
||||
@@ -2,15 +2,9 @@
|
||||
{
|
||||
public record UpdateTrackPictureEvent(
|
||||
Guid TrackId,
|
||||
string SourceBucketName,
|
||||
string SourceKeyName,
|
||||
string SmallPictureRoute,
|
||||
int SmallPictureWidth,
|
||||
int SmallPictureHeight,
|
||||
string MediumPictureRoute,
|
||||
int MediumPictureWidth,
|
||||
int MediumPictureHeight,
|
||||
string LargePictureRoute,
|
||||
int LargePictureWidth,
|
||||
int LargePictureHeight);
|
||||
string Bucket,
|
||||
string SourceKey,
|
||||
ImageSize Small,
|
||||
ImageSize Medium,
|
||||
ImageSize Large);
|
||||
}
|
||||
@@ -95,21 +95,25 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
return uploadFileResult;
|
||||
}
|
||||
|
||||
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
||||
async Task PublishUpdateEvent(string originalPictureKey, PlayList playList, CancellationToken cancellationToken)
|
||||
{
|
||||
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
||||
playList.Id,
|
||||
storageConfiguration.BucketName,
|
||||
originalPictureKeyName,
|
||||
playListConfiguration.Routes.SmallPicturesPath,
|
||||
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
||||
playListConfiguration.PicturesSizes.SmallPictureHeight,
|
||||
playListConfiguration.Routes.MediumPicturesPath,
|
||||
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
||||
playListConfiguration.PicturesSizes.MediumPictureHeight,
|
||||
playListConfiguration.Routes.LargePicturesPath,
|
||||
playListConfiguration.PicturesSizes.LargePictureWidth,
|
||||
playListConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
||||
originalPictureKey,
|
||||
new ImageSize(
|
||||
playListConfiguration.Routes.SmallPicturesPath,
|
||||
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
||||
playListConfiguration.PicturesSizes.SmallPictureHeight),
|
||||
new ImageSize(
|
||||
playListConfiguration.Routes.MediumPicturesPath,
|
||||
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
||||
playListConfiguration.PicturesSizes.MediumPictureHeight),
|
||||
new ImageSize(
|
||||
playListConfiguration.Routes.LargePicturesPath,
|
||||
playListConfiguration.PicturesSizes.LargePictureWidth,
|
||||
playListConfiguration.PicturesSizes.LargePictureHeight)),
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,11 +92,11 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
database.PlayLists.Update(playList);
|
||||
await database.SaveChangesAsync(cancellationToken);
|
||||
|
||||
logger.LogInformation("Updated PlayList with id={PlayListId} and picture key {PictureKeyName}.", playList.Id, newImageStorageKey);
|
||||
logger.LogInformation("Updated PlayList with id={PlayListId} and picture key {PictureKey}.", playList.Id, newImageStorageKey);
|
||||
return Result.Success(PlayListResponse.FromEntity(playList));
|
||||
}
|
||||
|
||||
async Task<Result> PublishRemoveFileEvent(string keyName, CancellationToken cancellationToken)
|
||||
async Task<Result> PublishRemoveFileEvent(string key, CancellationToken cancellationToken)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -104,14 +104,14 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
storageConfiguration.BucketName,
|
||||
Path.Combine(
|
||||
playListConfiguration.Routes.ParentFolders,
|
||||
keyName)), cancellationToken);
|
||||
key)), cancellationToken);
|
||||
|
||||
return Result.NoContent();
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Failed to publish remove file event for key {KeyName}.", keyName);
|
||||
return Result.Error($"Failed to publish remove file event for key {keyName}.");
|
||||
logger.LogError(exception, "Failed to publish remove file event for key {Key}.", key);
|
||||
return Result.Error($"Failed to publish remove file event for key {key}.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,21 +127,25 @@ namespace Musify.Application.PlayLists.Handlers
|
||||
return uploadFileResult;
|
||||
}
|
||||
|
||||
async Task PublishUpdateEvent(string originalPictureKeyName, PlayList playList, CancellationToken cancellationToken)
|
||||
async Task PublishUpdateEvent(string originalPictureKey, PlayList playList, CancellationToken cancellationToken)
|
||||
{
|
||||
await eventBus.PublishAsync(new UpdatePlayListPictureEvent(
|
||||
playList.Id,
|
||||
storageConfiguration.BucketName,
|
||||
originalPictureKeyName,
|
||||
playListConfiguration.Routes.SmallPicturesPath,
|
||||
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
||||
playListConfiguration.PicturesSizes.SmallPictureHeight,
|
||||
playListConfiguration.Routes.MediumPicturesPath,
|
||||
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
||||
playListConfiguration.PicturesSizes.MediumPictureHeight,
|
||||
playListConfiguration.Routes.LargePicturesPath,
|
||||
playListConfiguration.PicturesSizes.LargePictureWidth,
|
||||
playListConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
||||
originalPictureKey,
|
||||
new ImageSize(
|
||||
playListConfiguration.Routes.SmallPicturesPath,
|
||||
playListConfiguration.PicturesSizes.SmallPictureWidth,
|
||||
playListConfiguration.PicturesSizes.SmallPictureHeight),
|
||||
new ImageSize(
|
||||
playListConfiguration.Routes.MediumPicturesPath,
|
||||
playListConfiguration.PicturesSizes.MediumPictureWidth,
|
||||
playListConfiguration.PicturesSizes.MediumPictureHeight),
|
||||
new ImageSize(
|
||||
playListConfiguration.Routes.LargePicturesPath,
|
||||
playListConfiguration.PicturesSizes.LargePictureWidth,
|
||||
playListConfiguration.PicturesSizes.LargePictureHeight)),
|
||||
cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,9 +38,9 @@ namespace Musify.Application.Tracks.Handler
|
||||
LargePictureKeyName = trackConfiguration.Routes.PresetLargePicture,
|
||||
};
|
||||
|
||||
var originalPictureKeyName = Path.Combine(trackConfiguration.Routes.OriginalPicturesPath,
|
||||
var originalPictureKey = Path.Combine(trackConfiguration.Routes.OriginalPicturesPath,
|
||||
originalPictureFileName);
|
||||
var pictureUploadResult = await UploadFile(request.Picture, originalPictureKeyName, cancellationToken);
|
||||
var pictureUploadResult = await UploadFile(request.Picture, originalPictureKey, cancellationToken);
|
||||
if (!pictureUploadResult.IsSuccess)
|
||||
{
|
||||
logger.LogError("Failed to upload picture for track {TrackTitle}", request.Title);
|
||||
@@ -48,9 +48,9 @@ namespace Musify.Application.Tracks.Handler
|
||||
}
|
||||
|
||||
|
||||
var audioKeyName = Path.Combine(trackConfiguration.Routes.OriginalAudiosPath,
|
||||
var audioKey = Path.Combine(trackConfiguration.Routes.OriginalAudiosPath,
|
||||
Guid.NewGuid() + request.Audio.FileType);
|
||||
var audioUploadResult = await UploadFile(request.Audio, audioKeyName, cancellationToken);
|
||||
var audioUploadResult = await UploadFile(request.Audio, audioKey, cancellationToken);
|
||||
if (!audioUploadResult.IsSuccess)
|
||||
{
|
||||
logger.LogError("Failed to upload audio for track {TrackTitle}", request.Title);
|
||||
@@ -59,7 +59,7 @@ namespace Musify.Application.Tracks.Handler
|
||||
|
||||
try
|
||||
{
|
||||
await PublishUpdateEvent(originalPictureKeyName, track, cancellationToken);
|
||||
await PublishUpdateEvent(originalPictureKey, track, cancellationToken);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
@@ -83,36 +83,39 @@ namespace Musify.Application.Tracks.Handler
|
||||
return Result.Success();
|
||||
}
|
||||
|
||||
async Task<Result<string>> UploadFile(IFileData fileData, string keyName, CancellationToken cancellationToken)
|
||||
async Task<Result<string>> UploadFile(IFileData fileData, string key, CancellationToken cancellationToken)
|
||||
{
|
||||
var uploadFile = await storageHandler.UploadFileAsync(
|
||||
fileData.FileStream,
|
||||
fileData.ContentType,
|
||||
storageConfiguration.BucketName,
|
||||
keyName,
|
||||
key,
|
||||
cancellationToken);
|
||||
|
||||
return uploadFile;
|
||||
}
|
||||
|
||||
async Task PublishUpdateEvent(string originalPictureKeyName, Track track, CancellationToken cancellationToken)
|
||||
async Task PublishUpdateEvent(string originalPictureKey, Track track, CancellationToken cancellationToken)
|
||||
{
|
||||
await eventBus.PublishAsync(new UpdateTrackPictureEvent(
|
||||
track.Id,
|
||||
storageConfiguration.BucketName,
|
||||
originalPictureKeyName,
|
||||
trackConfiguration.Routes.SmallPicturesPath,
|
||||
trackConfiguration.PicturesSizes.SmallPictureWidth,
|
||||
trackConfiguration.PicturesSizes.SmallPictureHeight,
|
||||
trackConfiguration.Routes.MediumPicturesPath,
|
||||
trackConfiguration.PicturesSizes.MediumPictureWidth,
|
||||
trackConfiguration.PicturesSizes.MediumPictureHeight,
|
||||
trackConfiguration.Routes.LargePicturesPath,
|
||||
trackConfiguration.PicturesSizes.LargePictureWidth,
|
||||
trackConfiguration.PicturesSizes.LargePictureHeight), cancellationToken);
|
||||
originalPictureKey,
|
||||
new ImageSize(
|
||||
trackConfiguration.Routes.PresetSmallPicture,
|
||||
trackConfiguration.PicturesSizes.SmallPictureWidth,
|
||||
trackConfiguration.PicturesSizes.SmallPictureHeight),
|
||||
new ImageSize(
|
||||
trackConfiguration.Routes.PresetMediumPicture,
|
||||
trackConfiguration.PicturesSizes.MediumPictureWidth,
|
||||
trackConfiguration.PicturesSizes.MediumPictureHeight),
|
||||
new ImageSize(
|
||||
trackConfiguration.Routes.PresetLargePicture,
|
||||
trackConfiguration.PicturesSizes.LargePictureWidth,
|
||||
trackConfiguration.PicturesSizes.LargePictureHeight)), cancellationToken);
|
||||
}
|
||||
|
||||
async Task PublishTranscodeEvent(Guid trackId, string audioKeyName, CancellationToken cancellationToken)
|
||||
async Task PublishTranscodeEvent(Guid trackId, string audioKey, CancellationToken cancellationToken)
|
||||
{
|
||||
var destinationFolderAudio = Path.Combine(trackConfiguration.Routes.ProcessedAudiosPath,
|
||||
Guid.NewGuid().ToString());
|
||||
@@ -120,7 +123,7 @@ namespace Musify.Application.Tracks.Handler
|
||||
await eventBus.PublishAsync(new UpdateTrackAudioEvent(
|
||||
trackId,
|
||||
storageConfiguration.BucketName,
|
||||
audioKeyName,
|
||||
audioKey,
|
||||
storageConfiguration.BucketName,
|
||||
destinationFolderAudio), cancellationToken);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
try
|
||||
{
|
||||
var folderName = Guid.NewGuid().ToString();
|
||||
var sourceFileName = Path.GetFileName(executeContext.Arguments.SourceKeyName);
|
||||
var sourceFileName = Path.GetFileName(executeContext.Arguments.SourceKey);
|
||||
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, folderName);
|
||||
var sourceFilePath = Path.Combine(workingDirectory, sourceFileName);
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error generating audio workflow paths for key {SourceKeyName}",
|
||||
executeContext.Arguments.SourceKeyName);
|
||||
executeContext.Arguments.SourceKey);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariable);
|
||||
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||
var workingDirectory = executeContext.GetVariable<string>(executeContext.Arguments.WorkingDirectoryVariableName);
|
||||
var workingDirectory = executeContext.GetVariable<string>(executeContext.Arguments.WorkingDirectoryVariable);
|
||||
ArgumentNullException.ThrowIfNull(workingDirectory, nameof(workingDirectory));
|
||||
|
||||
try
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio
|
||||
track.Id,
|
||||
track.AudioFolderKeyName);
|
||||
|
||||
track.AudioFolderKeyName = Path.GetFileName(executeContext.Arguments.AudioFolderKeyName);
|
||||
track.AudioFolderKeyName = Path.GetFileName(executeContext.Arguments.AudioFolderKey);
|
||||
|
||||
database.Tracks.Update(track);
|
||||
await database.SaveChangesAsync(executeContext.CancellationToken);
|
||||
@@ -81,7 +81,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Audio
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
|
||||
track.AudioFolderKeyName = compensateContext.Log.PreviousFolderAudioKeyName;
|
||||
track.AudioFolderKeyName = compensateContext.Log.PreviousFolderAudioKey;
|
||||
|
||||
database.Tracks.Update(track);
|
||||
await database.SaveChangesAsync(compensateContext.CancellationToken);
|
||||
|
||||
@@ -31,22 +31,22 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
||||
var destinationPath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariable);
|
||||
ArgumentNullException.ThrowIfNull(destinationPath, nameof(destinationPath));
|
||||
|
||||
try
|
||||
{
|
||||
var getFile = await storageHandler.GetFileAsync(
|
||||
executeContext.Arguments.BucketName,
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.Arguments.Bucket,
|
||||
executeContext.Arguments.Key,
|
||||
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,
|
||||
executeContext.Arguments.Bucket,
|
||||
executeContext.Arguments.Key,
|
||||
errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
@@ -64,8 +64,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.Completed(new DownloadFileFromBucketLog(
|
||||
executeContext.Arguments.BucketName,
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.Arguments.Bucket,
|
||||
executeContext.Arguments.Key,
|
||||
destinationPath));
|
||||
}
|
||||
catch (Exception exception)
|
||||
|
||||
@@ -33,16 +33,16 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
try
|
||||
{
|
||||
var removeFile = await storageHandler.RemoveFileAsync(
|
||||
executeContext.Arguments.BucketName,
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.Arguments.Bucket,
|
||||
executeContext.Arguments.Key,
|
||||
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,
|
||||
executeContext.Arguments.Key,
|
||||
executeContext.Arguments.Bucket,
|
||||
errorMessage);
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error removing file {KeyName} from bucket {BucketName}",
|
||||
executeContext.Arguments.KeyName,
|
||||
executeContext.Arguments.BucketName);
|
||||
executeContext.Arguments.Key,
|
||||
executeContext.Arguments.Bucket);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -31,22 +31,21 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariableName);
|
||||
var folderPath = executeContext.GetVariable<string>(executeContext.Arguments.SourceDirectoryVariable);
|
||||
ArgumentNullException.ThrowIfNull(folderPath, nameof(folderPath));
|
||||
|
||||
var destinationKeyName = executeContext.Arguments.DestinationKeyName;
|
||||
ArgumentNullException.ThrowIfNull(destinationKeyName, nameof(destinationKeyName));
|
||||
var destinationKey = executeContext.Arguments.DestinationKey;
|
||||
ArgumentNullException.ThrowIfNull(destinationKey, nameof(destinationKey));
|
||||
|
||||
try
|
||||
{
|
||||
var uploadedKeys = Directory.GetFiles(folderPath)
|
||||
.Select(file => Path.Combine(destinationKeyName, Path.GetFileName(file)))
|
||||
.Select(file => Path.Combine(destinationKey, Path.GetFileName(file)))
|
||||
.ToArray();
|
||||
|
||||
var transferFilesResult = await storageHandler.TransferFilesAsync(
|
||||
folderPath,
|
||||
executeContext.Arguments.DestinationBucketName,
|
||||
destinationKeyName,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
destinationKey,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
if (!transferFilesResult.IsSuccess)
|
||||
@@ -54,8 +53,8 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
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,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
destinationKey,
|
||||
errorMessage);
|
||||
throw new Exception(errorMessage);
|
||||
}
|
||||
@@ -67,7 +66,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
{
|
||||
logger.LogError(exception, "Error transferring files from {FolderPath} to bucket {DestinationBucketName}",
|
||||
folderPath,
|
||||
executeContext.Arguments.DestinationBucketName);
|
||||
executeContext.Arguments.DestinationBucket);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
@@ -80,7 +79,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
foreach (var uploadedKey in compensateContext.Log.UploadedKeys)
|
||||
{
|
||||
await storageHandler.RemoveFileAsync(
|
||||
compensateContext.Log.DestinationBucketName,
|
||||
compensateContext.Log.DestinationBucket,
|
||||
uploadedKey,
|
||||
compensateContext.CancellationToken);
|
||||
}
|
||||
@@ -89,7 +88,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error compensating transferred files to bucket {DestinationBucketName}", compensateContext.Log.DestinationBucketName);
|
||||
logger.LogError(exception, "Error compensating transferred files to bucket {DestinationBucketName}", compensateContext.Log.DestinationBucket);
|
||||
return compensateContext.Failed(exception);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariableName);
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.FilePathVariable);
|
||||
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||
var fileName = Path.GetFileName(sourceFilePath);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
{
|
||||
var uploadResult = await storageHandler.UploadFileAsync(
|
||||
sourceFilePath,
|
||||
executeContext.Arguments.DestinationBucketName,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
Path.Combine(executeContext.Arguments.DestinationRoute, fileName),
|
||||
executeContext.CancellationToken);
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
{
|
||||
var errors = string.Join("; ", uploadResult.Errors);
|
||||
logger.LogWarning("Failed to upload file to bucket. Bucket: {BucketName}, Key: {KeyName}, Errors: {Errors}",
|
||||
executeContext.Arguments.DestinationBucketName,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
executeContext.Arguments.DestinationRoute,
|
||||
errors);
|
||||
throw new Exception(errors);
|
||||
@@ -55,7 +55,7 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
|
||||
await processTrackingStore.CompleteStepAsync(processId, stepId, executeContext.CancellationToken);
|
||||
return executeContext.CompletedWithVariables(new UploadFileToBucketLog(
|
||||
executeContext.Arguments.DestinationBucketName,
|
||||
executeContext.Arguments.DestinationBucket,
|
||||
executeContext.Arguments.DestinationRoute));
|
||||
}
|
||||
catch (Exception exception)
|
||||
@@ -71,14 +71,14 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
try
|
||||
{
|
||||
var uploadResult = await storageHandler.RemoveFileAsync(
|
||||
compensateContext.Log.DestinationBucketName,
|
||||
compensateContext.Log.DestinationKeyName,
|
||||
compensateContext.Log.DestinationBucket,
|
||||
compensateContext.Log.DestinationKey,
|
||||
compensateContext.CancellationToken);
|
||||
|
||||
if (!uploadResult.IsSuccess)
|
||||
{
|
||||
var errors = string.Join("; ", uploadResult.Errors);
|
||||
var errorMessage = $"Failed to remove file from bucket during compensation. Bucket: {compensateContext.Log.DestinationBucketName}, Key: {compensateContext.Log.DestinationKeyName}, Errors: {errors}";
|
||||
var errorMessage = $"Failed to remove file from bucket during compensation. Bucket: {compensateContext.Log.DestinationBucket}, Key: {compensateContext.Log.DestinationKey}, Errors: {errors}";
|
||||
|
||||
logger.LogError(errorMessage);
|
||||
return compensateContext.Failed(new Exception(errorMessage));
|
||||
@@ -88,8 +88,8 @@ namespace Musify.Infrastructure.MassTransit.Activities.Files
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "An error occurred while compensating upload file to bucket activity for bucket {BucketName} and key {KeyName}",
|
||||
compensateContext.Log.DestinationBucketName,
|
||||
compensateContext.Log.DestinationKeyName);
|
||||
compensateContext.Log.DestinationBucket,
|
||||
compensateContext.Log.DestinationKey);
|
||||
return compensateContext.Failed(exception);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
var workingDirectory = Path.Combine(executeContext.Arguments.TemporaryRootDirectory, destinationFolderName);
|
||||
|
||||
var sourceFilePath = Path.Combine(
|
||||
workingDirectory, Guid.NewGuid().ToString() + Path.GetExtension(executeContext.Arguments.SourceKeyName));
|
||||
workingDirectory, Guid.NewGuid().ToString() + Path.GetExtension(executeContext.Arguments.SourceKey));
|
||||
var smallPictureFilePath = Path.Combine(
|
||||
workingDirectory, Guid.NewGuid().ToString() + ResizedPictureFileExtension);
|
||||
var mediumPictureFilePath = Path.Combine(
|
||||
@@ -65,7 +65,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
catch (Exception exception)
|
||||
{
|
||||
logger.LogError(exception, "Error generating picture workflow paths for key {SourceKeyName}",
|
||||
executeContext.Arguments.SourceKeyName);
|
||||
executeContext.Arguments.SourceKey);
|
||||
await processTrackingStore.FailStepAsync(processId, stepId, exception.Message, executeContext.CancellationToken);
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -32,9 +32,9 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariableName);
|
||||
var sourceFilePath = executeContext.GetVariable<string>(executeContext.Arguments.SourceFilePathVariable);
|
||||
ArgumentNullException.ThrowIfNull(sourceFilePath, nameof(sourceFilePath));
|
||||
var destinationFilePath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariableName);
|
||||
var destinationFilePath = executeContext.GetVariable<string>(executeContext.Arguments.DestinationFilePathVariable);
|
||||
ArgumentNullException.ThrowIfNull(destinationFilePath, nameof(destinationFilePath));
|
||||
|
||||
try
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariableName);
|
||||
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariable);
|
||||
ArgumentNullException.ThrowIfNull(smallResizedVariable, nameof(smallResizedVariable));
|
||||
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariableName);
|
||||
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariable);
|
||||
ArgumentNullException.ThrowIfNull(mediumResizedVariable, nameof(mediumResizedVariable));
|
||||
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariableName);
|
||||
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariable);
|
||||
ArgumentNullException.ThrowIfNull(largeResizedVariable, nameof(largeResizedVariable));
|
||||
|
||||
try
|
||||
@@ -58,7 +58,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
playList.MediumPictureKeyName,
|
||||
playList.LargePictureKeyName);
|
||||
|
||||
playList.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
|
||||
playList.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKey);
|
||||
playList.SmallPictureKeyName = Path.GetFileName(smallResizedVariable);
|
||||
playList.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable);
|
||||
playList.LargePictureKeyName = Path.GetFileName(largeResizedVariable);
|
||||
@@ -94,10 +94,10 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
|
||||
playList.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKeyName;
|
||||
playList.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKeyName;
|
||||
playList.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKeyName;
|
||||
playList.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKeyName;
|
||||
playList.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKey;
|
||||
playList.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKey;
|
||||
playList.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKey;
|
||||
playList.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKey;
|
||||
|
||||
database.PlayLists.Update(playList);
|
||||
await database.SaveChangesAsync(compensateContext.CancellationToken);
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
0,
|
||||
executeContext.CancellationToken);
|
||||
|
||||
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariableName);
|
||||
var smallResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.SmallPictureVariable);
|
||||
ArgumentNullException.ThrowIfNull(smallResizedVariable, nameof(smallResizedVariable));
|
||||
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariableName);
|
||||
var mediumResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.MediumPictureVariable);
|
||||
ArgumentNullException.ThrowIfNull(mediumResizedVariable, nameof(mediumResizedVariable));
|
||||
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariableName);
|
||||
var largeResizedVariable = executeContext.GetVariable<string>(executeContext.Arguments.LargePictureVariable);
|
||||
ArgumentNullException.ThrowIfNull(largeResizedVariable, nameof(largeResizedVariable));
|
||||
|
||||
try
|
||||
@@ -58,7 +58,7 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
track.MediumPictureKeyName,
|
||||
track.LargePictureKeyName);
|
||||
|
||||
track.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKeyName);
|
||||
track.OriginalPictureKeyName = Path.GetFileName(executeContext.Arguments.OriginalPictureKey);
|
||||
track.SmallPictureKeyName = Path.GetFileName(smallResizedVariable);
|
||||
track.MediumPictureKeyName = Path.GetFileName(mediumResizedVariable);
|
||||
track.LargePictureKeyName = Path.GetFileName(largeResizedVariable);
|
||||
@@ -94,10 +94,10 @@ namespace Musify.Infrastructure.MassTransit.Activities
|
||||
return compensateContext.Compensated();
|
||||
}
|
||||
|
||||
track.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKeyName;
|
||||
track.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKeyName;
|
||||
track.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKeyName;
|
||||
track.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKeyName;
|
||||
track.OriginalPictureKeyName = compensateContext.Log.PreviousOriginalPictureKey;
|
||||
track.SmallPictureKeyName = compensateContext.Log.PreviousSmallPictureKey;
|
||||
track.MediumPictureKeyName = compensateContext.Log.PreviousMediumPictureKey;
|
||||
track.LargePictureKeyName = compensateContext.Log.PreviousLargePictureKey;
|
||||
|
||||
database.Tracks.Update(track);
|
||||
await database.SaveChangesAsync(compensateContext.CancellationToken);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record DownloadFileFromBucketArguments(
|
||||
string BucketName,
|
||||
string KeyName,
|
||||
string DestinationFilePathVariableName);
|
||||
string Bucket,
|
||||
string Key,
|
||||
string DestinationFilePathVariable);
|
||||
}
|
||||
@@ -2,5 +2,5 @@ namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record GenerateAudioWorkflowPathsArguments(
|
||||
string TemporaryRootDirectory,
|
||||
string SourceKeyName);
|
||||
string SourceKey);
|
||||
}
|
||||
|
||||
@@ -2,5 +2,5 @@ namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record GeneratePictureWorkflowPathsArguments(
|
||||
string TemporaryRootDirectory,
|
||||
string SourceKeyName);
|
||||
string SourceKey);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record RemoveFileFromBucketArguments(
|
||||
string BucketName,
|
||||
string KeyName);
|
||||
string Bucket,
|
||||
string Key);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record ResizePictureLocalArguments(
|
||||
string SourceFilePathVariableName,
|
||||
string DestinationFilePathVariableName,
|
||||
string SourceFilePathVariable,
|
||||
string DestinationFilePathVariable,
|
||||
int Width,
|
||||
int Height);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record TranscodeDashAudioArguments(
|
||||
string SourceFilePathVariableName,
|
||||
string WorkingDirectoryVariableName);
|
||||
string SourceFilePathVariable,
|
||||
string WorkingDirectoryVariable);
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Arguments
|
||||
{
|
||||
public record TransferFilesToBucketArguments(
|
||||
string DestinationBucketName,
|
||||
string SourceDirectoryVariableName,
|
||||
string? DestinationKeyName = null,
|
||||
string? DestinationKeyNameVariableName = null);
|
||||
string DestinationBucket,
|
||||
string SourceDirectoryVariable,
|
||||
string DestinationKey);
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
{
|
||||
public record UpdatePlayListPictureArguments(
|
||||
Guid PlayListId,
|
||||
string OriginalPictureKeyName,
|
||||
string SmallPictureVariableName,
|
||||
string MediumPictureVariableName,
|
||||
string LargePictureVariableName);
|
||||
string OriginalPictureKey,
|
||||
string SmallPictureVariable,
|
||||
string MediumPictureVariable,
|
||||
string LargePictureVariable);
|
||||
}
|
||||
@@ -2,5 +2,5 @@
|
||||
{
|
||||
public record UpdateTrackAudioArguments(
|
||||
Guid TrackId,
|
||||
string AudioFolderKeyName);
|
||||
string AudioFolderKey);
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
{
|
||||
public record UpdateTrackPictureArguments(
|
||||
Guid TrackId,
|
||||
string OriginalPictureKeyName,
|
||||
string SmallPictureVariableName,
|
||||
string MediumPictureVariableName,
|
||||
string LargePictureVariableName);
|
||||
string OriginalPictureKey,
|
||||
string SmallPictureVariable,
|
||||
string MediumPictureVariable,
|
||||
string LargePictureVariable);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Arguments
|
||||
{
|
||||
public record UploadFileToBucketArguments(
|
||||
string FilePathVariableName,
|
||||
string DestinationBucketName,
|
||||
string FilePathVariable,
|
||||
string DestinationBucket,
|
||||
string DestinationRoute);
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
using MassTransit;
|
||||
using MassTransit.Courier.Contracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Musify.Infrastructure.MassTransit;
|
||||
|
||||
namespace Musify.Infrastructure.MassTransit.Consumers
|
||||
{
|
||||
|
||||
@@ -65,29 +65,19 @@ namespace Musify.Infrastructure.MassTransit
|
||||
busFactoryConfigurator.UseConsumeFilter(typeof(ProcessTrackingConsumeFilter<>), busRegistrationContext);
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(UpdatePlayListPictureConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<UpdatePlayListPictureConsumer>(busRegistrationContext);
|
||||
} );
|
||||
endpointConfigurator.ConfigureConsumer<UpdatePlayListPictureConsumer>(busRegistrationContext));
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(RemoveFileConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<RemoveFileConsumer>(busRegistrationContext);
|
||||
} );
|
||||
endpointConfigurator.ConfigureConsumer<RemoveFileConsumer>(busRegistrationContext));
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(UpdateTrackAudioConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<UpdateTrackAudioConsumer>(busRegistrationContext);
|
||||
} );
|
||||
endpointConfigurator.ConfigureConsumer<UpdateTrackAudioConsumer>(busRegistrationContext));
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(UpdateTrackPictureConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<UpdateTrackPictureConsumer>(busRegistrationContext);
|
||||
} );
|
||||
endpointConfigurator.ConfigureConsumer<UpdateTrackPictureConsumer>(busRegistrationContext));
|
||||
|
||||
busFactoryConfigurator.ReceiveEndpoint(RoutingSlipCleanUpConsumer.QueueName, endpointConfigurator =>
|
||||
{
|
||||
endpointConfigurator.ConfigureConsumer<RoutingSlipCleanUpConsumer>(busRegistrationContext);
|
||||
} );
|
||||
endpointConfigurator.ConfigureConsumer<RoutingSlipCleanUpConsumer>(busRegistrationContext));
|
||||
|
||||
ConfigureExecuteActivityEndpoint<RemoveFileFromBucketActivity, RemoveFileFromBucketArguments>(
|
||||
busFactoryConfigurator,
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Musify.Infrastructure.MassTransit.Filters
|
||||
|
||||
public void Probe(ProbeContext context)
|
||||
{
|
||||
context.CreateFilterScope(nameof(ProcessTrackingConsumeFilter<TMessage>));
|
||||
context.CreateFilterScope(nameof(ProcessTrackingConsumeFilter<>));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Logs
|
||||
{
|
||||
public record DownloadFileFromBucketLog(
|
||||
string BucketName,
|
||||
string KeyName,
|
||||
string Bucket,
|
||||
string Key,
|
||||
string DestinationFilePath);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Activities.Logs
|
||||
{
|
||||
public record TransferFilesToBucketLog(string DestinationBucketName, string[] UploadedKeys);
|
||||
public record TransferFilesToBucketLog(string DestinationBucket, string[] UploadedKeys);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ namespace Musify.Infrastructure.MassTransit.Activities.Logs
|
||||
{
|
||||
public record UpdatePlayListPictureLog(
|
||||
Guid PlayListId,
|
||||
string PreviousOriginalPictureKeyName,
|
||||
string PreviousSmallPictureKeyName,
|
||||
string PreviousMediumPictureKeyName,
|
||||
string PreviousLargePictureKeyName);
|
||||
string PreviousOriginalPictureKey,
|
||||
string PreviousSmallPictureKey,
|
||||
string PreviousMediumPictureKey,
|
||||
string PreviousLargePictureKey);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Logs
|
||||
{
|
||||
public record UpdateTrackAudioLog(Guid TrackId,
|
||||
string PreviousFolderAudioKeyName);
|
||||
public record UpdateTrackAudioLog(
|
||||
Guid TrackId,
|
||||
string PreviousFolderAudioKey);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@ namespace Musify.Infrastructure.MassTransit.Activities.Logs
|
||||
{
|
||||
public record UpdateTrackPictureLog(
|
||||
Guid TrackId,
|
||||
string PreviousOriginalPictureKeyName,
|
||||
string PreviousSmallPictureKeyName,
|
||||
string PreviousMediumPictureKeyName,
|
||||
string PreviousLargePictureKeyName);
|
||||
string PreviousOriginalPictureKey,
|
||||
string PreviousSmallPictureKey,
|
||||
string PreviousMediumPictureKey,
|
||||
string PreviousLargePictureKey);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Musify.Infrastructure.MassTransit.Logs
|
||||
{
|
||||
public record UploadFileToBucketLog(string DestinationBucketName, string DestinationKeyName);
|
||||
public record UploadFileToBucketLog(string DestinationBucket, string DestinationKey);
|
||||
}
|
||||
@@ -15,7 +15,6 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
public RoutingSlipBuilder Build(UpdateTrackAudioEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddSubscription(
|
||||
@@ -27,14 +26,14 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
EndpointHelper.BuildExecuteActivityUri(GenerateAudioWorkflowPathsActivity.ExecuteEndpointName),
|
||||
new GenerateAudioWorkflowPathsArguments(
|
||||
workerConfiguration.Routes.TemporaryFilesDirectory,
|
||||
message.SourceKeyName));
|
||||
message.SourceKey));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.DownloadFile,
|
||||
EndpointHelper.BuildExecuteActivityUri(DownloadFileFromBucketActivity.ExecuteEndpointName),
|
||||
new DownloadFileFromBucketArguments(
|
||||
message.SourceBucketName,
|
||||
message.SourceKeyName,
|
||||
message.SourceBucket,
|
||||
message.SourceKey,
|
||||
RoutingSlipVariableNames.Audio.SourceFilePath));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
@@ -48,16 +47,16 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
ActivityNames.TransferFiles,
|
||||
EndpointHelper.BuildExecuteActivityUri(TransferFilesToBucketActivity.ExecuteEndpointName),
|
||||
new TransferFilesToBucketArguments(
|
||||
message.DestinationBucketName,
|
||||
message.DestinationBucket,
|
||||
RoutingSlipVariableNames.Audio.TranscodedDirectory,
|
||||
message.DestinationFolderKeyName));
|
||||
message.DestinationFolderKey));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.UpdateTrackAudio,
|
||||
EndpointHelper.BuildExecuteActivityUri(UpdateTrackAudioActivity.ExecuteEndpointName),
|
||||
new UpdateTrackAudioArguments(
|
||||
message.TrackId,
|
||||
message.DestinationFolderKeyName));
|
||||
message.DestinationFolderKey));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
|
||||
+31
-58
@@ -15,17 +15,11 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
public RoutingSlipBuilder Build(UpdateTrackPictureEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = BuildPictureWorkflow(
|
||||
message.SourceBucketName,
|
||||
message.SourceKeyName,
|
||||
message.SmallPictureRoute,
|
||||
message.SmallPictureWidth,
|
||||
message.SmallPictureHeight,
|
||||
message.MediumPictureRoute,
|
||||
message.MediumPictureWidth,
|
||||
message.MediumPictureHeight,
|
||||
message.LargePictureRoute,
|
||||
message.LargePictureWidth,
|
||||
message.LargePictureHeight,
|
||||
message.Bucket,
|
||||
message.SourceKey,
|
||||
message.Small,
|
||||
message.Medium,
|
||||
message.Large,
|
||||
correlationId);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
@@ -33,7 +27,7 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
EndpointHelper.BuildExecuteActivityUri(UpdateTrackPictureActivity.ExecuteEndpointName),
|
||||
new UpdateTrackPictureArguments(
|
||||
message.TrackId,
|
||||
message.SourceKeyName,
|
||||
message.SourceKey,
|
||||
RoutingSlipVariableNames.Picture.SmallResizedFilePath,
|
||||
RoutingSlipVariableNames.Picture.MediumResizedFilePath,
|
||||
RoutingSlipVariableNames.Picture.LargeResizedFilePath));
|
||||
@@ -44,17 +38,11 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
public RoutingSlipBuilder Build(UpdatePlayListPictureEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = BuildPictureWorkflow(
|
||||
message.SourceBucketName,
|
||||
message.SourceKeyName,
|
||||
message.SmallPictureRoute,
|
||||
message.SmallPictureWidth,
|
||||
message.SmallPictureHeight,
|
||||
message.MediumPictureRoute,
|
||||
message.MediumPictureWidth,
|
||||
message.MediumPictureHeight,
|
||||
message.LargePictureRoute,
|
||||
message.LargePictureWidth,
|
||||
message.LargePictureHeight,
|
||||
message.Bucket,
|
||||
message.SourceKey,
|
||||
message.Small,
|
||||
message.Medium,
|
||||
message.Large,
|
||||
correlationId);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
@@ -62,7 +50,7 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
EndpointHelper.BuildExecuteActivityUri(UpdatePlayListPictureActivity.ExecuteEndpointName),
|
||||
new UpdatePlayListPictureArguments(
|
||||
message.PlayListId,
|
||||
message.SourceKeyName,
|
||||
message.SourceKey,
|
||||
RoutingSlipVariableNames.Picture.SmallResizedFilePath,
|
||||
RoutingSlipVariableNames.Picture.MediumResizedFilePath,
|
||||
RoutingSlipVariableNames.Picture.LargeResizedFilePath));
|
||||
@@ -71,71 +59,58 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
}
|
||||
|
||||
RoutingSlipBuilder BuildPictureWorkflow(
|
||||
string bucketName,
|
||||
string sourceKeyName,
|
||||
string destinationSmallPictureRoute,
|
||||
int smallPictureWidth,
|
||||
int smallPictureHeight,
|
||||
string destinationMediumPictureRoute,
|
||||
int mediumPictureWidth,
|
||||
int mediumPictureHeight,
|
||||
string destinationLargePictureRoute,
|
||||
int largePictureWidth,
|
||||
int largePictureHeight,
|
||||
string bucket,
|
||||
string sourceKey,
|
||||
ImageSize small,
|
||||
ImageSize medium,
|
||||
ImageSize large,
|
||||
Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddSubscription(
|
||||
EndpointHelper.BuildConsumerUri(RoutingSlipCleanUpConsumer.QueueName),
|
||||
RoutingSlipEvents.Completed | RoutingSlipEvents.Faulted);
|
||||
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.GeneratePictureWorkflowPaths,
|
||||
EndpointHelper.BuildExecuteActivityUri(GeneratePictureWorkflowPathsActivity.ExecuteEndpointName),
|
||||
new GeneratePictureWorkflowPathsArguments(
|
||||
workerConfiguration.Routes.TemporaryFilesDirectory,
|
||||
sourceKeyName));
|
||||
sourceKey));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
ActivityNames.DownloadFile,
|
||||
EndpointHelper.BuildExecuteActivityUri(DownloadFileFromBucketActivity.ExecuteEndpointName),
|
||||
new DownloadFileFromBucketArguments(
|
||||
bucketName,
|
||||
sourceKeyName,
|
||||
bucket,
|
||||
sourceKey,
|
||||
RoutingSlipVariableNames.Picture.OriginalFilePath));
|
||||
|
||||
AddResizeActivity(
|
||||
routingSlipBuilder,
|
||||
ActivityNames.ResizeSmall,
|
||||
ActivityNames.UploadSmall,
|
||||
bucketName,
|
||||
bucket,
|
||||
RoutingSlipVariableNames.Picture.SmallResizedFilePath,
|
||||
destinationSmallPictureRoute,
|
||||
smallPictureWidth,
|
||||
smallPictureHeight);
|
||||
small);
|
||||
|
||||
AddResizeActivity(
|
||||
routingSlipBuilder,
|
||||
ActivityNames.ResizeMedium,
|
||||
ActivityNames.ResizeMedium,
|
||||
bucketName,
|
||||
bucket,
|
||||
RoutingSlipVariableNames.Picture.MediumResizedFilePath,
|
||||
destinationMediumPictureRoute,
|
||||
mediumPictureWidth,
|
||||
mediumPictureHeight);
|
||||
medium);
|
||||
|
||||
AddResizeActivity(
|
||||
routingSlipBuilder,
|
||||
ActivityNames.ResizeLarge,
|
||||
ActivityNames.UploadLarge,
|
||||
bucketName,
|
||||
bucket,
|
||||
RoutingSlipVariableNames.Picture.LargeResizedFilePath,
|
||||
destinationLargePictureRoute,
|
||||
largePictureWidth,
|
||||
largePictureHeight);
|
||||
large);
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
@@ -146,9 +121,7 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
string uploadActivityName,
|
||||
string bucketName,
|
||||
string destinationFilePathVariableName,
|
||||
string destinationBucketRoute,
|
||||
int width,
|
||||
int height)
|
||||
ImageSize imageSize)
|
||||
{
|
||||
routingSlipBuilder.AddActivity(
|
||||
resizeActivityName,
|
||||
@@ -156,8 +129,8 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
new ResizePictureLocalArguments(
|
||||
RoutingSlipVariableNames.Picture.OriginalFilePath,
|
||||
destinationFilePathVariableName,
|
||||
width,
|
||||
height));
|
||||
imageSize.Width,
|
||||
imageSize.Height));
|
||||
|
||||
routingSlipBuilder.AddActivity(
|
||||
uploadActivityName,
|
||||
@@ -165,7 +138,7 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
new UploadFileToBucketArguments(
|
||||
destinationFilePathVariableName,
|
||||
bucketName,
|
||||
destinationBucketRoute));
|
||||
imageSize.SavePath));
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-3
@@ -12,7 +12,6 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
public RoutingSlipBuilder Build(RemoveFileEvent message, Guid? correlationId)
|
||||
{
|
||||
var routingSlipBuilder = new RoutingSlipBuilder(NewId.NextGuid());
|
||||
|
||||
routingSlipBuilder.AddVariable(RoutingSlipVariableNames.Workflow.CorrelationId, correlationId ?? Guid.Empty);
|
||||
|
||||
routingSlipBuilder.AddSubscription(
|
||||
@@ -23,8 +22,8 @@ namespace Musify.Infrastructure.MassTransit.RoutingSlip.Builders
|
||||
ActivityNames.RemoveFile,
|
||||
EndpointHelper.BuildExecuteActivityUri(RemoveFileFromBucketActivity.ExecuteEndpointName),
|
||||
new RemoveFileFromBucketArguments(
|
||||
message.BucketName,
|
||||
message.KeyName));
|
||||
message.Bucket,
|
||||
message.Key));
|
||||
|
||||
return routingSlipBuilder;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user