mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-06-02 07:27:33 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user