33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using MassTransit;
|
|
using LCU.Library.Internal.LoanRateModels.Requests.LoadTestRequest;
|
|
using LCU.Api.Internal.MaidBotLib.Models;
|
|
using LCU.API.Internal.LoanRate.Configurations;
|
|
namespace LCU.API.Internal.LoanRate.Services.QueueServices;
|
|
|
|
public class QueueLoadTestProcessRateService : IQueueLoadTestProcessRateService
|
|
{
|
|
private readonly ISendEndpoint _sendEndpoint;
|
|
|
|
public QueueLoadTestProcessRateService(IBusControl busControl,
|
|
ReceiveEndpointConfigurations receiveEndpointConfigurations)
|
|
{
|
|
_sendEndpoint = busControl.GetSendEndpoint(receiveEndpointConfigurations.LoadTestProcessRateReceiveEndpoint.ReceiveEndpointUri).Result;
|
|
}
|
|
|
|
public async Task QueueLoadTestProcessRateRequest(LoadTestProcessRateRequest request)
|
|
{
|
|
try
|
|
{
|
|
var cancellationTokenSource = new CancellationTokenSource(TimeSpan.FromSeconds(30));
|
|
await _sendEndpoint.Send(request, cancellationTokenSource.Token);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Log.ForContext(Enum.GetName(typeof(PropertyEnum), PropertyEnum.Group),
|
|
Enum.GetName(typeof(GroupEnum), GroupEnum.ITDevelopment))
|
|
.Fatal(exception, "Failed to Queue Load Test Process Rate Request.");
|
|
throw new ServiceException("Failed to Queue Load Test Process Rate Request.");
|
|
}
|
|
}
|
|
}
|