swift-server / swift-aws-lambda-runtime

Swift implementation of AWS Lambda Runtime
Apache License 2.0
1.14k stars 104 forks source link

Add async LambdaHandler.shutdown #255

Closed adam-fowler closed 2 years ago

adam-fowler commented 2 years ago

Add async shutdown method to LambdaHandler protocol

Motivation:

LambdaHandler provides async interfaces for init and handle but not shutdown

Modifications:

Result:

Can shutdown LambdaHandler using async methods eg

final class MyLambda: LambdaHandler {
    init(context: Lambda.InitializationContext) {
        self.httpClient = HTTPClient(eventLoopGroupProvider: .shared(context.eventLoop))
    }

    func shutdown(context: Lambda.ShutdownContext) async throws {
        try await self.httpClient.shutdown()
    }
}
fabianfett commented 2 years ago

I think we should add the async methods directly to the replacement for the shutdown methods in: https://github.com/swift-server/swift-aws-lambda-runtime/pull/251

tomerd commented 2 years ago

agree with @fabianfett, lets get #251 over the finish line.

adam-fowler commented 2 years ago

Ok. I'm happy to close this in favour of #251 getting the async support