http client event loop cleanup (#3)

motivation: EventLoop is also an EventLoopGroup, no need in wrapping

changes: remove SingleEventLoopGroup wrapper, use EventLoop directly
This commit is contained in:
Tom Doron
2018-11-15 13:49:32 -08:00
committed by tomer doron
parent 6c9c1616d0
commit 39b0140b80
+1 -15
View File
@@ -38,7 +38,7 @@ internal class HTTPClient {
}
func execute(_ request: HTTPRequest) -> EventLoopFuture<HTTPResponse> {
let bootstrap = ClientBootstrap(group: SingleEventLoopGroup(eventLoop))
let bootstrap = ClientBootstrap(group: eventLoop)
.channelOption(ChannelOptions.socket(SocketOptionLevel(IPPROTO_TCP), TCP_NODELAY), value: 1)
.channelInitializer { channel in
channel.pipeline.addHTTPClientHandlers().then {
@@ -246,20 +246,6 @@ private class UnaryHTTPHandler: ChannelInboundHandler, ChannelOutboundHandler {
}
}
// TODO: is there a more elegant way to bootstrap?
private class SingleEventLoopGroup: EventLoopGroup {
let eventLoop: EventLoop
public init(_ eventLoop: EventLoop) {
self.eventLoop = eventLoop
}
func next() -> EventLoop {
return eventLoop
}
func shutdownGracefully(queue _: DispatchQueue, _: @escaping (Error?) -> Void) {}
}
private enum HTTPClientError: Error {
case invalidRequest
}