Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/joncloud/vitality-net

Provides component status evaluation to integrate with monitoring services
https://github.com/joncloud/vitality-net

asp-net-core availability azure check component entity-framework-core health monitor mvc status storage-account

Last synced: about 1 month ago
JSON representation

Provides component status evaluation to integrate with monitoring services

Awesome Lists containing this project

README

        

# Vitality.NET
[![Travis](https://img.shields.io/travis/joncloud/vitality-net.svg)](https://travis-ci.org/joncloud/vitality-net/)
[![NuGet](https://img.shields.io/nuget/v/Vitality.svg)](https://www.nuget.org/packages/Vitality/)

vitality.net

## Description
Vitality.NET provides component status evaluation to integrate with monitoring services.

## Licensing
Released under the MIT License. See the [LICENSE][] file for further details.

[license]: LICENSE.md

## Installation
In the Package Manager Console execute

```powershell
Install-Package Vitality
```

Or update `*.csproj` to include a dependency on

```xml

```

## Usage
Sample authorization for details:
```csharp
class Startup {
public void ConfigureServices(IServiceCollection services) =>
services.AddVitality(options => options.AuthorizeDetails = ctx => ctx.User.IsInRole("Admin"));
}
```

Sample integration with Sqlite Database:
```csharp
class Startup {
// ...

public void ConfigureServices(IServiceCollection services) =>
services.AddVitality(options => options.AddDbConnectionEvaluator("SqliteDatabase", () => new SqliteConnection(), "Data Source=:memory:;"));

public void Configure(IApplicationBuilder app, IHostingEnvironment env) =>
app.UseVitality().UseMvc();
}
```

Sample output for `/vitality` results in
```json
{
"sqliteDatabase": "Up"
}
```

Test results can be cached by using the appropriate overload:
```csharp
services.AddVitality(options => options.AddDbConnectionEvaluator("SqliteDatabase", () => new SqliteConnection(), "Data Source=:memory:;"), TimeSpan.FromMinutes(5));
```

Test an Entity Framework DbContext (include Vitality.EntityFrameworkCore):
```csharp
// Simply make sure the database connection is correct.
services.AddVitality(options => options.AddDbContextEvaluator("ApplicationDbContext"));

// Check something on the context for verification.
services.AddVitality(options => options.AddDbContextEvaluator("ApplicationDbContext", ctx => ctx.CriticalTableMustHaveRows.AnyAsync()));
```

For additional usage see [Tests][].

[Tests]: tests/Vitality.Tests