-
-
Notifications
You must be signed in to change notification settings - Fork 746
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
feature: Have the possibility to setup Polly Context #801
Comments
I think once #1001 is merged you could actually do this! Looking at the source code for |
It seems like this suggestion has made it into the docs as a recommended way to pass the Polly Context, but has this been confirm to actually work? I've been trying to set this up to pass an ILogger to my policies but haven't been able to get it to actually work., Even though I've added the property to my method signature:
And create a new context when executing the method:
When I debug the policy the context that I see when the action is executed is an new empty context and not the one I created with the attached logger. |
After some digging it turns out you've found a bug in the docs. I'll submit a PR for it later on. The correct key is "PolicyExecutionContext". Polly and Policy are so similar I must have just misread or mistyped it when adding it to the docs. It does work though. I replicated it in a unit test and also included advice on how to better accomplish the same thing through the use of a DelegatingHandler without passing it through the
|
@james-s-tayler fantastic! Thank you so much fixing the doc bug and pointing out the delegate injection, which I agree is much better for my use case. |
A bug report came in via an old issue reactiveui#801 that highlighted a bug in the docs. I've fixed the doc bug and added some guidance on how better to support a common use case and outlined in what case it's appropriate to pass the `Polly.Context` via the `[Property]` attribute.
@clairernovotny once #1366 is merged we can close this issue as it's fully supported now and the docs are clear on when/how to use it. Thanks @turacma for raising this. |
A bug report came in via an old issue #801 that highlighted a bug in the docs. I've fixed the doc bug and added some guidance on how better to support a common use case and outlined in what case it's appropriate to pass the `Polly.Context` via the `[Property]` attribute.
Hello and thanks in advance!
What about the case in which Polly and Refit are used with HttpClientFactory?
For example: is there a way to setup the Polly
Context
before each call with Refit?https://github.com/App-vNext/Polly/wiki/Keys-And-Context-Data
I didn't find a way to manage this.
In
Controllers
for example you inject the refit-generated interface (and it is amazing) but at this point you can't setup theContext
because you can't access the underlying http request.Polly provides the
request.SetPolicyExecutionContext(context);
but we can't use it.https://github.com/App-vNext/Polly/wiki/Polly-and-HttpClientFactory#use-case-exchanging-information-between-policy-execution-and-calling-code
The text was updated successfully, but these errors were encountered: