Files
2026-03-17 09:53:09 -05:00

37 lines
1.4 KiB
C#

using System.Threading;
using LCU.API.Internal.Operations.IncentiveApi.Configuration;
using LCU.Api.Internal.MaidBotLib.Models;
using LCU.Library.Internal.Exceptions;
using LCU.Library.Internal.IncentiveApiModels.Requests;
using MassTransit;
namespace LCU.API.Internal.Operations.IncentiveApi.Services.QueueServices
{
public class QueueAlliedGapMbpService : IQueueAlliedGapMbpService
{
private readonly ISendEndpoint _sendEndpoint;
public QueueAlliedGapMbpService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
{
_sendEndpoint = busControl.GetSendEndpoint(receiveEndpointConfigurations.GapMbpProcessEndpoint.ReceiveEndpointUri).Result;
}
public async Task QueueGapMbpProcess(AlliedGapMbpRequest request)
{
try
{
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
}
catch (Exception exception)
{
var message = "Failed to Queue Gap Mbp Process.";
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
.Fatal(exception, message);
throw new ServiceException(message);
}
}
}
}