|
| 1 | +# NetEvolve.HealthChecks.CouchDb |
| 2 | + |
| 3 | +[](https://www.nuget.org/packages/NetEvolve.HealthChecks.CouchDb/) |
| 4 | +[](https://www.nuget.org/packages/NetEvolve.HealthChecks.CouchDb/) |
| 5 | + |
| 6 | +This package provides a health check for CouchDb databases, based on the [MyCouch](https://www.nuget.org/packages/MyCouch/) package. The main purpose is to check if the database is available and if the database is online. |
| 7 | + |
| 8 | +:bulb: This package is available for .NET 8.0 and later. |
| 9 | + |
| 10 | +## Installation |
| 11 | +To use this package, you need to add the package to your project. You can do this by using the NuGet package manager or by using the dotnet CLI. |
| 12 | +```powershell |
| 13 | +dotnet add package NetEvolve.HealthChecks.CouchDb |
| 14 | +``` |
| 15 | + |
| 16 | +## Health Check - CouchDb Liveness |
| 17 | +The health check is a liveness check. It checks if the CouchDb Server is available and if the database is online. |
| 18 | +If the query needs longer than the configured timeout, the health check will return `Degraded`. |
| 19 | +If the query fails, for whatever reason, the health check will return `Unhealthy`. |
| 20 | + |
| 21 | +### Usage |
| 22 | +After adding the package, you need to import the namespace and add the health check to the health check builder. |
| 23 | +```csharp |
| 24 | +using NetEvolve.HealthChecks.CouchDb; |
| 25 | +``` |
| 26 | +Therefore, you can use two different approaches. In both approaches you have to provide a name for the health check. |
| 27 | + |
| 28 | +### Parameters |
| 29 | +- `name`: The name of the health check. The name is used to identify the configuration object. It is required and must be unique within the application. |
| 30 | +- `options`: The configuration options for the health check. If you don't provide any options, the health check will use the configuration based approach. |
| 31 | +- `tags`: The tags for the health check. The tags `couchdb` and `nosql` are always used as default and combined with the user input. You can provide additional tags to group or filter the health checks. |
| 32 | + |
| 33 | +### Variant 1: Configuration based |
| 34 | +The first one is to use the configuration based approach. This approach is recommended if you have multiple CouchDb instances to check. |
| 35 | +```csharp |
| 36 | +var builder = services.AddHealthChecks(); |
| 37 | + |
| 38 | +builder.AddCouchDb("<name>"); |
| 39 | +``` |
| 40 | + |
| 41 | +The configuration looks like this: |
| 42 | +```json |
| 43 | +{ |
| 44 | + ..., // other configuration |
| 45 | + "HealthChecks": { |
| 46 | + "CouchDb": { |
| 47 | + "<name>": { |
| 48 | + "ConnectionString": "<connection string>", |
| 49 | + "Timeout": "<timeout>" // optional, default is 100 milliseconds |
| 50 | + } |
| 51 | + } |
| 52 | + } |
| 53 | +} |
| 54 | +``` |
| 55 | + |
| 56 | +### Variant 2: Builder based |
| 57 | +The second approach is to use the builder based approach. This approach is recommended if you only have one NoSQL Server instance to check or dynamic programmatic values. |
| 58 | +```csharp |
| 59 | +var builder = services.AddHealthChecks(); |
| 60 | + |
| 61 | +builder.AddCouchDb("<name>", options => |
| 62 | +{ |
| 63 | + options.ConnectionString = "<connection string>"; |
| 64 | + options.Timeout = "<timeout>"; // optional, default is 100 milliseconds |
| 65 | +}); |
| 66 | +``` |
| 67 | + |
| 68 | +### :bulb: You can always provide tags to all health checks, for grouping or filtering. |
| 69 | + |
| 70 | +```csharp |
| 71 | +var builder = services.AddHealthChecks(); |
| 72 | + |
| 73 | +builder.AddCouchDb("<name>", options => ..., "CouchDb", "database"); |
| 74 | +``` |
| 75 | + |
| 76 | +## License |
| 77 | + |
| 78 | +This project is licensed under the MIT License - see the [LICENSE](https://raw.githubusercontent.com/dailydevops/healthchecks/refs/heads/main/LICENSE) file for details. |
0 commit comments