Skip to content

Commit 5e74dad

Browse files
committed
cleanup
1 parent c1aebc8 commit 5e74dad

19 files changed

+19
-229
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import PackageDescription
44

55
let package = Package(
66
name: "swift-aws-lambda-runtime",
7-
platforms: [ .macOS(.v10_15) ],
7+
platforms: [.macOS(.v10_15)],
88
products: [
99
// this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods
1010
.library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]),

Package@swift-5.5.swift

Lines changed: 0 additions & 55 deletions
This file was deleted.

Package@swift-5.6.swift

Lines changed: 0 additions & 55 deletions
This file was deleted.

Sources/AWSLambdaRuntimeCore/LambdaContext.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,17 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
#if compiler(>=5.6)
1615
@preconcurrency import Dispatch
17-
@preconcurrency import Logging
18-
@preconcurrency import NIOCore
19-
#else
20-
import Dispatch
2116
import Logging
2217
import NIOCore
23-
#endif
2418

2519
// MARK: - InitializationContext
2620

2721
/// Lambda runtime initialization context.
2822
/// The Lambda runtime generates and passes the `LambdaInitializationContext` to the Handlers
2923
/// ``ByteBufferLambdaHandler/makeHandler(context:)`` or ``LambdaHandler/init(context:)``
3024
/// as an argument.
31-
public struct LambdaInitializationContext: _AWSLambdaSendable {
25+
public struct LambdaInitializationContext: Sendable {
3226
/// `Logger` to log with.
3327
///
3428
/// - note: The `LogLevel` can be configured using the `LOG_LEVEL` environment variable.
@@ -71,8 +65,8 @@ public struct LambdaInitializationContext: _AWSLambdaSendable {
7165

7266
/// Lambda runtime context.
7367
/// The Lambda runtime generates and passes the `LambdaContext` to the Lambda handler as an argument.
74-
public struct LambdaContext: CustomDebugStringConvertible, _AWSLambdaSendable {
75-
final class _Storage: _AWSLambdaSendable {
68+
public struct LambdaContext: CustomDebugStringConvertible, Sendable {
69+
final class _Storage: Sendable {
7670
let requestID: String
7771
let traceID: String
7872
let invokedFunctionARN: String

Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ public protocol LambdaHandler {
7272

7373
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
7474
final class CodableLambdaHandler<Underlying: LambdaHandler, Event, Output>: ByteBufferLambdaHandler
75-
where Underlying.Event == Event, Underlying.Output == Output
76-
{
75+
where Underlying.Event == Event, Underlying.Output == Output {
7776
private let handler: Underlying
7877
private var outputBuffer: ByteBuffer
7978

@@ -228,15 +227,14 @@ extension EventLoopLambdaHandler where Output == Void {
228227
}
229228

230229
internal final class CodableEventLoopLambdaHandler<Underlying: EventLoopLambdaHandler, Event, Output>: ByteBufferLambdaHandler
231-
where Underlying.Event == Event, Underlying.Output == Output
232-
{
230+
where Underlying.Event == Event, Underlying.Output == Output {
233231
private let handler: Underlying
234232
private var outputBuffer: ByteBuffer
235233

236234
@inlinable
237235
static func makeHandler(context: LambdaInitializationContext) -> EventLoopFuture<CodableEventLoopLambdaHandler> {
238236
Underlying.makeHandler(context: context).map { handler -> CodableEventLoopLambdaHandler<Underlying, Event, Output> in
239-
return CodableEventLoopLambdaHandler(handler: handler, allocator: context.allocator)
237+
CodableEventLoopLambdaHandler(handler: handler, allocator: context.allocator)
240238
}
241239
}
242240

@@ -332,4 +330,3 @@ enum CodecError: Error {
332330
case responseEncoding(Error)
333331
case invalidString
334332
}
335-

Sources/AWSLambdaRuntimeCore/LambdaRunner.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ internal final class LambdaRunner {
2929
self.runtimeClient = LambdaRuntimeClient(eventLoop: self.eventLoop, configuration: configuration.runtimeEngine)
3030
self.allocator = ByteBufferAllocator()
3131
}
32-
32+
3333
/// Run the user provided initializer. This *must* only be called once.
3434
///
3535
/// - Returns: An `EventLoopFuture<LambdaHandler>` fulfilled with the outcome of the initialization.
@@ -44,11 +44,8 @@ internal final class LambdaRunner {
4444
terminator: terminator
4545
)
4646

47-
//let x: EventLoopFuture<some ByteBufferLambdaHandler> = handlerType.makeHandler(context: context)
48-
//return x.map{ $0 as any ByteBufferLambdaHandler }
49-
5047
return handlerType.makeHandler(context: context)
51-
.map{ $0 as any ByteBufferLambdaHandler }
48+
.map { $0 as any ByteBufferLambdaHandler }
5249
// Hopping back to "our" EventLoop is important in case the factory returns a future
5350
// that originated from a foreign EventLoop/EventLoopGroup.
5451
// This can happen if the factory uses a library (let's say a database client) that manages its own threads/loops

Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import NIOCore
1919
/// `LambdaRuntime` manages the Lambda process lifecycle.
2020
///
2121
/// Use this API, if you build a higher level web framework which shall be able to run inside the Lambda environment.
22-
public final class LambdaRuntime{
22+
public final class LambdaRuntime {
2323
private let eventLoop: EventLoop
2424
private let shutdownPromise: EventLoopPromise<Int>
2525
private let logger: Logger
@@ -41,7 +41,7 @@ public final class LambdaRuntime{
4141
/// - eventLoop: An `EventLoop` to run the Lambda on.
4242
/// - logger: A `Logger` to log the Lambda events.
4343
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
44-
public convenience init<T: LambdaHandler> (_ handlerType: T.Type, eventLoop: EventLoop, logger: Logger) {
44+
public convenience init<T: LambdaHandler>(_ handlerType: T.Type, eventLoop: EventLoop, logger: Logger) {
4545
self.init(CodableLambdaHandler<T, T.Event, T.Output>.self, eventLoop: eventLoop, logger: logger)
4646
}
4747

@@ -51,7 +51,7 @@ public final class LambdaRuntime{
5151
/// - handlerType: The ``EventLoopLambdaHandler`` type the `LambdaRuntime` shall create and manage.
5252
/// - eventLoop: An `EventLoop` to run the Lambda on.
5353
/// - logger: A `Logger` to log the Lambda events.
54-
public convenience init<T: EventLoopLambdaHandler> (_ handlerType: T.Type, eventLoop: EventLoop, logger: Logger) {
54+
public convenience init<T: EventLoopLambdaHandler>(_ handlerType: T.Type, eventLoop: EventLoop, logger: Logger) {
5555
self.init(CodableEventLoopLambdaHandler<T, T.Event, T.Output>.self, eventLoop: eventLoop, logger: logger)
5656
}
5757

@@ -61,9 +61,8 @@ public final class LambdaRuntime{
6161
/// - handlerType: The ``ByteBufferLambdaHandler`` type the `LambdaRuntime` shall create and manage.
6262
/// - eventLoop: An `EventLoop` to run the Lambda on.
6363
/// - logger: A `Logger` to log the Lambda events.
64-
public convenience init<T: ByteBufferLambdaHandler> (_ handlerType: T.Type, eventLoop: EventLoop, logger: Logger) {
64+
public convenience init<T: ByteBufferLambdaHandler>(_ handlerType: T.Type, eventLoop: EventLoop, logger: Logger) {
6565
self.init(T.self, eventLoop: eventLoop, logger: logger, configuration: .init())
66-
6766
}
6867

6968
init<Handler: ByteBufferLambdaHandler>(_ handlerType: Handler.Type, eventLoop: EventLoop, logger: Logger, configuration: LambdaConfiguration) {

Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,8 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
import Logging
16-
#if compiler(>=5.6)
17-
@preconcurrency import NIOCore
18-
@preconcurrency import NIOHTTP1
19-
#else
2016
import NIOCore
2117
import NIOHTTP1
22-
#endif
2318

2419
/// An HTTP based client for AWS Runtime Engine. This encapsulates the RESTful methods exposed by the Runtime Engine:
2520
/// * /runtime/invocation/next

Sources/AWSLambdaRuntimeCore/Sendable.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

Sources/AWSLambdaRuntimeCore/Terminator.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ extension LambdaTerminator {
100100

101101
extension LambdaTerminator {
102102
fileprivate final class Storage {
103-
private let lock: Lock
103+
private let lock: NIOLock
104104
private var index: [RegistrationKey]
105105
private var map: [RegistrationKey: (name: String, handler: Handler)]
106106

Tests/AWSLambdaRuntimeCoreTests/LambdaHandlerTest.swift

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

1919
class LambdaHandlerTest: XCTestCase {
20-
2120
// MARK: - LambdaHandler
2221

2322
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)

Tests/AWSLambdaRuntimeCoreTests/LambdaTest.swift

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,9 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
@testable import AWSLambdaRuntimeCore
16-
#if compiler(>=5.6)
17-
@preconcurrency import Logging
18-
@preconcurrency import NIOPosix
19-
#else
2016
import Logging
21-
import NIOPosix
22-
#endif
2317
import NIOCore
18+
import NIOPosix
2419
import XCTest
2520

2621
class LambdaTest: XCTestCase {

Tests/AWSLambdaRuntimeTests/Lambda+CodableTest.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ class CodableLambdaTest: XCTestCase {
128128
var outputBuffer: ByteBuffer?
129129
XCTAssertNoThrow(outputBuffer = try handler.handle(inputBuffer, context: context).wait())
130130
XCTAssertEqual(outputBuffer?.readableBytes, 0)
131-
132131
}
133132

134133
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)

Tests/AWSLambdaTestingTests/Tests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class LambdaTestingTests: XCTestCase {
2727
init(context: LambdaInitializationContext) {}
2828

2929
func handle(_ event: String, context: LambdaContext) async throws -> String {
30-
return event
30+
event
3131
}
3232
}
3333

docker/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG swift_version=5.4
1+
ARG swift_version=5.7
22
ARG base_image=swift:$swift_version-amazonlinux2
33
FROM $base_image
44
# needed to do again after FROM due to docker limitation
@@ -14,7 +14,7 @@ RUN echo 'export PATH="$HOME/.tools:$PATH"' >> $HOME/.profile
1414

1515
# swiftformat (until part of the toolchain)
1616

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

docker/docker-compose.al2.54.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

docker/docker-compose.al2.55.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)