Skip to content

Commit f2d65a1

Browse files
committed
http client event loop cleanup (#3)
motivation: EventLoop is also an EventLoopGroup, no need in wrapping changes: remove SingleEventLoopGroup wrapper, use EventLoop directly
1 parent fb2e551 commit f2d65a1

File tree

1 file changed

+1
-15
lines changed

1 file changed

+1
-15
lines changed

Sources/SwiftAwsLambda/HttpClient.swift

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal class HTTPClient {
3838
}
3939

4040
func execute(_ request: HTTPRequest) -> EventLoopFuture<HTTPResponse> {
41-
let bootstrap = ClientBootstrap(group: SingleEventLoopGroup(eventLoop))
41+
let bootstrap = ClientBootstrap(group: eventLoop)
4242
.channelOption(ChannelOptions.socket(SocketOptionLevel(IPPROTO_TCP), TCP_NODELAY), value: 1)
4343
.channelInitializer { channel in
4444
channel.pipeline.addHTTPClientHandlers().then {
@@ -246,20 +246,6 @@ private class UnaryHTTPHandler: ChannelInboundHandler, ChannelOutboundHandler {
246246
}
247247
}
248248

249-
// TODO: is there a more elegant way to bootstrap?
250-
private class SingleEventLoopGroup: EventLoopGroup {
251-
let eventLoop: EventLoop
252-
public init(_ eventLoop: EventLoop) {
253-
self.eventLoop = eventLoop
254-
}
255-
256-
func next() -> EventLoop {
257-
return eventLoop
258-
}
259-
260-
func shutdownGracefully(queue _: DispatchQueue, _: @escaping (Error?) -> Void) {}
261-
}
262-
263249
private enum HTTPClientError: Error {
264250
case invalidRequest
265251
}

0 commit comments

Comments
 (0)