Skip to content

Commit 297788b

Browse files
committed
fixup
1 parent bb34ac6 commit 297788b

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import NIOCore
2626
/// level protocols ``EventLoopLambdaHandler`` and
2727
/// ``ByteBufferLambdaHandler``.
2828
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
29-
public protocol LambdaHandler: EventLoopLambdaHandler where Event: _AWSLambdaSendable {
29+
public protocol LambdaHandler: EventLoopLambdaHandler {
3030
/// The Lambda initialization method
3131
/// Use this method to initialize resources that will be used in every request.
3232
///
@@ -69,15 +69,16 @@ extension LambdaHandler {
6969
}
7070

7171
/// unchecked sendable wrapper for the handler
72+
/// this is safe since lambda runtime is designed to calls the handler serially
7273
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
73-
fileprivate struct UncheckedSendableHandler<Underlying: LambdaHandler>: @unchecked Sendable {
74+
fileprivate struct UncheckedSendableHandler<Underlying: LambdaHandler, Event, Output>: @unchecked Sendable where Event == Underlying.Event, Output == Underlying.Output {
7475
let underlying: Underlying
7576

7677
init(underlying: Underlying) {
7778
self.underlying = underlying
7879
}
7980

80-
func handle(_ event: Underlying.Event, context: LambdaContext) async throws -> Underlying.Output {
81+
func handle(_ event: Event, context: LambdaContext) async throws -> Output {
8182
try await self.underlying.handle(event, context: context)
8283
}
8384
}

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,3 @@ public final class LambdaRuntime<Handler: ByteBufferLambdaHandler> {
189189
}
190190
}
191191
}
192-
193-
// TODO: ideally this would not be @unchecked Sendable, but Sendable checks do not understand locks
194-
#if compiler(>=5.5) && canImport(_Concurrency)
195-
extension LambdaRuntime: @unchecked Sendable {}
196-
#endif

Sources/AWSLambdaRuntimeCore/Terminator.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ extension LambdaTerminator {
138138
}
139139
}
140140

141-
// TODO: ideally this would not be @unchecked Sendable, but Sendable checks do not understand locks
141+
// Ideally this would not be @unchecked Sendable, but Sendable checks do not understand locks
142+
// We can transition this to an actor once we drop support for older Swift versions
142143
#if compiler(>=5.5) && canImport(_Concurrency)
143144
extension LambdaTerminator: @unchecked Sendable {}
144145
extension LambdaTerminator.Storage: @unchecked Sendable {}

0 commit comments

Comments
 (0)