From 9a69db3289058f6115cacd2e3a7e614b5de637f0 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Thu, 29 Jun 2023 09:04:10 +0200 Subject: [PATCH 01/10] Demonstrate how to create dynamic strategies with complex keys --- .../IssuesTests.StrategiesPerEndpoint_1365.cs | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs new file mode 100644 index 00000000000..953f78748be --- /dev/null +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -0,0 +1,109 @@ +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using Microsoft.Extensions.DependencyInjection; +using Polly.Registry; +using Polly.Retry; +using Polly.Timeout; + +namespace Polly.Extensions.Tests.Issues; + +public partial class IssuesTests +{ + [Fact] + public void StrategiesPerEndpoint_1365() + { + var services = new ServiceCollection(); + + // add resilience strategy, keyed by EndpointKey that only defines the builder name + services.AddResilienceStrategy(new EndpointKey("my-pipeline", string.Empty, string.Empty, new()), (builder, context) => + { + var endpointOptions = context.StrategyKey.EndpointOptions; + + // apply retries optionally per-endpoint + if (endpointOptions.Retries > 0) + { + builder.AddRetry(new() + { + BackoffType = RetryBackoffType.ExponentialWithJitter, + RetryCount = endpointOptions.Retries, + StrategyName = $"{context.StrategyKey.EndpointName}-Retry", + }); + } + + // apply circuit breaker + builder.AddAdvancedCircuitBreaker(new() + { + BreakDuration = endpointOptions.BreakDuration, + StrategyName = $"{context.StrategyKey.EndpointName}-{context.StrategyKey.Resource}-CircuitBreaker" + }); + + // apply timeout + + builder.AddTimeout(new TimeoutStrategyOptions + { + StrategyName = $"{context.StrategyKey.EndpointName}-Timeout", + Timeout = endpointOptions.Timeout.Add(TimeSpan.FromSeconds(1)), + }); + }); + + // configure the registry to allow multi-dimensional keys + services.Configure>(options => + { + options.BuilderComparer = new EndpointKey.BuilderComparer(); + options.StrategyComparer = new EndpointKey.StrategyComparer(); + + // format the key for telemetry + options.StrategyKeyFormatter = key => $"{key.BuilderName}-{key.EndpointName}-{key.Resource}"; + + // format the builder name for telemetry + options.BuilderNameFormatter = key => key.BuilderName; + }); + + // create the strategy provider + var provider = services.BuildServiceProvider().GetRequiredService>(); + + // Endpoint 1 + var endpoint1Options = new EndpointOptions + { + Retries = 3, + BreakDuration = TimeSpan.FromSeconds(30), + Timeout = TimeSpan.FromSeconds(10), + }; + + // define a key for each resource/endpoint combination + var resource1Key = new EndpointKey("my-pipeline", "Endpoint 1", "Resource 1", endpoint1Options); + var resource2Key = new EndpointKey("my-pipeline", "Endpoint 1", "Resource 2", endpoint1Options); + + var strategy1 = provider.GetStrategy(resource1Key); + var strategy2 = provider.GetStrategy(resource2Key); + + strategy1.Should().NotBe(strategy2); + } + + public class EndpointOptions + { + public int Retries { get; set; } + + public TimeSpan BreakDuration { get; set; } + + public TimeSpan Timeout { get; set; } + } + + public record EndpointKey(string BuilderName, string EndpointName, string Resource, EndpointOptions EndpointOptions) + { + public class BuilderComparer : IEqualityComparer + { + public bool Equals(EndpointKey? x, EndpointKey? y) => StringComparer.Ordinal.Equals(x.BuilderName, y.BuilderName); + + public int GetHashCode([DisallowNull] EndpointKey obj) => StringComparer.Ordinal.GetHashCode(obj.BuilderName); + } + + public class StrategyComparer : IEqualityComparer + { + public bool Equals(EndpointKey? x, EndpointKey? y) => (x.BuilderName, x.EndpointName, x.Resource) == (y.BuilderName, y.EndpointName, y.Resource); + + public int GetHashCode([DisallowNull] EndpointKey obj) => (obj.BuilderName, obj.EndpointName, obj.Resource).GetHashCode(); + } + } +} From f5f832fa7c5a3c860bfc372b78110c439ead5a39 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Thu, 29 Jun 2023 09:10:27 +0200 Subject: [PATCH 02/10] improve test --- .../Issues/IssuesTests.StrategiesPerEndpoint_1365.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index 953f78748be..57dc53d0fd8 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -79,6 +79,8 @@ public void StrategiesPerEndpoint_1365() var strategy2 = provider.GetStrategy(resource2Key); strategy1.Should().NotBe(strategy2); + provider.GetStrategy(resource1Key).Should().BeSameAs(strategy1); + provider.GetStrategy(resource2Key).Should().BeSameAs(strategy2); } public class EndpointOptions From bbb6e8c89f1fa1a1d0bc0c4d1c1973f9674dab7c Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Thu, 29 Jun 2023 09:12:27 +0200 Subject: [PATCH 03/10] cleanup --- .../Issues/IssuesTests.StrategiesPerEndpoint_1365.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index 57dc53d0fd8..c319ded8177 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; -using System.Net.Http; using Microsoft.Extensions.DependencyInjection; using Polly.Registry; using Polly.Retry; @@ -16,7 +15,7 @@ public void StrategiesPerEndpoint_1365() var services = new ServiceCollection(); // add resilience strategy, keyed by EndpointKey that only defines the builder name - services.AddResilienceStrategy(new EndpointKey("my-pipeline", string.Empty, string.Empty, new()), (builder, context) => + services.AddResilienceStrategy(new EndpointKey("my-pipeline", string.Empty, string.Empty, new()), (builder, context) => { var endpointOptions = context.StrategyKey.EndpointOptions; @@ -75,12 +74,12 @@ public void StrategiesPerEndpoint_1365() var resource1Key = new EndpointKey("my-pipeline", "Endpoint 1", "Resource 1", endpoint1Options); var resource2Key = new EndpointKey("my-pipeline", "Endpoint 1", "Resource 2", endpoint1Options); - var strategy1 = provider.GetStrategy(resource1Key); - var strategy2 = provider.GetStrategy(resource2Key); + var strategy1 = provider.GetStrategy(resource1Key); + var strategy2 = provider.GetStrategy(resource2Key); strategy1.Should().NotBe(strategy2); - provider.GetStrategy(resource1Key).Should().BeSameAs(strategy1); - provider.GetStrategy(resource2Key).Should().BeSameAs(strategy2); + provider.GetStrategy(resource1Key).Should().BeSameAs(strategy1); + provider.GetStrategy(resource2Key).Should().BeSameAs(strategy2); } public class EndpointOptions From f12b4c93c85b02add6b5eb9dd31fa79c47ddcc72 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Thu, 29 Jun 2023 09:14:49 +0200 Subject: [PATCH 04/10] cleanup --- .../Issues/IssuesTests.StrategiesPerEndpoint_1365.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index c319ded8177..b4cf8287d42 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -38,7 +38,6 @@ public void StrategiesPerEndpoint_1365() }); // apply timeout - builder.AddTimeout(new TimeoutStrategyOptions { StrategyName = $"{context.StrategyKey.EndpointName}-Timeout", From aeb0968ae2b1caf667a2f13f4e5988254d9777a1 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Thu, 29 Jun 2023 09:21:16 +0200 Subject: [PATCH 05/10] fixes --- .../Issues/IssuesTests.StrategiesPerEndpoint_1365.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index b4cf8287d42..a955c2bb175 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -94,14 +94,14 @@ public record EndpointKey(string BuilderName, string EndpointName, string Resour { public class BuilderComparer : IEqualityComparer { - public bool Equals(EndpointKey? x, EndpointKey? y) => StringComparer.Ordinal.Equals(x.BuilderName, y.BuilderName); + public bool Equals(EndpointKey? x, EndpointKey? y) => StringComparer.Ordinal.Equals(x?.BuilderName, y?.BuilderName); public int GetHashCode([DisallowNull] EndpointKey obj) => StringComparer.Ordinal.GetHashCode(obj.BuilderName); } public class StrategyComparer : IEqualityComparer { - public bool Equals(EndpointKey? x, EndpointKey? y) => (x.BuilderName, x.EndpointName, x.Resource) == (y.BuilderName, y.EndpointName, y.Resource); + public bool Equals(EndpointKey? x, EndpointKey? y) => (x?.BuilderName, x?.EndpointName, x?.Resource) == (y?.BuilderName, y?.EndpointName, y?.Resource); public int GetHashCode([DisallowNull] EndpointKey obj) => (obj.BuilderName, obj.EndpointName, obj.Resource).GetHashCode(); } From c0e9d2cbdb4ec6c4c18bde6d976b897cc8f16107 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Mon, 10 Jul 2023 08:29:37 +0200 Subject: [PATCH 06/10] Improve sample --- .../IssuesTests.StrategiesPerEndpoint_1365.cs | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index a955c2bb175..bdf0fc7506d 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; +using System.Threading.RateLimiting; using Microsoft.Extensions.DependencyInjection; using Polly.Registry; using Polly.Retry; @@ -14,11 +15,24 @@ public void StrategiesPerEndpoint_1365() { var services = new ServiceCollection(); + services.AddResilienceStrategy(); + // add resilience strategy, keyed by EndpointKey that only defines the builder name - services.AddResilienceStrategy(new EndpointKey("my-pipeline", string.Empty, string.Empty, new()), (builder, context) => + services.AddResilienceStrategy(new EndpointKey("endpoint-pipeline", string.Empty, string.Empty, new()), (builder, context) => { var endpointOptions = context.StrategyKey.EndpointOptions; + var registry = context.ServiceProvider.GetRequiredService>(); + + // we want to limit the number of concurrent requests per endpoint and not include the resource. + // using a registry we can create and cache the shared resilience strategy + var rateLimiterStrategy = registry.GetOrAddStrategy($"rate-limiter/{context.StrategyKey.EndpointName}", b => + { + b.AddConcurrencyLimiter(new ConcurrencyLimiterOptions { PermitLimit = endpointOptions.MaxParallelization }); + }); + + builder.AddStrategy(rateLimiterStrategy); + // apply retries optionally per-endpoint if (endpointOptions.Retries > 0) { @@ -70,8 +84,8 @@ public void StrategiesPerEndpoint_1365() }; // define a key for each resource/endpoint combination - var resource1Key = new EndpointKey("my-pipeline", "Endpoint 1", "Resource 1", endpoint1Options); - var resource2Key = new EndpointKey("my-pipeline", "Endpoint 1", "Resource 2", endpoint1Options); + var resource1Key = new EndpointKey("endpoint-pipeline", "Endpoint 1", "Resource 1", endpoint1Options); + var resource2Key = new EndpointKey("endpoint-pipeline", "Endpoint 1", "Resource 2", endpoint1Options); var strategy1 = provider.GetStrategy(resource1Key); var strategy2 = provider.GetStrategy(resource2Key); @@ -88,6 +102,8 @@ public class EndpointOptions public TimeSpan BreakDuration { get; set; } public TimeSpan Timeout { get; set; } + + public int MaxParallelization { get; set; } = 10; } public record EndpointKey(string BuilderName, string EndpointName, string Resource, EndpointOptions EndpointOptions) From fcb1481b6b66b37afa4c10bc8682735486d50536 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Mon, 10 Jul 2023 08:41:37 +0200 Subject: [PATCH 07/10] improve sample --- .../IssuesTests.StrategiesPerEndpoint_1365.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index bdf0fc7506d..d57ef79a704 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -2,6 +2,8 @@ using System.Diagnostics.CodeAnalysis; using System.Threading.RateLimiting; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Options; +using Polly.Extensions.Registry; using Polly.Registry; using Polly.Retry; using Polly.Timeout; @@ -16,18 +18,24 @@ public void StrategiesPerEndpoint_1365() var services = new ServiceCollection(); services.AddResilienceStrategy(); + services.AddOptions(); // add resilience strategy, keyed by EndpointKey that only defines the builder name - services.AddResilienceStrategy(new EndpointKey("endpoint-pipeline", string.Empty, string.Empty, new()), (builder, context) => + services.AddResilienceStrategy(new EndpointKey("endpoint-pipeline", string.Empty, string.Empty), (builder, context) => { - var endpointOptions = context.StrategyKey.EndpointOptions; + // we want this pipeline to react to changes in options + context.EnableReloads(); + var endpointOptions = context.GetOptions().Endpoints[context.StrategyKey.EndpointName]; var registry = context.ServiceProvider.GetRequiredService>(); // we want to limit the number of concurrent requests per endpoint and not include the resource. // using a registry we can create and cache the shared resilience strategy - var rateLimiterStrategy = registry.GetOrAddStrategy($"rate-limiter/{context.StrategyKey.EndpointName}", b => + var rateLimiterStrategy = registry.GetOrAddStrategy($"rate-limiter/{context.StrategyKey.EndpointName}", (b, c) => { + // let's also enable reloads for rate limiter + c.EnableReloads(context.ServiceProvider.GetRequiredService>()); + b.AddConcurrencyLimiter(new ConcurrencyLimiterOptions { PermitLimit = endpointOptions.MaxParallelization }); }); @@ -75,17 +83,9 @@ public void StrategiesPerEndpoint_1365() // create the strategy provider var provider = services.BuildServiceProvider().GetRequiredService>(); - // Endpoint 1 - var endpoint1Options = new EndpointOptions - { - Retries = 3, - BreakDuration = TimeSpan.FromSeconds(30), - Timeout = TimeSpan.FromSeconds(10), - }; - // define a key for each resource/endpoint combination - var resource1Key = new EndpointKey("endpoint-pipeline", "Endpoint 1", "Resource 1", endpoint1Options); - var resource2Key = new EndpointKey("endpoint-pipeline", "Endpoint 1", "Resource 2", endpoint1Options); + var resource1Key = new EndpointKey("endpoint-pipeline", "Endpoint 1", "Resource 1"); + var resource2Key = new EndpointKey("endpoint-pipeline", "Endpoint 1", "Resource 2"); var strategy1 = provider.GetStrategy(resource1Key); var strategy2 = provider.GetStrategy(resource2Key); @@ -97,16 +97,25 @@ public void StrategiesPerEndpoint_1365() public class EndpointOptions { - public int Retries { get; set; } + public int Retries { get; set; } = 3; - public TimeSpan BreakDuration { get; set; } + public TimeSpan BreakDuration { get; set; } = TimeSpan.FromSeconds(10); - public TimeSpan Timeout { get; set; } + public TimeSpan Timeout { get; set; } = TimeSpan.FromSeconds(4); public int MaxParallelization { get; set; } = 10; } - public record EndpointKey(string BuilderName, string EndpointName, string Resource, EndpointOptions EndpointOptions) + public class EndpointsOptions + { + public Dictionary Endpoints { get; set; } = new() + { + { "Endpoint 1", new EndpointOptions { Retries = 2 } }, + { "Endpoint 2", new EndpointOptions { Retries = 3 } }, + }; + } + + public record EndpointKey(string BuilderName, string EndpointName, string Resource) { public class BuilderComparer : IEqualityComparer { From 444de246319833d640ef7f2277fc08ae5c3c18d5 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Mon, 10 Jul 2023 11:42:29 +0200 Subject: [PATCH 08/10] cleanup --- .../IssuesTests.StrategiesPerEndpoint_1365.cs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index d57ef79a704..45fa97b4b2f 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -23,20 +23,21 @@ public void StrategiesPerEndpoint_1365() // add resilience strategy, keyed by EndpointKey that only defines the builder name services.AddResilienceStrategy(new EndpointKey("endpoint-pipeline", string.Empty, string.Empty), (builder, context) => { - // we want this pipeline to react to changes in options - context.EnableReloads(); - + var serviceProvider = context.ServiceProvider; var endpointOptions = context.GetOptions().Endpoints[context.StrategyKey.EndpointName]; var registry = context.ServiceProvider.GetRequiredService>(); + // we want this pipeline to react to changes to the options + context.EnableReloads(); + // we want to limit the number of concurrent requests per endpoint and not include the resource. // using a registry we can create and cache the shared resilience strategy - var rateLimiterStrategy = registry.GetOrAddStrategy($"rate-limiter/{context.StrategyKey.EndpointName}", (b, c) => + var rateLimiterStrategy = registry.GetOrAddStrategy($"rate-limiter/{context.StrategyKey.EndpointName}", (builder, context) => { - // let's also enable reloads for rate limiter - c.EnableReloads(context.ServiceProvider.GetRequiredService>()); + // let's also enable reloads for the rate limiter + context.EnableReloads(serviceProvider.GetRequiredService>()); - b.AddConcurrencyLimiter(new ConcurrencyLimiterOptions { PermitLimit = endpointOptions.MaxParallelization }); + builder.AddConcurrencyLimiter(new ConcurrencyLimiterOptions { PermitLimit = endpointOptions.MaxParallelization }); }); builder.AddStrategy(rateLimiterStrategy); @@ -110,8 +111,8 @@ public class EndpointsOptions { public Dictionary Endpoints { get; set; } = new() { - { "Endpoint 1", new EndpointOptions { Retries = 2 } }, - { "Endpoint 2", new EndpointOptions { Retries = 3 } }, + ["Endpoint 1"] = new EndpointOptions { Retries = 2 }, + ["Endpoint 2"] = new EndpointOptions { Retries = 3 }, }; } From 66af7d662071e05f6fa55172ad6b7a7a738ed57b Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Mon, 10 Jul 2023 12:58:57 +0200 Subject: [PATCH 09/10] Improve the test --- .../Issues/IssuesTests.StrategiesPerEndpoint_1365.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index 45fa97b4b2f..6818ae7009a 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -15,6 +15,8 @@ public partial class IssuesTests [Fact] public void StrategiesPerEndpoint_1365() { + var events = new List(); + using var listener = TestUtilities.EnablePollyMetering(events); var services = new ServiceCollection(); services.AddResilienceStrategy(); @@ -75,7 +77,7 @@ public void StrategiesPerEndpoint_1365() options.StrategyComparer = new EndpointKey.StrategyComparer(); // format the key for telemetry - options.StrategyKeyFormatter = key => $"{key.BuilderName}-{key.EndpointName}-{key.Resource}"; + options.InstanceNameFormatter = key => $"{key.EndpointName}/{key.Resource}"; // format the builder name for telemetry options.BuilderNameFormatter = key => key.BuilderName; @@ -94,6 +96,11 @@ public void StrategiesPerEndpoint_1365() strategy1.Should().NotBe(strategy2); provider.GetStrategy(resource1Key).Should().BeSameAs(strategy1); provider.GetStrategy(resource2Key).Should().BeSameAs(strategy2); + + strategy1.Execute(() => { }); + events.Should().HaveCount(3); + events[0].Tags["builder-name"].Should().Be("endpoint-pipeline"); + events[0].Tags["builder-instance"].Should().Be("Endpoint 1/Resource 1"); } public class EndpointOptions From acf3625dab85953a681169482263b73ab5d8e8c1 Mon Sep 17 00:00:00 2001 From: Martin Tomka Date: Wed, 12 Jul 2023 13:33:02 +0200 Subject: [PATCH 10/10] adopt to latest API --- .../Issues/IssuesTests.StrategiesPerEndpoint_1365.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs index 6818ae7009a..13e4445e70d 100644 --- a/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs +++ b/test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs @@ -19,7 +19,7 @@ public void StrategiesPerEndpoint_1365() using var listener = TestUtilities.EnablePollyMetering(events); var services = new ServiceCollection(); - services.AddResilienceStrategy(); + services.AddResilienceStrategyRegistry(); services.AddOptions(); // add resilience strategy, keyed by EndpointKey that only defines the builder name @@ -71,7 +71,7 @@ public void StrategiesPerEndpoint_1365() }); // configure the registry to allow multi-dimensional keys - services.Configure>(options => + services.AddResilienceStrategyRegistry(options => { options.BuilderComparer = new EndpointKey.BuilderComparer(); options.StrategyComparer = new EndpointKey.StrategyComparer();