public async Task <ConferenceDetailsResponse> GetConferenceDetailsByHearingIdWithRetry(Guid hearingId, string errorMessage)
        {
            try
            {
                var details = await _pollyRetryService.WaitAndRetryAsync <VideoApiException, ConferenceDetailsResponse>
                              (
                    6, _ => TimeSpan.FromSeconds(8),
                    retryAttempt =>
                    _logger.LogWarning(
                        "Failed to retrieve conference details from the VideoAPi for hearingId {Hearing}. Retrying attempt {RetryAttempt}", hearingId, retryAttempt),
                    videoApiResponseObject => !videoApiResponseObject.HasValidMeetingRoom(),
                    () => _videoApiClient.GetConferenceByHearingRefIdAsync(hearingId, false)
                              );

                return(details);
            }
            catch (VideoApiException ex)
            {
                _logger.LogError(ex, $"{errorMessage}: {ex.Message}");
            }

            return(new ConferenceDetailsResponse());
        }
Exemple #2
0
        public async Task <IActionResult> GetConferenceByHearingRefId(Guid hearingRefId)
        {
            _logger.LogDebug("GetConferenceByHearingRefId {hearingRefId}", hearingRefId);

            try
            {
                var response = await _videoApiClient.GetConferenceByHearingRefIdAsync(hearingRefId, false);

                return(Ok(response));
            }
            catch (VideoApiException e)
            {
                return(StatusCode(e.StatusCode, e.Response));
            }
        }
        public async Task <ConferenceDetailsResponse> GetConferenceByHearingIdPolling(Guid hearingRefId)
        {
            // 4 retries ^2 will execute after 2 seconds, then 4, 8, then finally 16 (30 seconds in total)
            const int RETRIES = 4;

            var policy = Policy
                         .Handle <VideoApiException>()
                         .Or <Exception>()
                         .WaitAndRetryAsync(RETRIES, retryAttempt =>
                                            TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));

            try
            {
                var result = await policy.ExecuteAsync(() => _videoApiClient.GetConferenceByHearingRefIdAsync(hearingRefId, false));

                return(result);
            }
            catch (Exception e)
            {
                _logger.LogError(e, "Encountered error '{message}' after {timeout} seconds whilst polling for conference by hearing ref id {hearingRefId}.", e.Message, RETRIES ^ 2, hearingRefId);
                throw;
            }
        }
Exemple #4
0
 public Task <ConferenceDetailsResponse> GetConferenceByHearingRefId(Guid hearingRefId, bool includeClosed = false)
 {
     _logger.LogInformation("Getting conference by hearing ref id {HearingId}", hearingRefId);
     return(_apiClient.GetConferenceByHearingRefIdAsync(hearingRefId, includeClosed));
 }