RA.Utilities.Logging.Shared
· One min read
Version 10.0.0-rc.2
This release modernizes the RA.Utilities.Integrations package, providing a robust and repeatable pattern for managing external API integrations.
It centralizes configuration, simplifies registration, and improves resilience with built-in retry policies.
✨ New Features
-
Standardized Configuration:
- Centralizes HTTP client settings (Base URL, timeouts, headers) in
appsettings.jsonusing theHttpClientSettingsbase class.
- Centralizes HTTP client settings (Base URL, timeouts, headers) in
-
Simplified Registration:
- Introduced the
AddIntegrationHttpClient<TClient, TSettings>extension method to register a typedHttpClient, bind its configuration, and apply default policies with a single line of code.
- Introduced the
-
Built-in Resilience:
- Includes a default transient error handling policy (retry with exponential backoff) using Polly, improving the reliability of external API calls.
-
Promotes Best Practices:
- Encourages the use of typed
HttpClients viaIHttpClientFactory, which provides better compile-time safety, intellisense, and connection management.
- Encourages the use of typed
-
Updated Documentation:
- The
README.mdhas been updated to provide a clear, step-by-step guide for setting up a typed client, from configuration to implementation.
- The
🚀 Getting Started
Register your typed HTTP client in Program.cs:
var builder = WebApplication.CreateBuilder(args);
// Register the typed client for "MyApi" integration
builder.Services.AddIntegrationHttpClient<IMyApiClient, MyApiClient, MyApiSettings>(
builder.Configuration,
configSection: "Integrations:MyApi"
);
var app = builder.Build();