Skip to content

Conversation

adam-fowler
Copy link
Member

Add async shutdown method to LambdaHandler protocol

Motivation:

LambdaHandler provides async interfaces for init and handle but not shutdown

Modifications:

  • Add protocol requirement shutdown(context: Lambda.ShutdownContext) async throws to LambdaHandler
  • Add default version that does nothing in extension
  • Override ByteBufferLambdaHandler.shutdown to call the async version from LambdaHandler in extension

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()
    }
}

@adam-fowler adam-fowler requested a review from fabianfett March 31, 2022 13:07
@fabianfett
Copy link
Member

fabianfett commented Apr 11, 2022

I think we should add the async methods directly to the replacement for the shutdown methods in: #251

@tomerd
Copy link
Contributor

tomerd commented Apr 11, 2022

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

@adam-fowler
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants