You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-14
Original file line number
Diff line number
Diff line change
@@ -27,14 +27,10 @@ and `AsyncHTTPClient` dependency to your target:
27
27
28
28
The code snippet below illustrates how to make a simple GET request to a remote server.
29
29
30
-
Please note that the example will spawn a new `EventLoopGroup` which will _create fresh threads_ which is a very costly operation. In a real-world application that uses [SwiftNIO](https://github.com/apple/swift-nio) for other parts of your application (for example a web server), please prefer `eventLoopGroupProvider: .shared(myExistingEventLoopGroup)` to share the `EventLoopGroup` used by AsyncHTTPClient with other parts of your application.
31
-
32
-
If your application does not use SwiftNIO yet, it is acceptable to use `eventLoopGroupProvider: .createNew` but please make sure to share the returned `HTTPClient` instance throughout your whole application. Do not create a large number of `HTTPClient` instances with `eventLoopGroupProvider: .createNew`, this is very wasteful and might exhaust the resources of your program.
33
-
34
30
```swift
35
31
importAsyncHTTPClient
36
32
37
-
let httpClient =HTTPClient(eventLoopGroupProvider: .createNew)
33
+
let httpClient =HTTPClient(eventLoopGroupProvider: .singleton)
38
34
39
35
/// MARK: - Using Swift Concurrency
40
36
let request =HTTPClientRequest(url: "https://apple.com/")
@@ -78,7 +74,7 @@ The default HTTP Method is `GET`. In case you need to have more control over the
78
74
```swift
79
75
importAsyncHTTPClient
80
76
81
-
let httpClient =HTTPClient(eventLoopGroupProvider: .createNew)
77
+
let httpClient =HTTPClient(eventLoopGroupProvider: .singleton)
82
78
do {
83
79
var request =HTTPClientRequest(url: "https://apple.com/")
Copy file name to clipboardExpand all lines: Sources/AsyncHTTPClient/Docs.docc/index.md
+34-15
Original file line number
Diff line number
Diff line change
@@ -31,14 +31,13 @@ and `AsyncHTTPClient` dependency to your target:
31
31
32
32
The code snippet below illustrates how to make a simple GET request to a remote server.
33
33
34
-
Please note that the example will spawn a new `EventLoopGroup` which will _create fresh threads_ which is a very costly operation. In a real-world application that uses [SwiftNIO](https://github.com/apple/swift-nio) for other parts of your application (for example a web server), please prefer `eventLoopGroupProvider: .shared(myExistingEventLoopGroup)` to share the `EventLoopGroup` used by AsyncHTTPClient with other parts of your application.
35
-
36
-
If your application does not use SwiftNIO yet, it is acceptable to use `eventLoopGroupProvider: .createNew` but please make sure to share the returned `HTTPClient` instance throughout your whole application. Do not create a large number of `HTTPClient` instances with `eventLoopGroupProvider: .createNew`, this is very wasteful and might exhaust the resources of your program.
37
-
38
34
```swift
39
35
importAsyncHTTPClient
40
36
41
-
let httpClient =HTTPClient(eventLoopGroupProvider: .createNew)
37
+
let httpClient =HTTPClient(eventLoopGroupProvider: .singleton)
38
+
defer {
39
+
try! httpClient.shutdown().wait()
40
+
}
42
41
43
42
/// MARK: - Using Swift Concurrency
44
43
let request =HTTPClientRequest(url: "https://apple.com/")
@@ -82,7 +81,11 @@ The default HTTP Method is `GET`. In case you need to have more control over the
82
81
```swift
83
82
importAsyncHTTPClient
84
83
85
-
let httpClient =HTTPClient(eventLoopGroupProvider: .createNew)
84
+
let httpClient =HTTPClient(eventLoopGroupProvider: .singleton)
85
+
defer {
86
+
try! httpClient.syncShutdown()
87
+
}
88
+
86
89
do {
87
90
var request =HTTPClientRequest(url: "https://apple.com/")
0 commit comments