-
Notifications
You must be signed in to change notification settings - Fork 121
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
baby steps towards a Structured Concurrency API #806
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy with this, but would like @fabianfett to review as well.
I left some Sendable correctness remarks. Overall this looks good to me. |
public static func withHTTPClient<R: Sendable>( | ||
eventLoopGroup: any EventLoopGroup = HTTPClient.defaultEventLoopGroup, | ||
configuration: Configuration = Configuration(), | ||
backgroundActivityLogger: Logger? = nil, | ||
_ body: @escaping @Sendable (HTTPClient) async throws -> R | ||
) async throws -> R { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static func withHTTPClient<R: Sendable>( | |
eventLoopGroup: any EventLoopGroup = HTTPClient.defaultEventLoopGroup, | |
configuration: Configuration = Configuration(), | |
backgroundActivityLogger: Logger? = nil, | |
_ body: @escaping @Sendable (HTTPClient) async throws -> R | |
) async throws -> R { | |
public static func withHTTPClient<Result: Sendable>( | |
eventLoopGroup: any EventLoopGroup = HTTPClient.defaultEventLoopGroup, | |
configuration: Configuration = Configuration(), | |
backgroundActivityLogger: Logger? = nil, | |
_ body: (HTTPClient) async throws -> Result | |
) async throws -> Result { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's in the 5.9 part
11db0bf
to
4f6856d
Compare
Thanks @FranzBusch for advice here! As you know, I still use |
At the moment,
HTTPClient
's entire API surface violates Structured Concurrency. Both the creation & shutdown of a HTTP client as well as making requests (#807) doesn't follow Structured Concurrency. Some of the problems are:This PR is baby steps towards a Structured Concurrency API, starting with start/shutdown of the HTTP client.