Skip to content

Commit 2624578

Browse files
committed
cleanup
1 parent 17ed17b commit 2624578

File tree

13 files changed

+17
-38
lines changed

13 files changed

+17
-38
lines changed

Package.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
// swift-tools-version:5.6
1+
// swift-tools-version:5.7
22

33
import PackageDescription
44

55
let package = Package(
66
name: "swift-aws-lambda-runtime",
7+
platforms: [
8+
.macOS(.v12),
9+
.iOS(.v15),
10+
.tvOS(.v15),
11+
.watchOS(.v8)
12+
],
713
products: [
814
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
915
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),
@@ -15,7 +21,7 @@ let package = Package(
1521
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
1622
],
1723
dependencies: [
18-
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.33.0")),
24+
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.43.1")),
1925
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.2")),
2026
.package(url: "https://github.com/swift-server/swift-backtrace.git", .upToNextMajor(from: "1.2.3")),
2127
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),

Sources/AWSLambdaRuntime/Lambda+Codable.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import NIOFoundationCompat
2222
// MARK: - LambdaHandler Codable support
2323

2424
/// Implementation of `ByteBuffer` to `Event` decoding.
25-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
2625
extension LambdaHandler where Event: Decodable {
2726
@inlinable
2827
public func decode(buffer: ByteBuffer) throws -> Event {
@@ -31,7 +30,6 @@ extension LambdaHandler where Event: Decodable {
3130
}
3231

3332
/// Implementation of `Output` to `ByteBuffer` encoding.
34-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
3533
extension LambdaHandler where Output: Encodable {
3634
@inlinable
3735
public func encode(value: Output, into buffer: inout ByteBuffer) throws {
@@ -41,7 +39,6 @@ extension LambdaHandler where Output: Encodable {
4139

4240
/// Default `ByteBuffer` to `Event` decoder using Foundation's `JSONDecoder`.
4341
/// Advanced users who want to inject their own codec can do it by overriding these functions.
44-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
4542
extension LambdaHandler where Event: Decodable {
4643
public var decoder: LambdaCodableDecoder {
4744
Lambda.defaultJSONDecoder
@@ -50,7 +47,6 @@ extension LambdaHandler where Event: Decodable {
5047

5148
/// Default `Output` to `ByteBuffer` encoder using Foundation's `JSONEncoder`.
5249
/// Advanced users who want to inject their own codec can do it by overriding these functions.
53-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
5450
extension LambdaHandler where Output: Encodable {
5551
public var encoder: LambdaCodableEncoder {
5652
Lambda.defaultJSONEncoder

Sources/AWSLambdaRuntimeCore/Lambda+String.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import NIOCore
1515

1616
// MARK: - LambdaHandler String support
1717

18-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
1918
extension LambdaHandler where Event == String {
2019
/// Implementation of a `ByteBuffer` to `String` decoding.
2120
@inlinable
@@ -27,7 +26,6 @@ extension LambdaHandler where Event == String {
2726
}
2827
}
2928

30-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
3129
extension LambdaHandler where Output == String {
3230
/// Implementation of `String` to `ByteBuffer` encoding.
3331
@inlinable

Sources/AWSLambdaRuntimeCore/Lambda.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public enum Lambda {
3434
///
3535
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
3636

37-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
3837
internal static func run<Handler: LambdaHandler>(
3938
configuration: LambdaConfiguration = .init(),
4039
handlerType: Handler.Type
@@ -60,7 +59,7 @@ public enum Lambda {
6059

6160
var result: Result<Int, Error>!
6261
MultiThreadedEventLoopGroup.withCurrentThreadAsEventLoop { eventLoop in
63-
let runtime = LambdaRuntime(handlerType, eventLoop: eventLoop, logger: logger, configuration: configuration)
62+
let runtime = LambdaRuntime(handlerType: handlerType, eventLoop: eventLoop, logger: logger, configuration: configuration)
6463
#if DEBUG
6564
let signalSource = trap(signal: configuration.lifecycle.stopSignal) { signal in
6665
logger.info("intercepted signal: \(signal)")

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,10 @@ import NIOCore
2323
///
2424
/// - note: Most users should implement the ``LambdaHandler`` protocol instead
2525
/// which defines the Lambda initialization method.
26-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
2726
public protocol SimpleLambdaHandler: LambdaHandler {
2827
init()
2928
}
3029

31-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
3230
extension SimpleLambdaHandler {
3331
public init(context: LambdaInitializationContext) async throws {
3432
self.init()
@@ -44,7 +42,6 @@ extension SimpleLambdaHandler {
4442
/// - note: Most users should implement this protocol instead of the lower
4543
/// level protocols ``EventLoopLambdaHandler`` and
4644
/// ``ByteBufferLambdaHandler``.
47-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
4845
public protocol LambdaHandler {
4946
/// The lambda function's input. In most cases this should be `Codable`. If your event originates from an
5047
/// AWS service, have a look at [AWSLambdaEvents](https://github.com/swift-server/swift-aws-lambda-events),
@@ -90,7 +87,6 @@ public protocol LambdaHandler {
9087
func decode(buffer: ByteBuffer) throws -> Event
9188
}
9289

93-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
9490
final class CodableLambdaHandler<Underlying: LambdaHandler>: ByteBufferLambdaHandler {
9591
private let handler: Underlying
9692
private var outputBuffer: ByteBuffer
@@ -137,13 +133,11 @@ final class CodableLambdaHandler<Underlying: LambdaHandler>: ByteBufferLambdaHan
137133
}
138134

139135
/// Implementation of `ByteBuffer` to `Void` decoding.
140-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
141136
extension LambdaHandler where Output == Void {
142137
@inlinable
143138
public func encode(value: Output, into buffer: inout ByteBuffer) throws {}
144139
}
145140

146-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
147141
extension LambdaHandler {
148142
/// Initializes and runs the Lambda function.
149143
///
@@ -161,7 +155,6 @@ extension LambdaHandler {
161155
/// unchecked sendable wrapper for the handler
162156
/// this is safe since lambda runtime is designed to calls the handler serially
163157
@usableFromInline
164-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
165158
internal struct UncheckedSendableHandler<Underlying: LambdaHandler, Event, Output>: @unchecked Sendable where Event == Underlying.Event, Output == Underlying.Output {
166159
@usableFromInline
167160
let underlying: Underlying

Sources/AWSLambdaRuntimeCore/LambdaRunner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ internal final class LambdaRunner {
6060
}
6161
}
6262

63-
func run(logger: Logger, handler: any ByteBufferLambdaHandler) -> EventLoopFuture<Void> {
63+
func run(handler: any ByteBufferLambdaHandler, logger: Logger) -> EventLoopFuture<Void> {
6464
logger.debug("lambda invocation sequence starting")
6565
// 1. request invocation from lambda runtime engine
6666
self.isGettingNextInvocation = true

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public final class LambdaRuntime {
4040
/// - handlerType: The ``LambdaHandler`` type the `LambdaRuntime` shall create and manage.
4141
/// - eventLoop: An `EventLoop` to run the Lambda on.
4242
/// - logger: A `Logger` to log the Lambda events.
43-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
4443
public convenience init<Handler: LambdaHandler>(_ handlerType: Handler.Type, eventLoop: EventLoop, logger: Logger) {
4544
self.init(CodableLambdaHandler<Handler>.self, eventLoop: eventLoop, logger: logger)
4645
}
@@ -62,10 +61,10 @@ public final class LambdaRuntime {
6261
/// - eventLoop: An `EventLoop` to run the Lambda on.
6362
/// - logger: A `Logger` to log the Lambda events.
6463
public convenience init(_ handlerType: (some ByteBufferLambdaHandler).Type, eventLoop: EventLoop, logger: Logger) {
65-
self.init(handlerType, eventLoop: eventLoop, logger: logger, configuration: .init())
64+
self.init(handlerType: handlerType, eventLoop: eventLoop, logger: logger, configuration: .init())
6665
}
6766

68-
init(_ handlerType: (some ByteBufferLambdaHandler).Type, eventLoop: EventLoop, logger: Logger, configuration: LambdaConfiguration) {
67+
init(handlerType: (some ByteBufferLambdaHandler).Type, eventLoop: EventLoop, logger: Logger, configuration: LambdaConfiguration) {
6968
self.eventLoop = eventLoop
7069
self.shutdownPromise = eventLoop.makePromise(of: Int.self)
7170
self.logger = logger
@@ -165,7 +164,7 @@ public final class LambdaRuntime {
165164
}
166165
var logger = self.logger
167166
logger[metadataKey: "lifecycleIteration"] = "\(count)"
168-
runner.run(logger: logger, handler: handler).whenComplete { result in
167+
runner.run(handler: handler, logger: logger).whenComplete { result in
169168
switch result {
170169
case .success:
171170
logger.log(level: .debug, "lambda invocation sequence completed successfully")

Sources/AWSLambdaTesting/Lambda+Testing.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ import Logging
3939
import NIOCore
4040
import NIOPosix
4141

42-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
4342
extension Lambda {
4443
public struct TestConfig {
4544
public var requestID: String

Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import XCTest
1919
class LambdaHandlerTest: XCTestCase {
2020
// MARK: - SimpleLambdaHandler
2121

22-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
2322
func testBootstrapSimpleNoInit() {
2423
let server = MockLambdaServer(behavior: Behavior())
2524
XCTAssertNoThrow(try server.start().wait())
@@ -37,7 +36,6 @@ class LambdaHandlerTest: XCTestCase {
3736
assertLambdaRuntimeResult(result, shouldHaveRun: maxTimes)
3837
}
3938

40-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
4139
func testBootstrapSimpleInit() {
4240
let server = MockLambdaServer(behavior: Behavior())
4341
XCTAssertNoThrow(try server.start().wait())
@@ -64,7 +62,6 @@ class LambdaHandlerTest: XCTestCase {
6462

6563
// MARK: - LambdaHandler
6664

67-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
6865
func testBootstrapSuccess() {
6966
let server = MockLambdaServer(behavior: Behavior())
7067
XCTAssertNoThrow(try server.start().wait())
@@ -90,7 +87,6 @@ class LambdaHandlerTest: XCTestCase {
9087
assertLambdaRuntimeResult(result, shouldHaveRun: maxTimes)
9188
}
9289

93-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
9490
func testBootstrapFailure() {
9591
let server = MockLambdaServer(behavior: FailedBootstrapBehavior())
9692
XCTAssertNoThrow(try server.start().wait())
@@ -116,7 +112,6 @@ class LambdaHandlerTest: XCTestCase {
116112
assertLambdaRuntimeResult(result, shouldFailWithError: TestError("kaboom"))
117113
}
118114

119-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
120115
func testHandlerSuccess() {
121116
let server = MockLambdaServer(behavior: Behavior())
122117
XCTAssertNoThrow(try server.start().wait())
@@ -134,7 +129,6 @@ class LambdaHandlerTest: XCTestCase {
134129
assertLambdaRuntimeResult(result, shouldHaveRun: maxTimes)
135130
}
136131

137-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
138132
func testVoidHandlerSuccess() {
139133
let server = MockLambdaServer(behavior: Behavior(result: .success(nil)))
140134
XCTAssertNoThrow(try server.start().wait())
@@ -151,7 +145,6 @@ class LambdaHandlerTest: XCTestCase {
151145
assertLambdaRuntimeResult(result, shouldHaveRun: maxTimes)
152146
}
153147

154-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
155148
func testHandlerFailure() {
156149
let server = MockLambdaServer(behavior: Behavior(result: .failure(TestError("boom"))))
157150
XCTAssertNoThrow(try server.start().wait())

Tests/AWSLambdaRuntimeCoreTests/LambdaTest.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,15 +279,15 @@ class LambdaTest: XCTestCase {
279279
let runner = LambdaRunner(eventLoop: eventLoopGroup.next(), configuration: configuration)
280280

281281
try runner.run(
282-
logger: logger,
283282
handler: CodableEventLoopLambdaHandler(
284283
handler: handler1,
285284
allocator: ByteBufferAllocator()
286-
)
285+
),
286+
logger: logger
287287
).wait()
288288

289289
try runner.initialize(handlerType: CodableEventLoopLambdaHandler<Handler>.self, logger: logger, terminator: LambdaTerminator()).flatMap { handler2 in
290-
runner.run(logger: logger, handler: handler2)
290+
runner.run(handler: handler2, logger: logger)
291291
}.wait()
292292
}
293293

Tests/AWSLambdaRuntimeCoreTests/Utils.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import NIOCore
1818
import NIOPosix
1919
import XCTest
2020

21-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
2221
func runLambda<Handler: LambdaHandler>(behavior: LambdaServerBehavior, handlerType: Handler.Type) throws {
2322
try runLambda(behavior: behavior, handlerType: CodableLambdaHandler<Handler>.self)
2423
}
@@ -37,7 +36,7 @@ func runLambda(behavior: LambdaServerBehavior, handlerType: (some ByteBufferLamb
3736
let server = try MockLambdaServer(behavior: behavior).start().wait()
3837
defer { XCTAssertNoThrow(try server.stop().wait()) }
3938
try runner.initialize(handlerType: handlerType, logger: logger, terminator: terminator).flatMap { handler in
40-
runner.run(logger: logger, handler: handler)
39+
runner.run(handler: handler, logger: logger)
4140
}.wait()
4241
}
4342

Tests/AWSLambdaRuntimeTests/Lambda+CodableTest.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ class CodableLambdaTest: XCTestCase {
9292
XCTAssertEqual(response?.requestId, request.requestId)
9393
}
9494

95-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
9695
func testCodableVoidHandler() async throws {
9796
struct Handler: SimpleLambdaHandler {
9897
var expected: Request?
@@ -119,7 +118,6 @@ class CodableLambdaTest: XCTestCase {
119118
XCTAssertEqual(outputBuffer?.readableBytes, 0)
120119
}
121120

122-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
123121
func testCodableHandler() async throws {
124122
struct Handler: SimpleLambdaHandler {
125123
var expected: Request?

Tests/AWSLambdaTestingTests/Tests.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import AWSLambdaTesting
1717
import NIOCore
1818
import XCTest
1919

20-
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
2120
class LambdaTestingTests: XCTestCase {
2221
func testBasics() async throws {
2322
struct MyLambda: SimpleLambdaHandler {

0 commit comments

Comments
 (0)