Skip to content

Commit 70fa193

Browse files
authored
make sure HTTPClient is shutdown
Motivation: Right now, HTTPClient only asserts that it's shut down if it was started with its own EventLoopGroup. That however is weird because it's lifecycle model depends on the parameters you pass to `init`. Modifications: Always validate the lifecycle (in debug mode). Result: API makes more sense.
1 parent bbf7966 commit 70fa193

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

Sources/AsyncHTTPClient/HTTPClient.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ public class HTTPClient {
6666
}
6767

6868
deinit {
69-
switch self.eventLoopGroupProvider {
70-
case .shared:
71-
return
72-
case .createNew:
73-
assert(self.isShutdown.load(), "Client not stopped before the deinit.")
74-
}
69+
assert(self.isShutdown.load(), "Client not shut down before the deinit. Please call client.syncShutdown() when no longer needed.")
7570
}
7671

7772
/// Shuts down the client and `EventLoopGroup` if it was created by the client.

0 commit comments

Comments
 (0)