@@ -58,13 +58,27 @@ extension LambdaHandler {
5858
5959 public func handle( _ event: Event , context: LambdaContext ) -> EventLoopFuture < Output > {
6060 let promise = context. eventLoop. makePromise ( of: Output . self)
61+ let handler = SendableHandler ( underlying: self )
6162 promise. completeWithTask {
62- try await self . handle ( event, context: context)
63+ try await handler . handle ( event, context: context)
6364 }
6465 return promise. futureResult
6566 }
6667}
6768
69+ @available ( macOS 12 , iOS 15 , tvOS 15 , watchOS 8 , * )
70+ fileprivate struct SendableHandler < Underlying: LambdaHandler > : @unchecked Sendable {
71+ let underlying : Underlying
72+
73+ init ( underlying: Underlying ) {
74+ self . underlying = underlying
75+ }
76+
77+ func handle( _ event: Underlying . Event , context: LambdaContext ) async throws -> Underlying . Output {
78+ try await self . underlying. handle ( event, context: context)
79+ }
80+ }
81+
6882#endif
6983
7084// MARK: - EventLoopLambdaHandler
@@ -157,7 +171,7 @@ extension EventLoopLambdaHandler where Output == Void {
157171/// - note: This is a low level protocol designed to power the higher level ``EventLoopLambdaHandler`` and
158172/// ``LambdaHandler`` based APIs.
159173/// Most users are not expected to use this protocol.
160- public protocol ByteBufferLambdaHandler : _ByteBufferLambdaHandlerSendable {
174+ public protocol ByteBufferLambdaHandler {
161175 /// Create your Lambda handler for the runtime.
162176 ///
163177 /// Use this to initialize all your resources that you want to cache between invocations. This could be database
0 commit comments