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
|
|
|
|
{
|
2024-05-02 08:41:20 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Timeout for a single HTTP call.
|
|
|
|
|
|
/// </summary>
|
2023-04-12 16:06:04 +02:00
|
|
|
|
TimeSpan HttpCallTimeout();
|
2024-05-02 08:41:20 +02:00
|
|
|
|
|
|
|
|
|
|
/// <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>
|
2023-05-10 09:55:36 +02:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-02 08:41:20 +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
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-10 09:55:36 +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
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-10-10 18:08:21 +02:00
|
|
|
|
|
2025-01-16 11:31:50 +01:00
|
|
|
|
public class LongWebCallTimeSet : IWebCallTimeSet
|
2023-10-10 18:08:21 +02:00
|
|
|
|
{
|
|
|
|
|
|
public TimeSpan HttpCallTimeout()
|
|
|
|
|
|
{
|
2024-05-02 08:41:20 +02:00
|
|
|
|
return TimeSpan.FromMinutes(30);
|
2023-10-10 18:08:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-02 08:41:20 +02:00
|
|
|
|
public TimeSpan HttpRetryTimeout()
|
2023-10-10 18:08:21 +02:00
|
|
|
|
{
|
2024-05-02 08:41:20 +02:00
|
|
|
|
return TimeSpan.FromHours(2.2);
|
2023-10-10 18:08:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public TimeSpan HttpCallRetryDelay()
|
|
|
|
|
|
{
|
2024-05-02 08:41:20 +02:00
|
|
|
|
return TimeSpan.FromSeconds(20);
|
2023-10-10 18:08:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2023-04-12 16:06:04 +02:00
|
|
|
|
}
|