-
-
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
Demonstrate how to create dynamic strategies with complex keys #1366
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1366 +/- ##
=======================================
Coverage 83.80% 83.80%
=======================================
Files 273 273
Lines 6476 6476
Branches 1010 1010
=======================================
Hits 5427 5427
Misses 840 840
Partials 209 209
Flags with carried forward coverage won't be shown. Click here to find out more. |
Thanks for this - I'll have a play around with it now. In my case, these options objects are bound from |
Off the top of my head, would nulling out the |
It's also getting a bit bootstrap-y, as I need the options from configuration to configure the service container, as that's where the endpoint options come from. |
This is starting to get a bit complicated - tomorrow I'll try and extract the relevant parts of the v7 Polly code into a runnable-sample with the existing tests - then it'll be easier to see what the migration path would be and if there's anything we can do to make that easier. |
In case you configure the Instead of: var endpointOptions = context.StrategyKey.EndpointOptions; You do: // resolve the options from DI
var endpointOptions = context.GetOptions<EndpointOptions>(context.StrategyKey.EndpointName);
// enable dynamic reload of the resilience strategy being configured whenever the named options are changed
context.EnableReloads<EndpointOptions>(context.StrategyKey.EndpointName); |
test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs
Outdated
Show resolved
Hide resolved
test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs
Outdated
Show resolved
Hide resolved
test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs
Outdated
Show resolved
Hide resolved
test/Polly.Extensions.Tests/Issues/IssuesTests.StrategiesPerEndpoint_1365.cs
Outdated
Show resolved
Hide resolved
2a4650b
to
66af7d6
Compare
@martincostello is it OK to merge this one or we are waiting for alpha.6? |
Sure - btw have you forgotten to re-open Slack since your vacation? 😄 |
Ooops, I check it maybe once, twice a day so the risk of me missing something is high :D |
Details on the issue fix or feature implementation
This sample demonstrates how to define a HTTP resilience strategy that is created and configured for different combinations of endpoints/resources.
The idea is to cache the strategy by complex
EndpointKey
. This sample also demonstrates howEndpointKey
can be used to create dynamic strategies where some inner strategies are conditional.Paired with the
EndpointKey
is the configuration ofResilienceStrategyRegistryOptions<EndpointKey>
where we customize how the registry creates and caches the strategies.@martincostello
Contributes to #1365
Confirm the following