Skip to content

Commit 1b7e97e

Browse files
committed
review fixes: make preference argument not explicit and add precondition that EL must be part of ELG
1 parent 1036075 commit 1b7e97e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Sources/AsyncHTTPClient/HTTPClient.swift

+7-2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public class HTTPClient {
206206
case .indifferent:
207207
return self.execute(request: request, delegate: delegate, eventLoop: self.eventLoopGroup.next(), deadline: deadline)
208208
case .prefers(let preferred):
209+
precondition(self.eventLoopGroup.makeIterator().contains { $0 === preferred }, "Provided EventLoop must be part of clients EventLoopGroup.")
209210
return self.execute(request: request, delegate: delegate, eventLoop: preferred, deadline: deadline)
210211
}
211212
}
@@ -353,11 +354,15 @@ public class HTTPClient {
353354

354355
var preference: Preference
355356

357+
init(_ preference: Preference) {
358+
self.preference = preference
359+
}
360+
356361
/// Event Loop will be selected by the library.
357-
public static let indifferent = EventLoopPreference(preference: .indifferent)
362+
public static let indifferent = EventLoopPreference(.indifferent)
358363
/// Library will try to use provided event loop if possible.
359364
public static func prefers(_ eventLoop: EventLoop) -> EventLoopPreference {
360-
return EventLoopPreference(preference: .prefers(eventLoop))
365+
return EventLoopPreference(.prefers(eventLoop))
361366
}
362367
}
363368

0 commit comments

Comments
 (0)