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

Rename HttpClientFactory to WasabiHttpClientFactory and introduce CreateLongLivedHttpClient helper #11307

Merged

Conversation

kiminuo
Copy link
Collaborator

@kiminuo kiminuo commented Aug 17, 2023

Alternative to #10569

Notes:

  • HttpClientFactory is renamed to WasabiHttpClientFactory to avoid confusion with IHttpClientFactory in .NET.
  • WasabiHttpClientFactory.CreateLongLivedHttpClient allows to create HttpClient instances that can live for long-time (as DNS is properly updated).
  • A modification in Global was done to use the new WasabiHttpClientFactory.CreateLongLivedHttpClient helper method.

Review is easy commit by commit. Each commit can be a standalone PR basically if needed.

@kiminuo kiminuo requested a review from adamPetho August 17, 2023 09:04
@kiminuo kiminuo marked this pull request as ready for review August 17, 2023 09:06
@kiminuo
Copy link
Collaborator Author

kiminuo commented Aug 17, 2023

@lontivero @molnard concept ACK?

Copy link
Collaborator

@Szpoti Szpoti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cACK

Copy link
Collaborator

@adamPetho adamPetho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tACK on RegTest, CV also works.

Don't be afraid of the 26 file changes, most of them are just renamings. Code LGTM.

@lontivero
Copy link
Collaborator

cack

/// <remarks>Created HTTP client handles correctly DNS changes.</remarks>
/// <seealso href="https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory"/>
[SuppressMessage("Reliability", "CA2000:Dispose objects before losing scope", Justification = "HTTP client will dispose the handler correctly.")]
public static HttpClient CreateLongLivedHttpClient(TimeSpan? pooledConnectionLifetime = null, DecompressionMethods? automaticDecompression = null)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method can be even in a different class. I have experimented with this but I can't seem to find a nicer/better name.

Copy link
Collaborator

@molnard molnard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK. Basically no change here in behavior. Except that pooledConnectionLifetime by default was InfiniteTimeSpan?
Now it is 5 minutes, right?

https://learn.microsoft.com/en-us/dotnet/api/system.net.http.socketshttphandler.pooledconnectionlifetime?view=net-7.0

@kiminuo
Copy link
Collaborator Author

kiminuo commented Aug 19, 2023

The PR is designed as just refactoring. There should be no change in behavior. We had that 5-minute timeout here: https://github.com/zkSNACKs/WalletWasabi/pull/11307/files#diff-a0fad88b3a26fafa04bbd69a412b28ad930c02cbed0ae3b83026da06122006baL26.

But we can also align with .NET where the timeout is 2 minutes (if I remember correctly).

@lontivero lontivero merged commit 9881093 into zkSNACKs:master Aug 21, 2023
6 of 7 checks passed
@kiminuo kiminuo deleted the feature/2023-08-17-Rename-HttpClientFactory branch August 21, 2023 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants