Skip to content

Commit 38a75c4

Browse files
committed
Default names for individual resilience strategies
1 parent 855ce01 commit 38a75c4

18 files changed

+49
-25
lines changed

src/Polly.Core/CircuitBreaker/CircuitBreakerConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace Polly.CircuitBreaker;
22

33
internal static class CircuitBreakerConstants
44
{
5+
public const string DefaultName = "CircuitBreaker";
6+
57
public const string OnCircuitClosed = "OnCircuitClosed";
68

79
public const string OnHalfOpenEvent = "OnCircuitHalfOpened";

src/Polly.Core/CircuitBreaker/CircuitBreakerStrategyOptions.TResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ namespace Polly.CircuitBreaker;
2222
/// </remarks>
2323
public class CircuitBreakerStrategyOptions<TResult> : ResilienceStrategyOptions
2424
{
25+
/// <summary>
26+
/// Initializes a new instance of the <see cref="CircuitBreakerStrategyOptions{TResult}"/> class.
27+
/// </summary>
28+
public CircuitBreakerStrategyOptions() => Name = CircuitBreakerConstants.DefaultName;
29+
2530
/// <summary>
2631
/// Gets or sets the failure-to-success ratio at which the circuit will break.
2732
/// </summary>

src/Polly.Core/Fallback/FallbackConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace Polly.Fallback;
22

33
internal static class FallbackConstants
44
{
5+
public const string DefaultName = "Fallback";
6+
57
public const string OnFallback = "OnFallback";
68
}
79

src/Polly.Core/Fallback/FallbackStrategyOptions.TResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace Polly.Fallback;
88
/// <typeparam name="TResult">The result type.</typeparam>
99
public class FallbackStrategyOptions<TResult> : ResilienceStrategyOptions
1010
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="FallbackStrategyOptions{TResult}"/> class.
13+
/// </summary>
14+
public FallbackStrategyOptions() => Name = FallbackConstants.DefaultName;
15+
1116
/// <summary>
1217
/// Gets or sets the outcome predicate for determining whether a fallback should be executed.
1318
/// </summary>

src/Polly.Core/Hedging/HedgingConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace Polly.Hedging;
22

33
internal static class HedgingConstants
44
{
5+
public const string DefaultName = "Hedging";
6+
57
public const string OnHedgingEventName = "OnHedging";
68

79
public const int DefaultMaxHedgedAttempts = 2;

src/Polly.Core/Hedging/HedgingStrategyOptions.TResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace Polly.Hedging;
88
/// <typeparam name="TResult">The type of result these hedging options handle.</typeparam>
99
public class HedgingStrategyOptions<TResult> : ResilienceStrategyOptions
1010
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="HedgingStrategyOptions{TResult}"/> class.
13+
/// </summary>
14+
public HedgingStrategyOptions() => Name = HedgingConstants.DefaultName;
15+
1116
/// <summary>
1217
/// Gets or sets the minimal time of waiting before spawning a new hedged call.
1318
/// </summary>

src/Polly.Core/Retry/RetryConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ namespace Polly.Retry;
22

33
internal static class RetryConstants
44
{
5+
public const string DefaultName = "Retry";
6+
57
public const string OnRetryEvent = "OnRetry";
68

79
public const RetryBackoffType DefaultBackoffType = RetryBackoffType.Constant;

src/Polly.Core/Retry/RetryStrategyOptions.TResult.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ namespace Polly.Retry;
88
/// <typeparam name="TResult">The type of result the retry strategy handles.</typeparam>
99
public class RetryStrategyOptions<TResult> : ResilienceStrategyOptions
1010
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="RetryStrategyOptions{TResult}"/> class.
13+
/// </summary>
14+
public RetryStrategyOptions() => Name = RetryConstants.DefaultName;
15+
1116
/// <summary>
1217
/// Gets or sets the maximum number of retries to use, in addition to the original call.
1318
/// </summary>

src/Polly.Core/Timeout/TimeoutConstants.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ namespace Polly.Timeout;
22

33
internal static class TimeoutConstants
44
{
5+
public const string DefaultName = "Timeout";
6+
57
public const string OnTimeoutEvent = "OnTimeout";
68
}

src/Polly.Core/Timeout/TimeoutStrategyOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ namespace Polly.Timeout;
77
/// </summary>
88
public class TimeoutStrategyOptions : ResilienceStrategyOptions
99
{
10+
/// <summary>
11+
/// Initializes a new instance of the <see cref="TimeoutStrategyOptions"/> class.
12+
/// </summary>
13+
public TimeoutStrategyOptions() => Name = TimeoutConstants.DefaultName;
14+
1015
#pragma warning disable IL2026 // Addressed with DynamicDependency on ValidationHelper.Validate method
1116
/// <summary>
1217
/// Gets or sets the default timeout.

0 commit comments

Comments
 (0)