Questions tagged [policywrap]

14 questions
13
votes
2 answers

Execute multiple policies

How to execute multiple policies (or combine them into a single one)? For example I have: var policy1 = Policy.Handle().WaitAndRetry(5)); var policy2 = Policy.Handle().RetryForever(); How to apply…
denny
  • 320
  • 3
  • 10
3
votes
2 answers

Polly C# retry exponentially for 3 tries then switch to retrying every hour

I am trying to use polly to construct a policy that can retry exponentially for n tries and then switch to retrying every 1 hour. Can this be achieved? I tried policy Wrap but did not get the desired results
3
votes
1 answer

C# and Polly - How to Unwrap IAsyncPolicy to get to the ICircuitBreakerPolicy

I am setting up Polly policies with some variant of: Policy .Handle() .AdvancedCircuitBreakerAsync(failureThreshold, samplingDuration, minimumThroughput, durationOfBreak ) .WrapAsync(Policy.TimeoutAsync(timeout,…
JALLRED
  • 855
  • 1
  • 11
  • 23
2
votes
1 answer

C# Polly combining http error handler, retry, bulkhead and timeout to be used inside HttpClient

I am trying to make some HTTP calls and I want to have retry, timeout, and bulkhead for maximum concurrent connections. This is my attempt. I don't know if the order of the WrapAsync function calls is correct. More specifically, I may sometimes get…
Node.JS
  • 1,042
  • 6
  • 44
  • 114
2
votes
1 answer

C# Polly Start counting CircuitBreaker Exception only on the last Retry attempt Exception

I'm trying to use Polly on an HttpClient with three policies: Retry, CircuitBreaker, Timeout. The result I would like to achieve is that the CircuitBreaker always starts counting from the last error of the Retry and not from all errors. For example,…
pampua84
  • 696
  • 10
  • 33
2
votes
1 answer

getting conversion error while trying to wrap 2 Polly policies

I am trying to wrap two Polly policies and want to return IAsyncPolicy, but it giving error, convert from Polly.Retry.RetryPolicy < System.Net.Http.HttpResponseMessage> to Polly.IAsyncPolicy public static IAsyncPolicy CreateDefaultRetryPolicy() …
user584018
  • 10,186
  • 15
  • 74
  • 160
1
vote
1 answer

Polly - How to achieve a circuit breaker that opens the circuit on WaitAndRetry failure and puts back retry logic on each 30 minutes if it fails

I was used to WaitAndRetryForeverAsync in the past which was wrong because I believe the Retry pattern is supposed to handle only transient faults, such as rate limiting, 429 status code, etc. At the moment that the API I was subscribing to went…
nop
  • 4,711
  • 6
  • 32
  • 93
1
vote
1 answer

Combining Polly policies and accessing handled exception in Polly policy Fallback

Given the following F# snippets //User Code .. code that can throw exceptions "Success" P1 policy Policy .Handle(fun cx -> cx.StatusCode = HttpStatusCode.TooManyRequests) .WaitAndRetryForever((fun _ cx _ -> (cx :?>…
Franco Tiveron
  • 2,364
  • 18
  • 34
1
vote
1 answer

why my polly timeout policy seems not firing

This is my Polly implementation, it has two policy, one timeout and one retry. The idea is that when sql time out, the timeout span will become longer, so sql server got more time to do the work. However, when using a sp that takes minutes to finish…
daxu
  • 3,514
  • 5
  • 38
  • 76
1
vote
1 answer

Polly Timeout optimistic using HttpClientFactory. How can I use cancellation token?

I would like to understand how to implement an optimistic timeout policy with Polly by using the HttpClientFactory. In the examples on the net, the timeout policy is used when calling asynchronous methods to be able to pass the cancellation token.…
alex
  • 101
  • 2
1
vote
1 answer

Can I share retryCount across policies in a PolicyWrap instead of them resetting?

I currently have two retry policies configured for making some api calls which are being executed using a PolicyWrap: A WaitAndRetry policy for catching 429 rate limit errors and honoring the retry-after header A regular retry policy for handling…
Kirlac
  • 684
  • 6
  • 18
0
votes
1 answer

Polly with cancellation token is not working for synchronous thread

I'm new to Polly so there may be a completely different approach compared to the one I'm trying to do and that would be perfectly OK. My goals are this: I am using timeout strategy as: TimeoutStrategy.Optimistic I want to timeout the call for given…
Monika A
  • 9
  • 2
0
votes
1 answer

how to capture CircuitState for AsyncCircuitBreakerPolicy

I have a variable asyncPolicy of type IAsyncPolicy which has one or more policy including AsyncCircuitBreakerPolicy. Now I want to get specific policy say AsyncCircuitBreakerPolicy before a API call, so that I can extract the status of Circuit. Is…
user584018
  • 10,186
  • 15
  • 74
  • 160
0
votes
0 answers

how to implement custom method when Polly circuit is close

I have method which returns IAsyncPolicy and it has 2 or more policies along with CircuitBreaker and part of my DI. Now in my implementation class I added one extra fallbackPolicy to handle BrokenCircuitException and wrap it…
user584018
  • 10,186
  • 15
  • 74
  • 160