58 lines
1.4 KiB
C#
Raw Normal View History

2025-01-16 11:31:50 +01:00
namespace WebUtils
2023-04-12 16:06:04 +02:00
{
2025-01-16 11:31:50 +01:00
public interface IWebCallTimeSet
2023-04-12 16:06:04 +02:00
{
/// <summary>
/// Timeout for a single HTTP call.
/// </summary>
2023-04-12 16:06:04 +02:00
TimeSpan HttpCallTimeout();
/// <summary>
/// Maximum total time to attempt to make a successful HTTP call to a service.
/// When HTTP calls time out during this timespan, retries will be made.
/// </summary>
TimeSpan HttpRetryTimeout();
/// <summary>
/// After a failed HTTP call, wait this long before trying again.
/// </summary>
TimeSpan HttpCallRetryDelay();
2023-04-12 16:06:04 +02:00
}
2025-01-16 11:31:50 +01:00
public class DefaultWebCallTimeSet : IWebCallTimeSet
2023-04-12 16:06:04 +02:00
{
public TimeSpan HttpCallTimeout()
{
2024-07-02 10:44:15 +02:00
return TimeSpan.FromMinutes(2);
2023-04-12 16:06:04 +02:00
}
public TimeSpan HttpRetryTimeout()
2023-04-12 16:06:04 +02:00
{
2024-07-02 10:44:15 +02:00
return TimeSpan.FromMinutes(5);
2023-04-12 16:06:04 +02:00
}
public TimeSpan HttpCallRetryDelay()
2023-04-12 16:06:04 +02:00
{
2023-06-08 13:23:26 +02:00
return TimeSpan.FromSeconds(1);
2023-04-12 16:06:04 +02:00
}
}
2025-01-16 11:31:50 +01:00
public class LongWebCallTimeSet : IWebCallTimeSet
{
public TimeSpan HttpCallTimeout()
{
return TimeSpan.FromMinutes(30);
}
public TimeSpan HttpRetryTimeout()
{
return TimeSpan.FromHours(2.2);
}
public TimeSpan HttpCallRetryDelay()
{
return TimeSpan.FromSeconds(20);
}
}
2023-04-12 16:06:04 +02:00
}