This package contains helpers and common funcitonality that can be employed when using ElasticSearch.
There is a ConfigureElasticSearch()
extension method provided to facilitate setting up an application to use AWS DynamoDb.
This will register an ElasticClient
instance configured with a SingleNodeConnectionPool
.
The domain url is retrieved from the configuration using the key supplied.
If no value is found in the configuration then a default of http://localhost:9200 is used.
Alternatively a custom default can be supplied.
By calling it in the application startup, the following interfaces will be configured in the DI container:
IElasticClient
IWildCardAppenderAndPrepender
using Hackney.Core.ElasticSearch;
namespace SomeApi
{
public class Startup
{
...
public void ConfigureServices(IServiceCollection services)
{
...
services.ConfigureElasticSearch(Configuration, "ELASTICSEARCH_DOMAIN_URL");
...
}
}
}
There is an ElasticSearchHealthCheck
class implemented that uses the
Microsoft Health check framework.
The check verifies that the ElasticSearch instance configured is accessible by attempting to ping it .
using Hackney.Core.ElasticSearch.HealthCheck;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
namespace SomeApi
{
public class Startup
{
...
public void ConfigureServices(IServiceCollection services)
{
...
services.AddElasticSearchHealthCheck();
...
}
public static void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
...
app.UseEndpoints(endpoints =>
{
endpoints.MapHealthChecks("/health");
});
...
}
}
}