Quilt4Net.Toolkit.Api
0.0.26
See the version list below for details.
dotnet add package Quilt4Net.Toolkit.Api --version 0.0.26
NuGet\Install-Package Quilt4Net.Toolkit.Api -Version 0.0.26
<PackageReference Include="Quilt4Net.Toolkit.Api" Version="0.0.26" />
paket add Quilt4Net.Toolkit.Api --version 0.0.26
#r "nuget: Quilt4Net.Toolkit.Api, 0.0.26"
// Install Quilt4Net.Toolkit.Api as a Cake Addin #addin nuget:?package=Quilt4Net.Toolkit.Api&version=0.0.26 // Install Quilt4Net.Toolkit.Api as a Cake Tool #tool nuget:?package=Quilt4Net.Toolkit.Api&version=0.0.26
Quilt4Net Toolkit Api
Add configurable support for Health, Liveness, Readyness, Version and Metrics in .NET Web Applications.
Get started
After having installed the nuget package. Register AddQuilt4NetApi as a service and use it in the app.
var builder = WebApplication.CreateBuilder(args);
...
builder.AddQuilt4NetApi();
var app = builder.Build();
...
app.UseRouting();
...
app.UseQuilt4NetApi();
app.Run();
You have to call AddQuilt4NetApi
in any order on the builder (or builder.Services).
On the app you have to call UseRouting
before UseQuilt4NetApi
.
Register service check
This is a basic way of adding a service check. This check will be performed when calling Health, Ready or Dependencies.
builder.AddQuilt4NetApi(o =>
{
o.AddComponent(new Component
{
Name = "some-service",
Essential = true,
CheckAsync = async _ =>
{
await Task.Delay(TimeSpan.FromSeconds(1));
return new CheckResult { Success = true };
}
});
});
Configuration options
Configuration can be configured by code. This will override any other configuration.
builder.AddQuilt4NetApi(o =>
{
o.ShowInSwagger = false;
o.FailReadyWhenDegraded = true;
});
Configuration in appsettings.json.
{
"Quilt4Net": {
"ShowInSwagger": false,
"FailReadyWhenDegraded" : true,
}
}
For values without configuration default values are used.
- ShowInSwagger: Turns on visibility in swagger.
- FailReadyWhenDegraded: When calling Ready and the service is Degraded it sill by default return 200. If this is set to true, the response will be 503 for degraded components.
Endpoints
Use the endpoint in different scenarios.
Health
~/api/Health/health
Use this by ping-services to check that everything works as intended. It can also be used for smoke tests after release to assure that the service is working.
Liveness
~/api/Health/live
Use this endpoint to check if a new instance sould be started. Commonly used in kubernetes or Azure to make sure the correct number of pods or machines are active.
Readyness
~/api/Health/ready
Use this endpoint to check if the instance is ready to perform work.
Troubleshooting
Error at startup with the message:
Unhandled exception. System.InvalidOperationException: EndpointRoutingMiddleware matches endpoints setup by EndpointMiddleware and so must be added to the request execution pipeline before EndpointMiddleware. Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseRouting' inside the call to 'Configure(...)' in the application startup code.
The solution is to add app.UseRouting();
before app.UseQuilt4NetApi();
in Program.cs.
Planned
- IP-Address lookup
- Authentication for endpoints (Use project auth or API-Key for different methods.)
- Feature to check if background services are running or if they have crashed.
- Monitor service that can be implemented so that components does not have to be added with 'AddComponent' in 'AddQuilt4NetApi'.
- Possible to create custom implementation of services
Support for API health, liveness, readiness, startup, metrics, version and dependencies.
Read more on the project site.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. 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 is compatible. |
-
net8.0
- Quilt4Net.Toolkit (>= 0.0.26)
- Swashbuckle.AspNetCore.SwaggerGen (>= 7.1.0)
- System.Management (>= 9.0.0)
-
net9.0
- Quilt4Net.Toolkit (>= 0.0.26)
- Swashbuckle.AspNetCore.SwaggerGen (>= 7.1.0)
- System.Management (>= 9.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.0.31 | 77 | 12/15/2024 |
0.0.30 | 123 | 12/9/2024 |
0.0.26 | 115 | 12/8/2024 |
0.0.24 | 85 | 12/4/2024 |
0.0.23 | 112 | 11/28/2024 |
0.0.22 | 100 | 11/28/2024 |
0.0.21 | 91 | 11/27/2024 |
0.0.20 | 87 | 11/27/2024 |
0.0.19 | 129 | 11/26/2024 |
0.0.18 | 92 | 11/23/2024 |
0.0.17 | 83 | 11/21/2024 |
0.0.14 | 83 | 11/18/2024 |
0.0.12 | 101 | 11/18/2024 |
0.0.10 | 103 | 11/17/2024 |
0.0.7 | 78 | 11/17/2024 |