Cross.WebHost.AvailabilityCheck
1.0.0
dotnet add package Cross.WebHost.AvailabilityCheck --version 1.0.0
NuGet\Install-Package Cross.WebHost.AvailabilityCheck -Version 1.0.0
<PackageReference Include="Cross.WebHost.AvailabilityCheck" Version="1.0.0" />
<PackageVersion Include="Cross.WebHost.AvailabilityCheck" Version="1.0.0" />
<PackageReference Include="Cross.WebHost.AvailabilityCheck" />
paket add Cross.WebHost.AvailabilityCheck --version 1.0.0
#r "nuget: Cross.WebHost.AvailabilityCheck, 1.0.0"
#:package Cross.WebHost.AvailabilityCheck@1.0.0
#addin nuget:?package=Cross.WebHost.AvailabilityCheck&version=1.0.0
#tool nuget:?package=Cross.WebHost.AvailabilityCheck&version=1.0.0
Cross.WebHost.AvailabilityCheck
A lightweight .NET library for validating microservice dependencies during application startup. The library ensures that all required services are available before the main application begins its operation.
Features
- Asynchronous health checks for HTTP/HTTPS endpoints
- Configurable retry policies with customizable timeouts
- Support for custom port configurations
- Built-in logging for dependency validation process
- Cancellation support for health check operations
Purpose
Designed to prevent application startup failures due to unavailable dependencies by implementing a readiness probe pattern for microservice environments.
Install with nuget.org:
https://www.nuget.org/packages/Cross.WebHost.AvailabilityCheck
Installation
Install via NuGet Package Manager:
dotnet add package Cross.WebHost.AvailabilityCheck
Or via Package Manager Console:
Install-Package Cross.WebHost.AvailabilityCheck
Usage
Basic Configuration
Add service availability check in your Program.cs
or Startup.cs
:
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// ...
var app = builder.Build();
// ...
// Configure service hosts to check
var hostsToCheck = new[]
{
"CheckServiceUrls:AuthService",
"CheckServiceUrls:UserService"
};
// Add availability check
AvailabilityHostsConfiguration.ConfigureAvailabilityHosts(
hostsToCheck,
builder.Configuration,
app.Logger,
timeoutInMs: 1500, // (Optional) Default: 1000 ms.
maxAttempts: 100 // (Optional) Default: 50 times.
);
app.Run();
}
}
Configuration in appsettings.json
{
"CheckServiceUrls": {
"AuthService": "https://auth-service:5001",
"UserService": "http://user-service:5002"
}
}
Supported URL Formats
The library supports various URL formats:
- HTTP URLs:
http://service-name:80
- HTTPS URLs:
https://service-name:443
- HTTP Default ports:
http://service-name
(assumes port 80) - HTTPS Default ports:
http://service-name
(assumes port 443) - Custom ports:
service-name:5000
- IP addresses:
192.168.1.100:5000
Logging
The library uses standard .NET logging mechanisms. Configure logging level in your appsettings.json:
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Cross.WebHost.AvailabilityCheck": "Debug"
}
}
}
Issues and Pull Request
Contribution is welcomed. If you would like to provide a PR please add some testing.
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Roadmap
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 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. |
-
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.Configuration.Binder (>= 8.0.2)
- Microsoft.Extensions.Logging (>= 8.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 |
---|---|---|
1.0.0 | 134 | 6/24/2025 |
Initial version.