DatabaseConnectionInspector 3.1.0
dotnet add package DatabaseConnectionInspector --version 3.1.0
NuGet\Install-Package DatabaseConnectionInspector -Version 3.1.0
<PackageReference Include="DatabaseConnectionInspector" Version="3.1.0" />
<PackageVersion Include="DatabaseConnectionInspector" Version="3.1.0" />
<PackageReference Include="DatabaseConnectionInspector" />
paket add DatabaseConnectionInspector --version 3.1.0
#r "nuget: DatabaseConnectionInspector, 3.1.0"
#:package DatabaseConnectionInspector@3.1.0
#addin nuget:?package=DatabaseConnectionInspector&version=3.1.0
#tool nuget:?package=DatabaseConnectionInspector&version=3.1.0
Connection Inspector
Library for inspect database connections and prevent requests to its until establish conneciton (for Asp.Net apps)
Library Purpose
Library purpose is to try to help achieve max app reliability by handling database connection state. That is if your database server was down app would continue it's work
How to use library
Here the example of how you can use this library in your Asp.Net project (from Example project)
Common use
In your Program.cs
or Startup.cs
file:
app.UseDbConnectionInspector(new ConnectionOptions()
{
new ConnectionChecker(new NpgsqlConnection(connString)),
new ConnectionChecker(new MySqlConnection(connString))
});
You can provide key
parameter
app.UseDbConnectionInspector(new ConnectionOptions()
{
new ConnectionChecker(new NpgsqlConnection(connString), "chekerOne"),
new ConnectionChecker(new MySqlConnection(connString), "checkerTwo")
});
In your controller:
[RequireDbInspection]
[HttpGet("/get")]
public IActionResult Get()
{
return Ok(_dbContext.Models.ToList());
}
If you want check only one specific connection:
[RequireDbInspection("checkerKey")]
[HttpGet("/get")]
public IActionResult Get()
{
return Ok(_dbContext.Models.ToList());
}
Without connections
In this case checking will be always succeed whether inspection is required or not
app.UseDbConnectionInspector(new ConnectionOptions());
Specify action
You may specify what action would be invoked if connection failed
app.UseDbConnectionInspector(new ConnectionOptions()
{
new ConnectionChecker(new NpgsqlConnection(connString))
}, context => context.Response.StatusCode = (int)HttpStatusCode.BadRequest);
Features list v1.0
- Embedding inspector to request pipeline
- Support PostgreSQL
Features list v2.0
- Specify action that would be invoke if connection failed
- Support for all connection providers who provide a class that implements
IDbConnection
interface - Logger for inspector
Note
Architecture has been redesigned, so a new version is not compatible with old one
Features list v3.0
- Attribute based inspection
Starting with this version connection inspection would be called only for controller methods marked by special attributeRequireDbInspection
Features list v3.0.1
- Added additional parameter for
IConnectionChecker
-key
for identification each checker - Added ability provide
key
parameter inRequireDbInspection
attribute constructor - Change inspection logic
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net6.0
- Microsoft.AspNetCore.Http.Abstractions (>= 2.2.0)
- Microsoft.AspNetCore.Routing.Abstractions (>= 2.2.0)
- Microsoft.Extensions.DependencyInjection (>= 6.0.1)
- Microsoft.Extensions.Logging.Abstractions (>= 6.0.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.