Winton.Extensions.Configuration.Consul icon indicating copy to clipboard operation
Winton.Extensions.Configuration.Consul copied to clipboard

WintonExtensions and Polly retry policies

Open TheDouye opened this issue 5 years ago • 3 comments

Hi. Not sure this is the right place to post so do not hesitate to tell me. I would like to use a retry policy (for instance with Polly) whenever a request fails. But I'm not sure the current API allows me to do this. Or I don't know how to do it :). So what is the best way to achieve this ?

I am able to do it in the OnLoadException callback by forcing context.Source.Build(configurationBuilder).Load() and finally add it the current IConfigurationBuilder but for me we should be able to apply the policy directly on the Load method of the ConsulConfigurationProvider class, shouldn't we ?

I can also create a ConfigurationBuilder and add ConsulConfigurationSource (s) only, call the Build method, retry as long as it fails, and finally add the created IConfiguration to the ConfigurationBuilder that will be used in my StartUp (bootstrap) class.

Thx a lot and have a good day

TheDouye avatar Apr 29 '20 13:04 TheDouye

@TheDouye thanks for opening this. I've been a bit busy with other things recently, but I'll try and get back to you with a proper answer shortly. One thing that jumped to mind was that you can access the underlying HttpClient through the ConsulHttpClientOptions property when configuring the Consul config source. From the limited knowledge I have about Polly I thought that it might be possible to integrate it through there?

If that doesn't work or is particularly cumbersome then please let me know. I'd be open to improving the functionality in this area. I think it would be good to make it possible to make the initial load more resilient if clients want that behaviour. I wouldn't want to add a direct dependency on anything like Polly though, so we'd need to find a way to create an interface enabled this.

Choc13 avatar May 06 '20 10:05 Choc13

Hello Really sorry for not having answered :(. Actually we just used Polly around the Build method after adding Consul as a configuration source (it has some drawbacks...). From what I remembered we could not use the HttpClient (the HttpClientFactory would have been more usefull) Thx

TheDouye avatar Jun 05 '20 14:06 TheDouye