37 lines
1.5 KiB
C#
37 lines
1.5 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 QueueGoalDispersalService : IQueueGoalDispersalService
|
|
{
|
|
private readonly ISendEndpoint _sendEndpoint;
|
|
|
|
public QueueGoalDispersalService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
|
{
|
|
_sendEndpoint = busControl.GetSendEndpoint(receiveEndpointConfigurations.GoalDispersalProcessEndpoint.ReceiveEndpointUri).Result;
|
|
}
|
|
|
|
public async Task QueueGoalDispersalProcess(GoalDispersalRequest request)
|
|
{
|
|
try
|
|
{
|
|
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
|
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
var message = "Failed to Queue Goal Dispersal Process.";
|
|
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
|
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
|
.Fatal(exception, message);
|
|
throw new ServiceException(message);
|
|
}
|
|
}
|
|
}
|
|
}
|