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); }
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); } }
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")); }