mirror of
https://github.com/swift-server/swift-aws-lambda-runtime.git
synced 2026-06-02 07:27:33 +00:00
Allow `LambdaChannelHandler.nextInvocation` to be cancelled. ### Motivation: If we want to use ServiceLifecycle with the lambda runtime the lambda runtime needs to be cancellable either via a ServiceLifecycle graceful shutdown or via Task cancellation. To avoid bringing in the ServiceLifecycle dependency this PR adds cancellation via Task cancellation handler. ### Modifications: Add `withTaskCancellationHandler` to nextInvocation which calls close on cancel. In `LambdaChannelHandler.channelInactive` resume continuation if state is `waitingForNextInvocation` Added `LambdaRuntimeClientTests.testCancellation` ### Result: You can now cancel the runtime while it is waiting for the next invocation. --------- Co-authored-by: Fabian Fett <fabianfett@apple.com> Co-authored-by: Sébastien Stormacq <sebastien.stormacq@gmail.com>