Skip to content

Commit bb65408

Browse files
committed
Update for Swift 5.5
1 parent 936337a commit bb65408

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

Package.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ let package = Package(
2424
.byName(name: "AWSLambdaRuntimeCore"),
2525
.product(name: "NIO", package: "swift-nio"),
2626
.product(name: "NIOFoundationCompat", package: "swift-nio"),
27-
], swiftSettings: [.unsafeFlags(["-Xfrontend", "-enable-experimental-concurrency"])]),
27+
]),
2828
.target(name: "AWSLambdaRuntimeCore", dependencies: [
2929
.product(name: "Logging", package: "swift-log"),
3030
.product(name: "Backtrace", package: "swift-backtrace"),
3131
.product(name: "NIOHTTP1", package: "swift-nio"),
32-
], swiftSettings: [.unsafeFlags(["-Xfrontend", "-enable-experimental-concurrency"])]),
32+
]),
3333
.testTarget(name: "AWSLambdaRuntimeCoreTests", dependencies: [
3434
.byName(name: "AWSLambdaRuntimeCore"),
3535
.product(name: "NIOTestUtils", package: "swift-nio"),
@@ -38,7 +38,7 @@ let package = Package(
3838
.testTarget(name: "AWSLambdaRuntimeTests", dependencies: [
3939
.byName(name: "AWSLambdaRuntimeCore"),
4040
.byName(name: "AWSLambdaRuntime"),
41-
], swiftSettings: [.unsafeFlags(["-Xfrontend", "-enable-experimental-concurrency"])]),
41+
]),
4242
.target(name: "AWSLambdaEvents", dependencies: []),
4343
.testTarget(name: "AWSLambdaEventsTests", dependencies: ["AWSLambdaEvents"]),
4444
// testing helper

Sources/AWSLambdaRuntime/Lambda+Codable.swift

+4-5
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,11 @@ internal struct CodableVoidClosureWrapper<In: Decodable>: LambdaHandler {
8080

8181
// MARK: - Async
8282

83-
#if compiler(>=5.4) && $AsyncAwait
83+
#if compiler(>=5.5) && $AsyncAwait
8484
extension Lambda {
85-
8685
/// An async Lambda Closure that takes a `In: Decodable` and returns an `Out: Encodable`
8786
public typealias CodableAsyncClosure<In: Decodable, Out: Encodable> = (Lambda.Context, In) async throws -> Out
88-
87+
8988
/// Run a Lambda defined by implementing the `CodableAsyncClosure` function.
9089
///
9190
/// - parameters:
@@ -97,7 +96,7 @@ extension Lambda {
9796
}
9897

9998
/// An asynchronous Lambda Closure that takes a `In: Decodable` and returns nothing.
100-
public typealias CodableVoidAsyncClosure<In: Decodable> = (Lambda.Context, In) async throws -> ()
99+
public typealias CodableVoidAsyncClosure<In: Decodable> = (Lambda.Context, In) async throws -> Void
101100

102101
/// Run a Lambda defined by implementing the `CodableVoidAsyncClosure` function.
103102
///
@@ -135,7 +134,7 @@ internal struct CodableVoidAsyncWrapper<In: Decodable>: AsyncLambdaHandler {
135134
self.closure = closure
136135
}
137136

138-
func handle(context: Lambda.Context, event: In) async throws -> Void {
137+
func handle(context: Lambda.Context, event: In) async throws {
139138
try await self.closure(context, event)
140139
}
141140
}

Sources/AWSLambdaRuntimeCore/Lambda.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public enum Lambda {
5555
fatalError("\(error)")
5656
}
5757
}
58-
59-
#if compiler(>=5.4) && $AsyncAwait
58+
59+
#if compiler(>=5.5) && $AsyncAwait
6060
public static func run(_ factory: @escaping (InitializationContext) async throws -> Handler) {
6161
self.run { context -> EventLoopFuture<Handler> in
6262
@asyncHandler func _createLambda(_ context: InitializationContext, promise: EventLoopPromise<Handler>) {
@@ -67,7 +67,7 @@ public enum Lambda {
6767
promise.fail(error)
6868
}
6969
}
70-
70+
7171
let promise = context.eventLoop.makePromise(of: Handler.self)
7272
_createLambda(context, promise: promise)
7373
return promise.futureResult

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ extension LambdaHandler {
8585

8686
// MARK: - AsyncLambdaHandler
8787

88-
#if compiler(>=5.4) && $AsyncAwait
88+
#if compiler(>=5.5) && $AsyncAwait
8989
/// Strongly typed, processing protocol for a Lambda that takes a user defined `In` and returns a user defined `Out` async.
9090
public protocol AsyncLambdaHandler: EventLoopLambdaHandler {
91-
9291
/// The Lambda handling method
9392
/// Concrete Lambda handlers implement this method to provide the Lambda functionality.
9493
///
@@ -106,7 +105,7 @@ extension AsyncLambdaHandler {
106105
self._run(context: context, event: event, promise: promise)
107106
return promise.futureResult
108107
}
109-
108+
110109
@asyncHandler private func _run(context: Lambda.Context, event: In, promise: EventLoopPromise<Out>) {
111110
do {
112111
let result = try await handle(context: context, event: event)

Tests/AWSLambdaRuntimeTests/Lambda+CodeableTest.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ class CodableLambdaTest: XCTestCase {
6262
XCTAssertNoThrow(response = try JSONDecoder().decode(Response.self, from: XCTUnwrap(outputBuffer)))
6363
XCTAssertEqual(response?.requestId, request.requestId)
6464
}
65-
66-
#if compiler(>=5.4) && $AsyncAwait
65+
66+
#if compiler(>=5.5) && $AsyncAwait
6767
func testCodableVoidAsyncWrapper() {
6868
let request = Request(requestId: UUID().uuidString)
6969
var inputBuffer: ByteBuffer?
7070
var outputBuffer: ByteBuffer?
7171

72-
let closureWrapper = CodableVoidAsyncWrapper { (context, req: Request) in
72+
let closureWrapper = CodableVoidAsyncWrapper { (_, req: Request) in
7373
XCTAssertEqual(request, req)
7474
}
7575

@@ -84,7 +84,7 @@ class CodableLambdaTest: XCTestCase {
8484
var outputBuffer: ByteBuffer?
8585
var response: Response?
8686

87-
let closureWrapper = CodableAsyncWrapper { (context, req: Request) -> Response in
87+
let closureWrapper = CodableAsyncWrapper { (_, req: Request) -> Response in
8888
XCTAssertEqual(req, request)
8989
return Response(requestId: req.requestId)
9090
}

0 commit comments

Comments
 (0)