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

[Feature request]: Add TimeProvider argument to resilience extension methods #1983

Closed
silkfire opened this issue Feb 21, 2024 · 5 comments
Closed

Comments

@silkfire
Copy link

silkfire commented Feb 21, 2024

Is your feature request related to a specific problem? Or an existing feature?

When creating a ResiliencePipelineBuilder, the consumer is offered to set a custom ITimeProvider by setting the TimeProvider property on the builder. This is not possible when using e.g. HTTP resilience extension methods like AddStandardResilienceHandler as the builder is created internally.

Describe the solution you'd like

It'd be useful if an overload was provided that allows the consumer of the extension methods to specify a ITimeProvider argument of their own choice, so as to increase flexibility for e.g. unit tests.

Additional context

No response

@martincostello
Copy link
Member

Could you clarify exactly which methods you want this added to?

If it's the AddStandardResilienceHandler() methods, they don't live in this repository but in dotnet/extensions.

@silkfire
Copy link
Author

silkfire commented Feb 22, 2024

The methods I was referring to were AddStandardResiliencePipeline and AddResiliencePipeline. I wasn't actually aware that they belonged to a different repository. Should I open an issue there instead?

@martincostello
Copy link
Member

I don't seem to be able to find AddStandardResiliencePipeline() in either repository with GitHub code search. AddStandardResilienceHandler() is in dotnt/extensions, where as AddResiliencePipeline() lives here.

public static IServiceCollection AddResiliencePipeline<TKey>(

@martintmk
Copy link
Contributor

@silkfire If TimeProvider is registered in the DI, the AddResiliencePipeline will automatically use and assign it:

if (serviceProvider.GetService<TimeProvider>() is { } timeProvider)

@silkfire
Copy link
Author

I don't seem to be able to find AddStandardResiliencePipeline() in either repository with GitHub code search. AddStandardResilienceHandler() is in dotnt/extensions, where as AddResiliencePipeline() lives here.

public static IServiceCollection AddResiliencePipeline<TKey>(

Apologies, it was late and I got the methods mixed up. The one I intended was AddStandardResilienceHandler().

@silkfire If TimeProvider is registered in the DI, the AddResiliencePipeline will automatically use and assign it:

if (serviceProvider.GetService<TimeProvider>() is { } timeProvider)

Interesting, I wasn't aware of that, this might actually be sufficient for my use case. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants