Closed
Description
In a non-trivial Lambda we might use an AHC, which we initialize with a factory method like this:
class MyLambdaHandler: EventLoopLambdaHandler {
typealias In = SQS.Event
typealias Out = Void
let httpClient: HTTPClient
static func create(_ eventLoop: EventLoop) -> EventLoopFuture<ByteBufferLambdaHandler> {
let httpClient = HTTPClient(eventLoopGroupProvider: .shared(eventLoop))
return eventLoop.makeSucceededFuture(MyLambdaHandler(httpClient: httpClient))
}
private init(httpClient: HTTPClient) {
self.httpClient = httpClient
}
func handle(context: Lambda.Context, payload: SQS.Event) -> EventLoopFuture<Void> {
// not interesting
}
}
Lambda.run(MyLambdaHandler.create)
We currently don't have any chance to stop the httpClient
in a coordinated way, if we stop the LocalTestServer
, which closes the Lambda.
This is why I propose the following:
We expand the ByteBufferLambdaHandler
protocol with a function syncShutdown() throws
which will be invoked, if the Lambda is stopped. We supply a default empty implementation so that developers only need to deal with it if they run into a problem.
@tomerd @weissi @ktoso @adam-fowler wdyt?
Metadata
Metadata
Assignees
Labels
No labels