feat: add healthcheck for databases
This commit is contained in:
parent
428c2dc3ba
commit
98ee3c389c
@ -86,4 +86,15 @@ public static class DependencyInjection
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public static IHealthChecksBuilder AddDatabaseHealthCheck(this IHealthChecksBuilder healthChecksBuilder, DatabaseProvider dbProvider, string connection)
|
||||
{
|
||||
return dbProvider switch
|
||||
{
|
||||
DatabaseProvider.Mysql => healthChecksBuilder.AddMySql(connection, name: "MySql"),
|
||||
DatabaseProvider.Sqlite => healthChecksBuilder.AddSqlite(connection, name: "Sqlite"),
|
||||
DatabaseProvider.Postgresql => healthChecksBuilder.AddNpgSql(connection, name: "PostgreSQL"),
|
||||
_ => throw new ArgumentException("Unsupported database provider", Enum.GetName(dbProvider))
|
||||
};
|
||||
}
|
||||
}
|
@ -5,16 +5,20 @@
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Company>Winsomnia</Company>
|
||||
<Version>1.0.0</Version>
|
||||
<AssemblyVersion>1.0.3.0</AssemblyVersion>
|
||||
<FileVersion>1.0.3.0</FileVersion>
|
||||
<Version>1.0.1</Version>
|
||||
<AssemblyVersion>1.0.3.1</AssemblyVersion>
|
||||
<FileVersion>1.0.3.1</FileVersion>
|
||||
<AssemblyName>Mirea.Api.DataAccess.Persistence</AssemblyName>
|
||||
<RootNamespace>$(AssemblyName)</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AspNetCore.HealthChecks.MySql" Version="8.0.1" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.NpgSql" Version="8.0.2" />
|
||||
<PackageReference Include="AspNetCore.HealthChecks.Sqlite" Version="8.1.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
|
||||
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="8.0.10" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
|
||||
</ItemGroup>
|
||||
|
Loading…
Reference in New Issue
Block a user