Skip to content

Commit c7c5953

Browse files
committed
Document custom health check configuration options
Added examples and documentation for using StartWithHealthCheckAsync with custom health check configuration delegates. Updated API method lists and usage instructions to reflect new overloads supporting inline health check setup.
1 parent 1f03bd9 commit c7c5953

2 files changed

Lines changed: 41 additions & 2 deletions

File tree

.pages/app/api/page.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,9 +546,11 @@ const apiCategories = [
546546
'EnableHealthCheck(IPAddress, port)',
547547
'EnableHealthCheck(options)',
548548
'StartWithHealthCheckAsync(port, ct)',
549+
'StartWithHealthCheckAsync(port, configureHealthChecks, ct)',
549550
'StartWithHealthCheckAsync(hostname, port, ct)',
551+
'StartWithHealthCheckAsync(hostname, port, configureHealthChecks, ct)',
550552
'StartWithHealthCheckAsync(IPAddress, port, ct)',
551-
'StartWithHealthCheckAsync(options, ct)',
553+
'StartWithHealthCheckAsync(IPAddress, port, configureHealthChecks, ct)',
552554
'AddHealthCheck(healthCheckService, name, check)',
553555
'AddHealthCheck(healthCheckService, name, checkFunc)'
554556
],

src/Zetian.HealthCheck/README.MD

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,38 @@ await healthCheck.StartAsync();
5454
```csharp
5555
// Start both SMTP and health check together
5656
var healthCheck = await server.StartWithHealthCheckAsync(8080);
57+
58+
// Or with custom health checks configured inline
59+
await server.StartWithHealthCheckAsync(8080, healthService =>
60+
{
61+
// Add custom health checks
62+
healthService.AddHealthCheck("database", async (ct) =>
63+
{
64+
try
65+
{
66+
await CheckDatabaseAsync();
67+
return HealthCheckResult.Healthy("Database connected");
68+
}
69+
catch (Exception ex)
70+
{
71+
return HealthCheckResult.Unhealthy("Database unavailable", ex);
72+
}
73+
});
74+
75+
healthService.AddHealthCheck("redis", async (ct) =>
76+
{
77+
try
78+
{
79+
await CheckRedisAsync();
80+
return HealthCheckResult.Healthy("Redis connected");
81+
}
82+
catch (Exception ex)
83+
{
84+
// Redis is not critical, mark as degraded
85+
return HealthCheckResult.Degraded("Redis unavailable", ex);
86+
}
87+
});
88+
});
5789
```
5890

5991
## 🛠️ Advanced Configuration
@@ -383,11 +415,16 @@ curl -f http://localhost:8080/health/readyz
383415
| Method | Description |
384416
|--------|-------------|
385417
| `EnableHealthCheck(port)` | Enable health check on localhost |
386-
| `AddHealthCheck(name, checkFunc)` | Add custom health check |
418+
| `AddHealthCheck(name, checkFunc)` | Add custom health check to service |
387419
| `StartWithHealthCheckAsync(port)` | Start server and health check |
388420
| `EnableHealthCheck(hostname, port)` | Enable on specific hostname |
389421
| `EnableHealthCheck(IPAddress, port)` | Enable on specific IP |
390422
| `EnableHealthCheck(options, healthOptions)` | Advanced configuration |
423+
| `StartWithHealthCheckAsync(hostname, port)` | Start on specific hostname |
424+
| `StartWithHealthCheckAsync(IPAddress, port)` | Start on specific IP |
425+
| `StartWithHealthCheckAsync(port, configureHealthChecks)` | Start server with custom health checks |
426+
| `StartWithHealthCheckAsync(hostname, port, configureHealthChecks)` | Start on hostname with custom checks |
427+
| `StartWithHealthCheckAsync(IPAddress, port, configureHealthChecks)` | Start on IP with custom checks |
391428

392429
### Health Check Results
393430

0 commit comments

Comments
 (0)