Skip to content

Commit

Permalink
CON-1640-Integrate Polly
Browse files Browse the repository at this point in the history
  • Loading branch information
shomavg committed Apr 21, 2020
1 parent db6b13e commit 7f2071c
Showing 1 changed file with 2 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Threading.Tasks;
using MediatR;
using SFA.DAS.EmployerAccounts.Configuration;
using SFA.DAS.EmployerAccounts.Interfaces;
using SFA.DAS.HashingService;
using SFA.DAS.NLog.Logger;
@@ -15,20 +14,17 @@ public class GetReservationsRequestHandler : IAsyncRequestHandler<GetReservation
private readonly ILog _logger;
private readonly IReservationsService _service;
private readonly IHashingService _hashingService;
private readonly EmployerAccountsConfiguration _employerAccountsConfiguration;

public GetReservationsRequestHandler(
IValidator<GetReservationsRequest> validator,
ILog logger,
IReservationsService service,
IHashingService hashingService,
EmployerAccountsConfiguration employerAccountsConfiguration)
IHashingService hashingService)
{
_validator = validator;
_logger = logger;
_service = service;
_hashingService = hashingService;
_employerAccountsConfiguration = employerAccountsConfiguration;
}

public async Task<GetReservationsResponse> Handle(GetReservationsRequest message)
@@ -46,25 +42,11 @@ public async Task<GetReservationsResponse> Handle(GetReservationsRequest message

try
{
var task = _service.Get(accountId);
if (await Task.WhenAny(task, Task.Delay(_employerAccountsConfiguration.AddApprenticeCallToActionTimeout)) == task)
{
await task;
}
return new GetReservationsResponse
{
Reservations = task.Result
Reservations = await _service.Get(accountId)
};
}
catch (TimeoutException ex)
{
_logger.Error(ex, $"Failed to get Reservations for {message.HashedAccountId}");
return new GetReservationsResponse
{
HasFailed = true
};

}
catch (Exception ex)
{
_logger.Error(ex, $"Failed to get Reservations for {message.HashedAccountId}");

0 comments on commit 7f2071c

Please sign in to comment.