From c74dc4ce2a3e082191d8b22c68e0aacc7fbec598 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Mon, 7 Aug 2023 08:12:32 +0200 Subject: [PATCH] Simplify file names --- .../CircuitBreakerResilienceStrategy.cs | 2 +- .../Fallback/FallbackResilienceStrategy.cs | 2 +- .../Hedging/HedgingResilienceStrategy.cs | 2 +- ...Strategy.cs => ReactiveResilienceStrategy.cs} | 4 ++-- ....ValueTask.cs => ResilienceStrategy.Async.cs} | 0 ...alueTaskT.cs => ResilienceStrategy.AsyncT.cs} | 0 ...ult.Async.cs => ResilienceStrategyT.Async.cs} | 12 ------------ ...esult.Sync.cs => ResilienceStrategyT.Sync.cs} | 0 src/Polly.Core/ResilienceStrategyT.cs | 16 ++++++++++++++++ src/Polly.Core/Retry/RetryResilienceStrategy.cs | 2 +- ...sync.cs => ResilienceStrategyTTests.Async.cs} | 0 ....Sync.cs => ResilienceStrategyTTests.Sync.cs} | 0 ...eTask.cs => ResilienceStrategyTests.Async.cs} | 0 ...askT.cs => ResilienceStrategyTests.AsyncT.cs} | 0 ...sts.cs => ReactiveResilienceStrategyTests.cs} | 8 +++----- 15 files changed, 25 insertions(+), 23 deletions(-) rename src/Polly.Core/{Utils/OutcomeResilienceStrategy.cs => ReactiveResilienceStrategy.cs} (94%) rename src/Polly.Core/{ResilienceStrategy.Async.ValueTask.cs => ResilienceStrategy.Async.cs} (100%) rename src/Polly.Core/{ResilienceStrategy.Async.ValueTaskT.cs => ResilienceStrategy.AsyncT.cs} (100%) rename src/Polly.Core/{ResilienceStrategy.TResult.Async.cs => ResilienceStrategyT.Async.cs} (90%) rename src/Polly.Core/{ResilienceStrategy.TResult.Sync.cs => ResilienceStrategyT.Sync.cs} (100%) create mode 100644 src/Polly.Core/ResilienceStrategyT.cs rename test/Polly.Core.Tests/{ResilienceStrategyTests.TResult.Async.cs => ResilienceStrategyTTests.Async.cs} (100%) rename test/Polly.Core.Tests/{ResilienceStrategyTests.TResult.Sync.cs => ResilienceStrategyTTests.Sync.cs} (100%) rename test/Polly.Core.Tests/{ResilienceStrategyTests.Async.ValueTask.cs => ResilienceStrategyTests.Async.cs} (100%) rename test/Polly.Core.Tests/{ResilienceStrategyTests.Async.ValueTaskT.cs => ResilienceStrategyTests.AsyncT.cs} (100%) rename test/Polly.Core.Tests/Utils/{OutcomeResilienceStrategyTests.cs => ReactiveResilienceStrategyTests.cs} (91%) diff --git a/src/Polly.Core/CircuitBreaker/CircuitBreakerResilienceStrategy.cs b/src/Polly.Core/CircuitBreaker/CircuitBreakerResilienceStrategy.cs index 4694c47acdb..716931863c9 100644 --- a/src/Polly.Core/CircuitBreaker/CircuitBreakerResilienceStrategy.cs +++ b/src/Polly.Core/CircuitBreaker/CircuitBreakerResilienceStrategy.cs @@ -1,6 +1,6 @@ namespace Polly.CircuitBreaker; -internal sealed class CircuitBreakerResilienceStrategy : OutcomeResilienceStrategy +internal sealed class CircuitBreakerResilienceStrategy : ReactiveResilienceStrategy { private readonly Func, ValueTask> _handler; private readonly CircuitStateController _controller; diff --git a/src/Polly.Core/Fallback/FallbackResilienceStrategy.cs b/src/Polly.Core/Fallback/FallbackResilienceStrategy.cs index 1c73f55b1d6..7c153dc20ce 100644 --- a/src/Polly.Core/Fallback/FallbackResilienceStrategy.cs +++ b/src/Polly.Core/Fallback/FallbackResilienceStrategy.cs @@ -4,7 +4,7 @@ namespace Polly.Fallback; #pragma warning disable CA1031 // Do not catch general exception types -internal sealed class FallbackResilienceStrategy : OutcomeResilienceStrategy +internal sealed class FallbackResilienceStrategy : ReactiveResilienceStrategy { private readonly FallbackHandler _handler; private readonly Func, ValueTask>? _onFallback; diff --git a/src/Polly.Core/Hedging/HedgingResilienceStrategy.cs b/src/Polly.Core/Hedging/HedgingResilienceStrategy.cs index 0d82c07b290..62f0f7c5efc 100644 --- a/src/Polly.Core/Hedging/HedgingResilienceStrategy.cs +++ b/src/Polly.Core/Hedging/HedgingResilienceStrategy.cs @@ -4,7 +4,7 @@ namespace Polly.Hedging; -internal sealed class HedgingResilienceStrategy : OutcomeResilienceStrategy +internal sealed class HedgingResilienceStrategy : ReactiveResilienceStrategy { private readonly TimeProvider _timeProvider; private readonly ResilienceStrategyTelemetry _telemetry; diff --git a/src/Polly.Core/Utils/OutcomeResilienceStrategy.cs b/src/Polly.Core/ReactiveResilienceStrategy.cs similarity index 94% rename from src/Polly.Core/Utils/OutcomeResilienceStrategy.cs rename to src/Polly.Core/ReactiveResilienceStrategy.cs index 0d4368fcf2d..9bbc728e7f7 100644 --- a/src/Polly.Core/Utils/OutcomeResilienceStrategy.cs +++ b/src/Polly.Core/ReactiveResilienceStrategy.cs @@ -1,4 +1,4 @@ -namespace Polly.Utils; +namespace Polly; /// /// This base strategy class is used to simplify the implementation of generic (reactive) @@ -8,7 +8,7 @@ /// /// For strategies that handle all result types the generic parameter must be of type . /// -internal abstract class OutcomeResilienceStrategy : ResilienceStrategy +internal abstract class ReactiveResilienceStrategy : ResilienceStrategy { protected internal sealed override ValueTask> ExecuteCore( Func>> callback, diff --git a/src/Polly.Core/ResilienceStrategy.Async.ValueTask.cs b/src/Polly.Core/ResilienceStrategy.Async.cs similarity index 100% rename from src/Polly.Core/ResilienceStrategy.Async.ValueTask.cs rename to src/Polly.Core/ResilienceStrategy.Async.cs diff --git a/src/Polly.Core/ResilienceStrategy.Async.ValueTaskT.cs b/src/Polly.Core/ResilienceStrategy.AsyncT.cs similarity index 100% rename from src/Polly.Core/ResilienceStrategy.Async.ValueTaskT.cs rename to src/Polly.Core/ResilienceStrategy.AsyncT.cs diff --git a/src/Polly.Core/ResilienceStrategy.TResult.Async.cs b/src/Polly.Core/ResilienceStrategyT.Async.cs similarity index 90% rename from src/Polly.Core/ResilienceStrategy.TResult.Async.cs rename to src/Polly.Core/ResilienceStrategyT.Async.cs index c5c9752a759..270e145ddab 100644 --- a/src/Polly.Core/ResilienceStrategy.TResult.Async.cs +++ b/src/Polly.Core/ResilienceStrategyT.Async.cs @@ -4,20 +4,8 @@ namespace Polly; #pragma warning disable RS0027 // API with optional parameter(s) should have the most parameters amongst its public overloads -/// -/// Resilience strategy is used to execute the user-provided callbacks. -/// -/// The type of result this strategy supports. -/// -/// Resilience strategy supports various types of callbacks of result type -/// and provides a unified way to execute them. This includes overloads for synchronous and asynchronous callbacks. -/// public partial class ResilienceStrategy { - internal ResilienceStrategy(ResilienceStrategy strategy) => Strategy = strategy; - - internal ResilienceStrategy Strategy { get; } - /// /// Executes the specified callback. /// diff --git a/src/Polly.Core/ResilienceStrategy.TResult.Sync.cs b/src/Polly.Core/ResilienceStrategyT.Sync.cs similarity index 100% rename from src/Polly.Core/ResilienceStrategy.TResult.Sync.cs rename to src/Polly.Core/ResilienceStrategyT.Sync.cs diff --git a/src/Polly.Core/ResilienceStrategyT.cs b/src/Polly.Core/ResilienceStrategyT.cs new file mode 100644 index 00000000000..a9119fb4901 --- /dev/null +++ b/src/Polly.Core/ResilienceStrategyT.cs @@ -0,0 +1,16 @@ +namespace Polly; + +/// +/// Resilience strategy is used to execute the user-provided callbacks. +/// +/// The type of result this strategy supports. +/// +/// Resilience strategy supports various types of callbacks of result type +/// and provides a unified way to execute them. This includes overloads for synchronous and asynchronous callbacks. +/// +public partial class ResilienceStrategy +{ + internal ResilienceStrategy(ResilienceStrategy strategy) => Strategy = strategy; + + internal ResilienceStrategy Strategy { get; } +} diff --git a/src/Polly.Core/Retry/RetryResilienceStrategy.cs b/src/Polly.Core/Retry/RetryResilienceStrategy.cs index 6a5d3a244e5..13a7fbcf004 100644 --- a/src/Polly.Core/Retry/RetryResilienceStrategy.cs +++ b/src/Polly.Core/Retry/RetryResilienceStrategy.cs @@ -3,7 +3,7 @@ namespace Polly.Retry; -internal sealed class RetryResilienceStrategy : OutcomeResilienceStrategy +internal sealed class RetryResilienceStrategy : ReactiveResilienceStrategy { private readonly TimeProvider _timeProvider; private readonly ResilienceStrategyTelemetry _telemetry; diff --git a/test/Polly.Core.Tests/ResilienceStrategyTests.TResult.Async.cs b/test/Polly.Core.Tests/ResilienceStrategyTTests.Async.cs similarity index 100% rename from test/Polly.Core.Tests/ResilienceStrategyTests.TResult.Async.cs rename to test/Polly.Core.Tests/ResilienceStrategyTTests.Async.cs diff --git a/test/Polly.Core.Tests/ResilienceStrategyTests.TResult.Sync.cs b/test/Polly.Core.Tests/ResilienceStrategyTTests.Sync.cs similarity index 100% rename from test/Polly.Core.Tests/ResilienceStrategyTests.TResult.Sync.cs rename to test/Polly.Core.Tests/ResilienceStrategyTTests.Sync.cs diff --git a/test/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs b/test/Polly.Core.Tests/ResilienceStrategyTests.Async.cs similarity index 100% rename from test/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTask.cs rename to test/Polly.Core.Tests/ResilienceStrategyTests.Async.cs diff --git a/test/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs b/test/Polly.Core.Tests/ResilienceStrategyTests.AsyncT.cs similarity index 100% rename from test/Polly.Core.Tests/ResilienceStrategyTests.Async.ValueTaskT.cs rename to test/Polly.Core.Tests/ResilienceStrategyTests.AsyncT.cs diff --git a/test/Polly.Core.Tests/Utils/OutcomeResilienceStrategyTests.cs b/test/Polly.Core.Tests/Utils/ReactiveResilienceStrategyTests.cs similarity index 91% rename from test/Polly.Core.Tests/Utils/OutcomeResilienceStrategyTests.cs rename to test/Polly.Core.Tests/Utils/ReactiveResilienceStrategyTests.cs index 27701e30eb9..041a59f2e60 100644 --- a/test/Polly.Core.Tests/Utils/OutcomeResilienceStrategyTests.cs +++ b/test/Polly.Core.Tests/Utils/ReactiveResilienceStrategyTests.cs @@ -1,8 +1,6 @@ -using Polly.Utils; +namespace Polly.Core.Tests.Utils; -namespace Polly.Core.Tests.Utils; - -public class OutcomeResilienceStrategyTests +public class ReactiveResilienceStrategyTests { [Fact] public void Ctor_Ok() @@ -62,7 +60,7 @@ public void Pipeline_TypeCheck_Ok() called.Should().BeTrue(); } - private class Strategy : OutcomeResilienceStrategy + private class Strategy : ReactiveResilienceStrategy { private readonly Action> _onOutcome;