Skip to content

Add async-friendly actor HTTPClient #6022

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

Merged
merged 46 commits into from
Feb 1, 2023
Merged

Conversation

MaxDesiatov
Copy link
Contributor

@MaxDesiatov MaxDesiatov commented Jan 6, 2023

Motivation:

For making HTTP requests in async context, either HTTPClient or its replacement need to expose async functions.

Modifications:

Existing HTTPClient makes strong assumptions about its concurrency behavior, as it exposes Dispatch types in its API. For that reason it was renamed to LegacyHTTPClient. New HTTPClient can use the same URLSessionHTTPClient underlying implementation that LegacyHTTPClient uses.

Additionally, moved HTTPClientHeaders, HTTPClientRequest, and HTTPClientResponse to separate files for easier maintenance.

Depends on #6058 and #6075.

Result:

HTTPClient can now be used in async context. It's not used anywhere in this PR yet, so this is technically NFC.

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov MaxDesiatov self-assigned this Jan 6, 2023
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

1 similar comment
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@@ -28,6 +28,19 @@ public struct URLSessionHTTPClient {
self.downloadTaskManager = DownloadTaskManager(configuration: configuration)
}

@available(macOS 12, *)
public func execute(
Copy link
Contributor

Choose a reason for hiding this comment

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

couple of things:

  1. lets add a test that puts some concurrent load on this? there is a similar one already but would be nice to have one that tests the threading across async boundries
  2. iirc @neonichu ran into some trouble introducing async APIs since some of the CI / toolchain build nodes did not have the backward support libraries. need to make sure that is addressed so we can finally make use of async APIs in SwiftPM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added tests that are basically asyncified copies of existing non-async tests for HTTPClient. Did you have something specific in mind for testing threading across async boundaries?

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov MaxDesiatov force-pushed the maxd/httpclient-async-execute branch from f791384 to 8de3549 Compare January 10, 2023 14:06
Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

👍 assuming CI can handle it :D

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

2 similar comments
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@tomerd tomerd left a comment

Choose a reason for hiding this comment

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

some unrelated changes here need further review / discussion. comments inline

@MaxDesiatov MaxDesiatov force-pushed the maxd/httpclient-async-execute branch from 60bde3f to f5925b7 Compare January 19, 2023 21:41
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov MaxDesiatov marked this pull request as draft January 19, 2023 21:43
@MaxDesiatov MaxDesiatov added the WIP Work in progress label Jan 19, 2023
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

6 similar comments
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov MaxDesiatov force-pushed the maxd/httpclient-async-execute branch from 47191c8 to 219ede1 Compare January 31, 2023 18:30
@MaxDesiatov MaxDesiatov changed the base branch from maxd/concurrency-helpers to main January 31, 2023 18:30
@MaxDesiatov MaxDesiatov dismissed tomerd’s stale review January 31, 2023 18:30

The base branch was changed.

@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov MaxDesiatov requested a review from tomerd January 31, 2023 18:31
@MaxDesiatov
Copy link
Contributor Author

@swift-ci smoke test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test Windows platform

@MaxDesiatov
Copy link
Contributor Author

@swift-ci please smoke test Windows platform

@MaxDesiatov
Copy link
Contributor Author

@swift-ci please test Windows platform

@MaxDesiatov MaxDesiatov merged commit 5e27ab8 into main Feb 1, 2023
@MaxDesiatov MaxDesiatov deleted the maxd/httpclient-async-execute branch February 1, 2023 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants