-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce ResilienceStrategyRegistry #1085
Conversation
|
||
namespace Polly.Core.Tests.Registry; | ||
|
||
public record StrategyId(Type Type, string BuilderName, string InstanceName = "") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@geeknoid We can consider moving this to the core API as we would propably have to copy-paste this piece to our codebase. This struct allows:
- Isolation of strategies by the type of the result they are handling.
- Multi-instance support.
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## main #1085 +/- ##
==========================================
+ Coverage 74.83% 75.04% +0.20%
==========================================
Files 170 173 +3
Lines 4208 4243 +35
Branches 787 790 +3
==========================================
+ Hits 3149 3184 +35
Misses 854 854
Partials 205 205
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
src/Polly.Core.Tests/Registry/ResilienceStrategyRegistryTests.cs
Outdated
Show resolved
Hide resolved
/// An options class used by <see cref="ResilienceStrategyRegistry{TKey}"/>. | ||
/// </summary> | ||
/// <typeparam name="TKey">The type of the key used by the registry.</typeparam> | ||
public class ResilienceStrategyRegistryOptions<TKey> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please document all the default values of the properties and what they do.
/// </summary> | ||
/// <typeparam name="TKey">The type of the key.</typeparam> | ||
/// <remarks> | ||
/// The ResilienceStrategyRegistry class provides a way to organize and manage multiple resilience strategies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// The ResilienceStrategyRegistry class provides a way to organize and manage multiple resilience strategies | |
/// This class provides a way to organize and manage multiple resilience strategies |
The issue or feature being addressed
#1084
Details on the issue fix or feature implementation
Registry allows registration and retrieval of strategies:
Or builders:
The more advanced scenarios allow multi-instance support where one builder is repeatedly used to create multiple strategies. Registry then caches each of these strategies individually. We need this functionality to allow having distinct circuit breaker instances that are cached by composite keys.
Typical scenario for this is having HttpClient that sends requests to a different server across multiple geo-locations. We want to have a different circuit breaker instances assigned.
In the follow-up (#1087) I would like to introduce
Polly.Hosting
orPolly.DependencyInjection
project that integrates theResilienceStrategyRegistry
into the DI and allows defining the strategies at startup usingIServiceCollection
. That way, the core infra will be done and we can focus fully on strategies.Confirm the following