Skip to content
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 ResilienceProperties #1062

Merged
merged 4 commits into from
Mar 20, 2023
Merged

Introduce ResilienceProperties #1062

merged 4 commits into from
Mar 20, 2023

Conversation

martintmk
Copy link
Contributor

@martintmk martintmk commented Mar 19, 2023

The issue or feature being addressed

The resilience properties are heavily inspired by HttpRequestOptions and allow type-safe access to custom data attached to ResilienceContext.

Example Usage:

        var context = ResilienceContext.Get();
        var key = new ResiliencePropertyKey<string>("my-key");

        // set property
        context.Properties.Set(key, "my-value");

        // retrieve
        context.Properties.TryGetValue(key, out var value);

        // retrieve with the default fallback
        value = context.Properties.GetValue(key, "default-value");

Details on the issue fix or feature implementation

The ResilienceProperty are convertible to IDictionary<string, object?> and support the same scenarios as the Context found in V7. In general, extensibility author can expose well-known properties for easy and type-safe access.

Confirm the following

  • I started this PR by branching from the head of the default branch
  • I have targeted the PR to merge into the default branch
  • I have included unit tests for the issue/feature
  • I have successfully run a local build

src/Polly.Core.Tests/ResiliencePropertyKeyTests.cs Outdated Show resolved Hide resolved
src/Polly.Core/Builder/ResilienceStrategyBuilderOptions.cs Outdated Show resolved Hide resolved
src/Polly.Core/ResilienceContext.cs Outdated Show resolved Hide resolved
src/Polly.Core/ResilienceProperties.cs Outdated Show resolved Hide resolved
src/Polly.Core/ResilienceProperties.cs Outdated Show resolved Hide resolved
src/Polly.Core/ResilienceProperties.cs Outdated Show resolved Hide resolved
src/Polly.Core/ResiliencePropertyKey.cs Outdated Show resolved Hide resolved
@martintmk martintmk merged commit 0b3e741 into main Mar 20, 2023
@martincostello martincostello deleted the mtomka/ResilienceProperties branch March 20, 2023 09:35
@martincostello martincostello added this to the v8.0.0 milestone Mar 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants