SAIF.NetCore.PingableService overview¶
Documentation context: Packaged Component (NuGet)
SAIF.NetCore.PingableService adds a framework-standard, anonymous GET /Ping health route to any ASP.NET Core API. A request to /Ping pings every DI-registered IPingableService implementation and every MVC controller that implements IPingableService, all concurrently, and fails the whole request if any target fails. It depends only on the foundation package SAIF.NetCore.ServiceContracts and is consumed by SAIF.NetCore.ServiceExtensions (top layer) and, as one of the three documented implementation-to-implementation exceptions, by SAIF.NetCore.Services.Messaging.
Purpose¶
- Provide a single, consistent health-check endpoint (
GET /Ping) that any host can adopt with one line of MVC setup. - Let services and controllers participate in health reporting through a C# 8 default-interface-method mixin (
IPingableService), without requiring every implementer to write custom ping logic. - Surface target failures as a single HTTP 500 so monitoring systems have one signal for "this API or one of its dependencies is unhealthy."
Responsibilities¶
- Register pingable services under both their own service type and
IPingableServiceso a single DI registration call (AddPingable{Transient|Scoped|Singleton}) is enough to participate. - Discover pingable controllers by reflection over MVC application parts, with no per-controller startup code required.
- Run every ping concurrently, classify and flatten failures, and return a stable success/failure contract to the caller.
Key components¶
IPingableService: the mixin interface, with default implementations forPingAsyncorchestration andPing/IsThrowablePingError/OnPingFailure/OnPingSuccesshooks.PingableController: the[AllowAnonymous]GET /Pingendpoint that resolves and pings every target.IServiceCollectionExtensions:AddPingableTransient/AddPingableScoped/AddPingableSingletonregistration helpers.MvcBuilderExtensions.WithPingableController(): opt-in host wiring that routes the controller and registers controller discovery.ControllerRetriever: reflection-based discovery of pingable MVC controllers from snapshotted application parts.PingServiceException: the HTTP 500 exception type used to report any ping failure.
Related documentation¶
- Index
- Architecture
- Dependencies
- Operations and processes
- Business rules
- Security and authorization
- Service registration
- API reference
Sources¶
src/SAIF.NetCore.PingableService/SAIF.NetCore.PingableService/IPingableService.cssrc/SAIF.NetCore.PingableService/SAIF.NetCore.PingableService/Controllers/PingableController.cssrc/SAIF.NetCore.PingableService/SAIF.NetCore.PingableService/Extensions/MvcBuilderExtensions.cssrc/SAIF.NetCore.PingableService/README.mdArchitecture.md