After discussing with members of the Swift Server Workgroup (https://www.swift.org/sswg/ ), I've come to the conclusion that we'll need to revert the Client initializer back to injecting the HTTPClient.
Their recommendations are as follows:
Normally users should have one HTTPClient per app. HTTPClients should be long-lived since they pool the connections for you.
Calling a sync shutdown in a deinit may block the concurrent executor, which can lead to unexpected hangs. Especially if you use your client from an async/await context.
Generally, we would advise creating a single HTTPClient on startup and shutting it down on application close. Automatically shutting it down in deinit leads to patterns where users create HTTPClients over and over which is bad performance-wise since the underlying connection pool can not be shared over multiple executions.
After discussing with members of the Swift Server Workgroup (https://www.swift.org/sswg/ ), I've come to the conclusion that we'll need to revert the Client initializer back to injecting the HTTPClient.
Their recommendations are as follows:
Generally, we would advise creating a single HTTPClient on startup and shutting it down on application close. Automatically shutting it down in deinit leads to patterns where users create HTTPClients over and over which is bad performance-wise since the underlying connection pool can not be shared over multiple executions.