Esempio n. 1
0
        public async Task <SearchStatusResponse> GetStatusAsync(SearchStatusOptions options, Assembly assemblyForMetadata)
        {
            var response = new SearchStatusResponse
            {
                Success = true,
            };

            response.Duration = await Measure.DurationAsync(() => PopulateResponseAsync(options, assemblyForMetadata, response));

            _telemetryService.TrackGetSearchServiceStatus(options, response.Success, response.Duration.Value);

            return(response);
        }
Esempio n. 2
0
 private async Task TryAsync(
     Func <Task> getAsync,
     SearchStatusResponse response,
     string operation)
 {
     try
     {
         await Task.Yield();
         await getAsync();
     }
     catch (Exception ex)
     {
         response.Success = false;
         _logger.LogError(0, ex, "When getting the search status, {Operation} failed.", operation);
     }
 }
Esempio n. 3
0
 private async Task PopulateResponseAsync(SearchStatusOptions options, Assembly assembly, SearchStatusResponse response)
 {
     await Task.WhenAll(
         TryAsync(
             async() =>
     {
         if (options.HasFlag(SearchStatusOptions.AzureSearch))
         {
             response.SearchIndex = await GetIndexStatusAsync(_searchIndex);
         }
     },
             response,
             "warming the search index"),
         TryAsync(
             async() =>
     {
         if (options.HasFlag(SearchStatusOptions.AzureSearch))
         {
             response.HijackIndex = await GetIndexStatusAsync(_hijackIndex);
         }
     },
             response,
             "warming the hijack index"),
         TryAsync(
             async() =>
     {
         if (options.HasFlag(SearchStatusOptions.AuxiliaryFiles))
         {
             response.AuxiliaryFiles = await GetAuxiliaryFilesMetadataAsync();
         }
     },
             response,
             "getting cached auxiliary data"),
         TryAsync(
             async() =>
     {
         if (options.HasFlag(SearchStatusOptions.Server))
         {
             response.Server = await GetServerStatusAsync(assembly);
         }
     },
             response,
             "getting server information"));
 }