No1.OpenSearchCommons
1.1.0
dotnet add package No1.OpenSearchCommons --version 1.1.0
NuGet\Install-Package No1.OpenSearchCommons -Version 1.1.0
<PackageReference Include="No1.OpenSearchCommons" Version="1.1.0" />
<PackageVersion Include="No1.OpenSearchCommons" Version="1.1.0" />
<PackageReference Include="No1.OpenSearchCommons" />
paket add No1.OpenSearchCommons --version 1.1.0
#r "nuget: No1.OpenSearchCommons, 1.1.0"
#:package No1.OpenSearchCommons@1.1.0
#addin nuget:?package=No1.OpenSearchCommons&version=1.1.0
#tool nuget:?package=No1.OpenSearchCommons&version=1.1.0
No1.OpenSearchCommons
Tools and libraries required by .NET applications to use OpenSearch
Contents
This library has two important classes:
OpenSearchHealthCheckcan be added as health checker to asp.net health checks:
builder.Services
.AddHealthChecks()
.AddCheck<OpenSearchHealthCheck>("OpenSearch");
OpenSearchExtensionsclass has a helper method that registers specific http client for connecting to OpenSearch server. OpenSearch requires you to generate custom keys, certificates, pem files, ... to trust to clients.
After you created the keys, you can specify your client key and certificate files and also root certificate authority file in configuration file:
{
"OpenSearchConfig": {
"ClientCertificateFile": "/usr/share/opensearch/config/client.pem",
"ClientPrivateKeyFile": "/usr/share/opensearch/config/client-key.pem",
"RootCertificateAuthorityFile": "/usr/share/opensearch/config/root-ca.pem",
"HealthUrl": "https://[domain]:[port]/_cluster/health"
}
}
Then get service by name (OpenSearchExtensions.OpenSearchKey):
public class OpenSearchHealthCheck(IHttpClientFactory factory) : IHealthCheck
{
public HttpClient GetClient() {
return factory.CreateClient(OpenSearchExtensions.OpenSearchKey);
}
}
Above HttpClient provides client certificate to the OpenSearch server and also verifies that the server has valid certificates. This HttpClient has been used for OpenSearchHealthCheck, but can be used elsewhere too.
You have problem in configuring OpenSearch? then read my another repo Boots.OpenSearchBoot
How to use?
Add below dependency:
dotnet package add No1.OpenSearchCommons
Then add below line in the Program.cs before building app:
using No1.OpenSearchCommons;
//...
builder.RegisterOpenSearchCertificateSignedHttpClient();
For adding OpenSearch to Health, add below code too:
builder.Services
.AddHealthChecks()
.AddCheck<OpenSearchHealthCheck>("OpenSearch");
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No1.asp.NET.Commons (>= 1.1.1)
- OpenSearch.Net (>= 1.8.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.