This commit is contained in:
Zeeshaun
2026-04-27 10:50:07 -05:00
parent 8b528fa00b
commit b5edd55420
141 changed files with 9602 additions and 0 deletions
@@ -0,0 +1,43 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using MassTransit;
using LCU.Api.Internal.FileOperations.Services;
using LCU.Library.Internal.Exceptions;
using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Library.Internal.FileOperationsModels.Models;
namespace LCU.Api.Internal.FileOperations.Consumers;
public class FileOperationsConsumer : IConsumer<QueueRequest>
{
private readonly IServiceScopeFactory _scopeFactory;
public FileOperationsConsumer(IServiceScopeFactory scopeFactory)
{
_scopeFactory = scopeFactory;
}
public async Task Consume(ConsumeContext<QueueRequest> context)
{
try
{
using var scope = _scopeFactory.CreateScope();
await Task.Run(async () => await scope.ServiceProvider.GetRequiredService<IFileOperationsService>().HandleFileOperationsRequest(context.Message));
}
catch (ServiceException)
{
//Masstransit handles the exception. https://masstransit-project.com/usage/exceptions.html#retry
throw;
}
catch (Exception exception)
{
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
.Fatal(exception, $"Unexpected Failure in FileOperations Api");
//Masstransit handles the exception. https://masstransit-project.com/usage/exceptions.html#retry
throw;
}
}
}