devops-lab4/src/CommunicationControl/DevOpsProject/DI/HttpClientsConfiguration.cs
dsokolovrudakov 21a6a22a9e Program.cs cleanup, HiveModel change, log level change
Clean up HiveMind Minimal API setup - move configuration to extenstion methods, same for CommunicationControl, move RequestSchema for Hive to HiveModel, make ComControl use it, set minimum log level for files to Information
2025-02-19 23:02:15 +02:00

21 lines
695 B
C#

using DevOpsProject.Shared.Clients;
using Polly;
using Polly.Extensions.Http;
namespace DevOpsProject.CommunicationControl.API.DI
{
public static class HttpClientsConfiguration
{
public static IServiceCollection AddHttpClientsConfiguration(this IServiceCollection serviceCollection)
{
var hiveRetryPolicy = HttpPolicyExtensions
.HandleTransientHttpError()
.WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)));
serviceCollection.AddHttpClient<CommunicationControlHttpClient>()
.AddPolicyHandler(hiveRetryPolicy);
return serviceCollection;
}
}
}