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 QueuePayoutIncentiveService : IQueuePayoutIncentiveService { private readonly ISendEndpoint _sendEndpoint; public QueuePayoutIncentiveService(IBusControl busControl, ReceiveEndpointConfigurations receiveEndpointConfigurations) { _sendEndpoint = busControl.GetSendEndpoint(receiveEndpointConfigurations.PayoutIncentiveProcessEndpoint.ReceiveEndpointUri).Result; } public async Task QueuePayoutIncentiveProcess(PayoutIncentiveRequest request) { try { var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30)); await _sendEndpoint.Send(request, cancellationTokenSource.Token); } catch (Exception exception) { var message = "Failed to Queue Payout Incentive Process."; Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group), Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment)) .Fatal(exception, message); throw new ServiceException(message); } } } }