Skip to content

Commit c80f7c7

Browse files
committed
fixup
1 parent 39da6d9 commit c80f7c7

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

+16-2
Original file line numberDiff line numberDiff line change
@@ -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

Sources/AWSLambdaRuntimeCore/Sendable.swift

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@
1414

1515
// Sendable bridging types
1616

17-
#if compiler(>=5.6)
18-
@preconcurrency public protocol _ByteBufferLambdaHandlerSendable: Sendable {}
19-
#else
20-
public protocol _ByteBufferLambdaHandlerSendable {}
21-
#endif
22-
2317
#if compiler(>=5.6)
2418
public typealias _AWSLambdaSendable = Sendable
2519
#else

docker/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
1515

1616
# swiftformat (until part of the toolchain)
1717

18-
ARG swiftformat_version=0.49.6
18+
ARG swiftformat_version=0.47.3
1919
RUN git clone --branch $swiftformat_version --depth 1 https://github.com/nicklockwood/SwiftFormat $HOME/.tools/swift-format
2020
RUN cd $HOME/.tools/swift-format && swift build -c release
2121
RUN ln -s $HOME/.tools/swift-format/.build/release/swiftformat $HOME/.tools/swiftformat

0 commit comments

Comments
 (0)