@@ -19,10 +19,10 @@ import OpenAPIRuntime
19
19
import HTTPTypes
20
20
21
21
/// A Lambda function implemented with a OpenAPI server (implementing `APIProtocol` from Swift OpenAPIRuntime)
22
- public protocol OpenAPILambda {
22
+ public protocol OpenAPILambda : Sendable {
23
23
24
- associatedtype Event : Decodable
25
- associatedtype Output : Encodable
24
+ associatedtype Event : Decodable , Sendable
25
+ associatedtype Output : Encodable , Sendable
26
26
27
27
/// Initialize application.
28
28
///
@@ -51,27 +51,8 @@ extension OpenAPILambda {
51
51
/// when one is given.
52
52
/// - Parameter logger: The logger to use for Lambda runtime logging
53
53
public static func run( logger: Logger ? = nil ) async throws {
54
-
55
54
let _logger = logger ?? Logger ( label: " OpenAPILambda " )
56
- #if swift(>=6.2)
57
- let box = UnsafeTransferBox ( value: try Self . handler ( ) )
58
- let lambdaRuntime = LambdaRuntime ( logger: _logger, body: box. value)
59
- #else
60
- let lambdaHandler = try Self . handler ( )
61
- let lambdaRuntime = LambdaRuntime ( logger: _logger, body: lambdaHandler)
62
- #endif
55
+ let lambdaRuntime = LambdaRuntime ( logger: _logger, body: try Self . handler ( ) )
63
56
try await lambdaRuntime. run ( )
64
57
}
65
58
}
66
-
67
- // on Swift 6.2, with approachable concurrency, the compiler considers
68
- // the `lambdaHandler` can not be sent to the `LambdaRuntime(body:)` directly
69
- // despite the fact `lambdaHandler` is not used after the call.
70
- // There are two workarounds:
71
- // - make `OpenAPILambda` conform to `Sendable`. But this would require users to ensure their implementations are also `Sendable`
72
- // - wrap the handler in a `UnsafeTransferBox`
73
- #if swift(>=6.2)
74
- private struct UnsafeTransferBox < Value> : @unchecked Sendable {
75
- let value : Value
76
- }
77
- #endif
0 commit comments