public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { try { var url = $"{_options.Uri}/{_options.Core}"; if (!_connections.TryGetValue(url, out SolrConnection solrConnection)) { solrConnection = new SolrConnection(url); solrConnection.Timeout = _options.Timeout; if (!_connections.TryAdd(url, solrConnection)) { solrConnection = _connections[url]; } } var server = new SolrBasicServer <string>(solrConnection, null, null, null, null, null, null, null); var result = await server.PingAsync(); var isSuccess = result.Status == 0; return(isSuccess ? HealthCheckResult.Healthy() : new HealthCheckResult(context.Registration.FailureStatus)); } catch (Exception ex) { return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex)); } }
public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default) { try { var url = $"{_options.Uri}/{_options.Core}"; if (!_connections.TryGetValue(url, out SolrConnection solrConnection)) { solrConnection = new SolrConnection(url); solrConnection.Timeout = (int)_options.Timeout.TotalMilliseconds; if (!_connections.TryAdd(url, solrConnection)) { solrConnection = _connections[url]; } } var server = new SolrBasicServer <string>( solrConnection, queryExecuter: null, documentSerializer: null, schemaParser: null, headerParser: null, querySerializer: null, dihStatusParser: null, extractResponseParser: null); var result = await server.PingAsync(); var isSuccess = result.Status == 0; return(isSuccess ? HealthCheckResult.Healthy() : new HealthCheckResult(context.Registration.FailureStatus)); } catch (Exception ex) { return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex)); } }