You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and injecting like
public DataProvider(
ILogger logger,
[FromKeyedServices(ResiliencePipelineName)] ResiliencePipeline apiRetryPipeline)
and getting an exception This resilience pipeline has been disposed and cannot be used anymore
where DataProvider DI as singleton . How should I control lifetime resilience pipeline for singleton or any other way to resolved above exception
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
Exception(s) (if any)
No response
Polly version
No response
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered:
It's hard to make guesses at what the problem might be from the small snippet you've provided as there's no detail about how you setup your DI container.
If the comments in the attached issue don't help, please provide a minimal reproducible example as a GitHub repository that demonstrates the issue you're experiencing so we can look into this further.
Thanks for the additional code, but it's not something we can just clone and debug (and it's hard to read when you don't use codefences), which is why I asked for a minimal reproducible example as a GitHub repository.
Describe the bug
services.AddResiliencePipeline<string, IApiResponse>(DataProvider.ResiliencePipelineName, (builder, context) =>
{
var logger = context.ServiceProvider.GetRequiredService<ILogger>();
builder.AddRetry(new ()
{
ShouldHandle = new PredicateBuilder()
.HandleResult(static response =>
{
return (int)response.StatusCode >= 500;
}),
MaxRetryAttempts = 2,
DelayGenerator = static args =>
{
var delay = args.AttemptNumber switch
{
0 => TimeSpan.FromSeconds(10),
_ => TimeSpan.FromMinutes(2)
};
return new ValueTask<TimeSpan?>(delay);
},
OnRetry = args =>
{
logger.LogWarning("Retry attempt: {attemptNumber} for {url}", args.AttemptNumber, args.Outcome.Result?.Error?.Uri);
return default;
},
});
and injecting like
public DataProvider(
ILogger logger,
[FromKeyedServices(ResiliencePipelineName)] ResiliencePipeline apiRetryPipeline)
and getting an exception This resilience pipeline has been disposed and cannot be used anymore
where DataProvider DI as singleton . How should I control lifetime resilience pipeline for singleton or any other way to resolved above exception
Expected behavior
No response
Actual behavior
No response
Steps to reproduce
No response
Exception(s) (if any)
No response
Polly version
No response
.NET Version
No response
Anything else?
No response
The text was updated successfully, but these errors were encountered: