@@ -6,6 +6,38 @@ public static partial class PolicyHandlerStorageExtensions
66 {
77 private static readonly Func < int , RetryPolicyOptions , IBulkErrorProcessor , RetryPolicy > _retryPolicyCreator = ( rc , rpo , bep ) => new RetryPolicy ( rc , bep , retryDelay : rpo . RetryDelay ) ;
88
9+ private static readonly Func < RetryPolicyOptions , IBulkErrorProcessor , RetryPolicy > _infiniteRetryPolicyCreator = ( rpo , bep ) => RetryPolicy . InfiniteRetries ( bep , retryDelay : rpo . RetryDelay ) ;
10+
11+ /// <summary>
12+ /// Adds a handler based on a <see cref="RetryPolicy"/> to a pipeline builder
13+ /// that implements the <see cref="IPolicyHandlerStorage{TStorage}"/> interface,
14+ /// configured for **infinite retries**.
15+ /// </summary>
16+ /// <typeparam name="TStorage">Storage type for <see cref="System.Net.Http.DelegatingHandler"/>.</typeparam>
17+ /// <param name="storage">Storage for <see cref="System.Net.Http.DelegatingHandler"/>.</param>
18+ /// <param name="options"><see cref="RetryPolicyOptions"/>.</param>
19+ public static TStorage AddInfiniteRetryHandler < TStorage > ( this IPolicyHandlerStorage < TStorage > storage , RetryPolicyOptions options ) where TStorage : IPolicyHandlerStorage < TStorage >
20+ {
21+ return storage . AddRetryHandler ( _infiniteRetryPolicyCreator , options ) ;
22+ }
23+
24+ /// <summary>
25+ /// Adds a handler based on a <see cref="RetryPolicy"/> to a pipeline builder
26+ /// that implements the <see cref="IPolicyHandlerStorage{TStorage}"/> interface,
27+ /// configured for **infinite retries**.
28+ /// </summary>
29+ /// <typeparam name="TStorage">Storage type for <see cref="System.Net.Http.DelegatingHandler"/>.</typeparam>
30+ /// <param name="storage">Storage for <see cref="System.Net.Http.DelegatingHandler"/>.</param>
31+ /// <param name="configure">Delegate for configuring <see cref="RetryPolicyOptions"/>.</param>
32+ /// <returns></returns>
33+ public static TStorage AddInfiniteRetryHandler < TStorage > ( this IPolicyHandlerStorage < TStorage > storage , Action < RetryPolicyOptions > configure = null ) where TStorage : IPolicyHandlerStorage < TStorage >
34+ {
35+ var options = new RetryPolicyOptions ( ) ;
36+ configure ? . Invoke ( options ) ;
37+
38+ return storage . AddInfiniteRetryHandler ( options ) ;
39+ }
40+
941 /// <summary>
1042 /// Adds a handler based on a RetryPolicy to a pipeline builder
1143 /// that implements the <see cref="IPolicyHandlerStorage{TStorage}"/> interface.
0 commit comments