-
Notifications
You must be signed in to change notification settings - Fork 9
Yurii bart feat add retryable policy 01 #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Add configurable retry logic and circuit breaker pattern using Polly library to improve SDK reliability when handling transient HTTP failures. Features: - Exponential backoff with jitter for retry attempts - Circuit breaker to prevent cascading failures - Configurable retry count, delays, and thresholds - Support for 429 rate limiting and transient 5xx errors - Event callbacks for monitoring (OnRetry, OnCircuitBreakerOpen) - Both sync and async operation support - Backward compatible (retry disabled by default)
Feat/add retryable policy
- Update Microsoft.Extensions.Logging.Abstractions to 8.0.2 in Route4MeSDKLibrary - Update Microsoft.Extensions.Logging to 8.0.1 in Route4MeSDKTest
…-retryable-policy-01' into yurii-bart-feat-add-retryable-policy-01
Gemini AI Code Risk & Compatibility AnalysisStatus: [OK] Analysis completed successfully Files analyzed:
Analysis Results[STARTUP] StartupProfiler.flush() called with 9 phases SummaryThe submitted code introduces resilience and fault-tolerance mechanisms (retry and circuit breaker patterns) into the HTTP client logic using the Polly library. This is a significant feature addition that improves the robustness of the SDK. While the implementation is generally good, there are potential risks related to synchronous-over-asynchronous programming patterns that could lead to deadlocks, and changes in exception handling that could affect existing clients. 1. Potential Backward Compatibility Risks
2. Performance Risks & Coding Standard Violations
// Problematic code in synchronous GET
var httpResponse = HttpResiliencePolicy.GetSyncPolicy()
.Execute(() =>
{
var task = httpClientHolder.HttpClient.GetAsync(uri.PathAndQuery);
task.Wait(); // <-- Potential deadlock
return task.Result;
});
// Problematic code in synchronous POST/PUT etc.
var response = HttpResiliencePolicy.GetSyncPolicy()
.Execute(() =>
{
// ...
task.Wait(); // <-- Potential deadlock
return task.Result;
});3. Other Improvement Suggestions
// Current implementation
resultResponse = new ResultResponse
{
Status = false,
Messages = new Dictionary<string, string[]>
{
{"RetryExhausted", new[] {
$"Request failed after {Route4MeConfig.RetryCount} retry attempts: {hre.Message}"
}}
}
};
// Suggested improvement
resultResponse = new ResultResponse
{
Status = false,
Messages = new Dictionary<string, string[]>
{
{"RetryExhausted", new[] {
$"Request failed after {Route4MeConfig.RetryCount} retry attempts. Last exception: {hre.Message}"
// Consider also logging hre.ToString() for full details if a logging framework is used
}}
}
};
|
No description provided.