Skip to content

Commit 8676c89

Browse files
authoredAug 26, 2024··
apply swiftformat (#342)
* apply swiftformat * update dep on Swift Docc to v1.3.0 * force usage of swift docc plugin 1.3.0
1 parent 79fa2c2 commit 8676c89

23 files changed

+115
-118
lines changed
 

‎Examples/Foundation/Lambda.swift

+2-3
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ struct ExchangeRatesCalculator {
122122
monthIndex: Array<Date>.Index,
123123
currencies: [String],
124124
state: [Date: ExchangeRates],
125-
callback: @escaping ((Result<[Date: ExchangeRates], Swift.Error>) -> Void))
126-
{
125+
callback: @escaping ((Result<[Date: ExchangeRates], Swift.Error>) -> Void)) {
127126
if monthIndex == months.count {
128127
return callback(.success(state))
129128
}
@@ -182,7 +181,7 @@ struct ExchangeRatesCalculator {
182181
interval = nil
183182
}
184183

185-
let ratesByCurrencyCode: [String: Decimal?] = Dictionary(uniqueKeysWithValues: try currencyCodes.map {
184+
let ratesByCurrencyCode: [String: Decimal?] = try Dictionary(uniqueKeysWithValues: currencyCodes.map {
186185
let xpathCurrency = $0.replacingOccurrences(of: "'", with: "&apos;")
187186
if let rateString = try document.nodes(forXPath: "/exchangeRateMonthList/exchangeRate/currencyCode[text()='\(xpathCurrency)']/../rateNew/text()").first?.stringValue,
188187
// We must parse the decimal data using the UK locale, not the system one.

‎Examples/LocalDebugging/MyApp/MyApp/ContentView.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,35 @@ struct ContentView: View {
2323

2424
var body: some View {
2525
VStack(alignment: .leading, spacing: 20) {
26-
TextField("Username", text: $name)
27-
SecureField("Password", text: $password)
28-
let inputIncomplete = name.isEmpty || password.isEmpty
26+
TextField("Username", text: self.$name)
27+
SecureField("Password", text: self.$password)
28+
let inputIncomplete = self.name.isEmpty || self.password.isEmpty
2929
Button {
3030
Task {
31-
isLoading = true
31+
self.isLoading = true
3232
do {
33-
response = try await self.register()
33+
self.response = try await self.register()
3434
} catch {
35-
response = error.localizedDescription
35+
self.response = error.localizedDescription
3636
}
37-
isLoading = false
37+
self.isLoading = false
3838
}
3939
} label: {
4040
Text("Register")
4141
.padding()
4242
.foregroundColor(.white)
4343
.background(.black)
4444
.border(.black, width: 2)
45-
.opacity(isLoading ? 0 : 1)
45+
.opacity(self.isLoading ? 0 : 1)
4646
.overlay {
47-
if isLoading {
47+
if self.isLoading {
4848
ProgressView()
4949
}
5050
}
5151
}
52-
.disabled(inputIncomplete || isLoading)
52+
.disabled(inputIncomplete || self.isLoading)
5353
.opacity(inputIncomplete ? 0.5 : 1)
54-
Text(response)
54+
Text(self.response)
5555
}.padding(100)
5656
}
5757

‎Package.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
dependencies: [
2424
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.67.0")),
2525
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.5.4")),
26-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
26+
.package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.3.0"),
2727
],
2828
targets: [
2929
.target(name: "AWSLambdaRuntime", dependencies: [

‎Package@swift-5.7.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let package = Package(
2424
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.43.1")),
2525
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.2")),
2626
.package(url: "https://github.com/swift-server/swift-backtrace.git", .upToNextMajor(from: "1.2.3")),
27-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
27+
.package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.3.0"),
2828
],
2929
targets: [
3030
.target(name: "AWSLambdaRuntime", dependencies: [

‎Package@swift-5.8.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ let package = Package(
2424
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.43.1")),
2525
.package(url: "https://github.com/apple/swift-log.git", .upToNextMajor(from: "1.4.2")),
2626
.package(url: "https://github.com/swift-server/swift-backtrace.git", .upToNextMajor(from: "1.2.3")),
27-
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
27+
.package(url: "https://github.com/apple/swift-docc-plugin", exact: "1.3.0"),
2828
],
2929
targets: [
3030
.target(name: "AWSLambdaRuntime", dependencies: [

‎Sources/AWSLambdaRuntimeCore/ControlPlaneRequest.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct ErrorResponse: Hashable, Codable {
6666
}
6767

6868
extension ErrorResponse {
69-
internal func toJSONBytes() -> [UInt8] {
69+
func toJSONBytes() -> [UInt8] {
7070
var bytes = [UInt8]()
7171
bytes.append(UInt8(ascii: "{"))
7272
bytes.append(contentsOf: #""errorType":"#.utf8)

‎Sources/AWSLambdaRuntimeCore/DetachedTasks.swift

+7-8
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,18 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414
import Foundation
15+
import Logging
1516
import NIOConcurrencyHelpers
1617
import NIOCore
17-
import Logging
1818

1919
/// A container that allows tasks to finish after a synchronous invocation
2020
/// has produced its response.
2121
actor DetachedTasksContainer: Sendable {
22-
2322
struct Context: Sendable {
2423
let eventLoop: EventLoop
2524
let logger: Logger
2625
}
27-
26+
2827
private var context: Context
2928
private var storage: [RegistrationKey: EventLoopFuture<Void>] = [:]
3029

@@ -40,17 +39,17 @@ actor DetachedTasksContainer: Sendable {
4039
/// - Returns: A `RegistrationKey` for the registered task.
4140
func detached(task: @Sendable @escaping () async -> Void) {
4241
let key = RegistrationKey()
43-
let promise = context.eventLoop.makePromise(of: Void.self)
42+
let promise = self.context.eventLoop.makePromise(of: Void.self)
4443
promise.completeWithTask(task)
45-
let task = promise.futureResult.always { [weak self] result in
44+
let task = promise.futureResult.always { [weak self] _ in
4645
guard let self else { return }
4746
Task {
4847
await self.removeTask(forKey: key)
4948
}
5049
}
5150
self.storage[key] = task
5251
}
53-
52+
5453
func removeTask(forKey key: RegistrationKey) {
5554
self.storage.removeValue(forKey: key)
5655
}
@@ -59,9 +58,9 @@ actor DetachedTasksContainer: Sendable {
5958
///
6059
/// - Returns: An `EventLoopFuture<Void>` that completes when all tasks have finished.
6160
func awaitAll() -> EventLoopFuture<Void> {
62-
let tasks = storage.values
61+
let tasks = self.storage.values
6362
if tasks.isEmpty {
64-
return context.eventLoop.makeSucceededVoidFuture()
63+
return self.context.eventLoop.makeSucceededVoidFuture()
6564
} else {
6665
let context = context
6766
return EventLoopFuture.andAllComplete(Array(tasks), on: context.eventLoop).flatMap { [weak self] in

‎Sources/AWSLambdaRuntimeCore/HTTPClient.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import NIOPosix
2020
/// A barebone HTTP client to interact with AWS Runtime Engine which is an HTTP server.
2121
/// Note that Lambda Runtime API dictate that only one requests runs at a time.
2222
/// This means we can avoid locks and other concurrency concern we would otherwise need to build into the client
23-
internal final class HTTPClient {
23+
final class HTTPClient {
2424
private let eventLoop: EventLoop
2525
private let configuration: LambdaConfiguration.RuntimeEngine
2626
private let targetHost: String
@@ -120,7 +120,7 @@ internal final class HTTPClient {
120120
}
121121
}
122122

123-
internal struct Request: Equatable {
123+
struct Request: Equatable {
124124
let url: String
125125
let method: HTTPMethod
126126
let targetHost: String
@@ -138,14 +138,14 @@ internal final class HTTPClient {
138138
}
139139
}
140140

141-
internal struct Response: Equatable {
141+
struct Response: Equatable {
142142
var version: HTTPVersion
143143
var status: HTTPResponseStatus
144144
var headers: HTTPHeaders
145145
var body: ByteBuffer?
146146
}
147147

148-
internal enum Errors: Error {
148+
enum Errors: Error {
149149
case connectionResetByPeer
150150
case timeout
151151
case cancelled
@@ -277,6 +277,7 @@ private final class LambdaChannelHandler: ChannelDuplexHandler {
277277
switch self.state {
278278
case .idle:
279279
break
280+
280281
case .running(let promise, let timeout):
281282
self.state = .idle
282283
timeout?.cancel()

‎Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension Lambda {
3636
/// - body: Code to run within the context of the mock server. Typically this would be a Lambda.run function call.
3737
///
3838
/// - note: This API is designed strictly for local testing and is behind a DEBUG flag
39-
internal static func withLocalServer<Value>(invocationEndpoint: String? = nil, _ body: @escaping () -> Value) throws -> Value {
39+
static func withLocalServer<Value>(invocationEndpoint: String? = nil, _ body: @escaping () -> Value) throws -> Value {
4040
let server = LocalLambda.Server(invocationEndpoint: invocationEndpoint)
4141
try server.start().wait()
4242
defer { try! server.stop() }

‎Sources/AWSLambdaRuntimeCore/Lambda.swift

+9-9
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ public enum Lambda {
4040
/// - handlerType: The Handler to create and invoke.
4141
///
4242
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
43-
internal static func run<Handler: SimpleLambdaHandler>(
43+
static func run<Handler: SimpleLambdaHandler>(
4444
configuration: LambdaConfiguration = .init(),
4545
handlerType: Handler.Type
4646
) -> Result<Int, Error> {
47-
Self.run(configuration: configuration, handlerProvider: CodableSimpleLambdaHandler<Handler>.makeHandler(context:))
47+
self.run(configuration: configuration, handlerProvider: CodableSimpleLambdaHandler<Handler>.makeHandler(context:))
4848
}
4949

5050
/// Run a Lambda defined by implementing the ``LambdaHandler`` protocol.
@@ -56,11 +56,11 @@ public enum Lambda {
5656
/// - handlerType: The Handler to create and invoke.
5757
///
5858
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
59-
internal static func run<Handler: LambdaHandler>(
59+
static func run<Handler: LambdaHandler>(
6060
configuration: LambdaConfiguration = .init(),
6161
handlerType: Handler.Type
6262
) -> Result<Int, Error> {
63-
Self.run(configuration: configuration, handlerProvider: CodableLambdaHandler<Handler>.makeHandler(context:))
63+
self.run(configuration: configuration, handlerProvider: CodableLambdaHandler<Handler>.makeHandler(context:))
6464
}
6565

6666
/// Run a Lambda defined by implementing the ``EventLoopLambdaHandler`` protocol.
@@ -72,11 +72,11 @@ public enum Lambda {
7272
/// - handlerType: The Handler to create and invoke.
7373
///
7474
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
75-
internal static func run<Handler: EventLoopLambdaHandler>(
75+
static func run<Handler: EventLoopLambdaHandler>(
7676
configuration: LambdaConfiguration = .init(),
7777
handlerType: Handler.Type
7878
) -> Result<Int, Error> {
79-
Self.run(configuration: configuration, handlerProvider: CodableEventLoopLambdaHandler<Handler>.makeHandler(context:))
79+
self.run(configuration: configuration, handlerProvider: CodableEventLoopLambdaHandler<Handler>.makeHandler(context:))
8080
}
8181

8282
/// Run a Lambda defined by implementing the ``ByteBufferLambdaHandler`` protocol.
@@ -88,11 +88,11 @@ public enum Lambda {
8888
/// - handlerType: The Handler to create and invoke.
8989
///
9090
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
91-
internal static func run(
91+
static func run(
9292
configuration: LambdaConfiguration = .init(),
9393
handlerType: (some ByteBufferLambdaHandler).Type
9494
) -> Result<Int, Error> {
95-
Self.run(configuration: configuration, handlerProvider: handlerType.makeHandler(context:))
95+
self.run(configuration: configuration, handlerProvider: handlerType.makeHandler(context:))
9696
}
9797

9898
/// Run a Lambda defined by implementing the ``LambdaRuntimeHandler`` protocol.
@@ -101,7 +101,7 @@ public enum Lambda {
101101
/// - handlerProvider: A provider of the ``LambdaRuntimeHandler`` to invoke.
102102
///
103103
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
104-
internal static func run(
104+
static func run(
105105
configuration: LambdaConfiguration = .init(),
106106
handlerProvider: @escaping (LambdaInitializationContext) -> EventLoopFuture<some LambdaRuntimeHandler>
107107
) -> Result<Int, Error> {

‎Sources/AWSLambdaRuntimeCore/LambdaConfiguration.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import Dispatch
1616
import Logging
1717
import NIOCore
1818

19-
internal struct LambdaConfiguration: CustomStringConvertible {
19+
struct LambdaConfiguration: CustomStringConvertible {
2020
let general: General
2121
let lifecycle: Lifecycle
2222
let runtimeEngine: RuntimeEngine

‎Sources/AWSLambdaRuntimeCore/LambdaContext.swift

+3-4
Original file line numberDiff line numberDiff line change
@@ -197,19 +197,18 @@ public struct LambdaContext: CustomDebugStringConvertible, Sendable {
197197
let remaining = deadline - now
198198
return .milliseconds(remaining)
199199
}
200-
200+
201201
var tasks: DetachedTasksContainer {
202202
self.storage.tasks
203203
}
204-
205-
204+
206205
/// Registers a background task that continues running after the synchronous invocation has completed.
207206
/// This is useful for tasks like flushing metrics or performing clean-up operations without delaying the response.
208207
///
209208
/// - Parameter body: An asynchronous closure that performs the background task.
210209
/// - Warning: You will be billed for the milliseconds of Lambda execution time until the very last
211210
/// background task is finished.
212-
public func detachedBackgroundTask(_ body: @escaping @Sendable () async -> ()) {
211+
public func detachedBackgroundTask(_ body: @escaping @Sendable () async -> Void) {
213212
Task {
214213
await self.tasks.detached(task: body)
215214
}

‎Sources/AWSLambdaRuntimeCore/LambdaHandler.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ extension LambdaHandler {
255255
/// unchecked sendable wrapper for the handler
256256
/// this is safe since lambda runtime is designed to calls the handler serially
257257
@usableFromInline
258-
internal struct UncheckedSendableHandler<Underlying: LambdaHandler, Event, Output>: @unchecked Sendable where Event == Underlying.Event, Output == Underlying.Output {
258+
struct UncheckedSendableHandler<Underlying: LambdaHandler, Event, Output>: @unchecked Sendable where Event == Underlying.Event, Output == Underlying.Output {
259259
@usableFromInline
260260
let underlying: Underlying
261261

‎Sources/AWSLambdaRuntimeCore/LambdaRequestID.swift

+32-32
Original file line numberDiff line numberDiff line change
@@ -217,38 +217,38 @@ extension LambdaRequestID {
217217
// are safe and we don't need Swifts safety guards.
218218

219219
characters.withUnsafeBufferPointer { lookup in
220-
string.0 = lookup[Int(uuid.0 >> 4)]
221-
string.1 = lookup[Int(uuid.0 & 0x0F)]
222-
string.2 = lookup[Int(uuid.1 >> 4)]
223-
string.3 = lookup[Int(uuid.1 & 0x0F)]
224-
string.4 = lookup[Int(uuid.2 >> 4)]
225-
string.5 = lookup[Int(uuid.2 & 0x0F)]
226-
string.6 = lookup[Int(uuid.3 >> 4)]
227-
string.7 = lookup[Int(uuid.3 & 0x0F)]
228-
string.9 = lookup[Int(uuid.4 >> 4)]
229-
string.10 = lookup[Int(uuid.4 & 0x0F)]
230-
string.11 = lookup[Int(uuid.5 >> 4)]
231-
string.12 = lookup[Int(uuid.5 & 0x0F)]
232-
string.14 = lookup[Int(uuid.6 >> 4)]
233-
string.15 = lookup[Int(uuid.6 & 0x0F)]
234-
string.16 = lookup[Int(uuid.7 >> 4)]
235-
string.17 = lookup[Int(uuid.7 & 0x0F)]
236-
string.19 = lookup[Int(uuid.8 >> 4)]
237-
string.20 = lookup[Int(uuid.8 & 0x0F)]
238-
string.21 = lookup[Int(uuid.9 >> 4)]
239-
string.22 = lookup[Int(uuid.9 & 0x0F)]
240-
string.24 = lookup[Int(uuid.10 >> 4)]
241-
string.25 = lookup[Int(uuid.10 & 0x0F)]
242-
string.26 = lookup[Int(uuid.11 >> 4)]
243-
string.27 = lookup[Int(uuid.11 & 0x0F)]
244-
string.28 = lookup[Int(uuid.12 >> 4)]
245-
string.29 = lookup[Int(uuid.12 & 0x0F)]
246-
string.30 = lookup[Int(uuid.13 >> 4)]
247-
string.31 = lookup[Int(uuid.13 & 0x0F)]
248-
string.32 = lookup[Int(uuid.14 >> 4)]
249-
string.33 = lookup[Int(uuid.14 & 0x0F)]
250-
string.34 = lookup[Int(uuid.15 >> 4)]
251-
string.35 = lookup[Int(uuid.15 & 0x0F)]
220+
string.0 = lookup[Int(self.uuid.0 >> 4)]
221+
string.1 = lookup[Int(self.uuid.0 & 0x0F)]
222+
string.2 = lookup[Int(self.uuid.1 >> 4)]
223+
string.3 = lookup[Int(self.uuid.1 & 0x0F)]
224+
string.4 = lookup[Int(self.uuid.2 >> 4)]
225+
string.5 = lookup[Int(self.uuid.2 & 0x0F)]
226+
string.6 = lookup[Int(self.uuid.3 >> 4)]
227+
string.7 = lookup[Int(self.uuid.3 & 0x0F)]
228+
string.9 = lookup[Int(self.uuid.4 >> 4)]
229+
string.10 = lookup[Int(self.uuid.4 & 0x0F)]
230+
string.11 = lookup[Int(self.uuid.5 >> 4)]
231+
string.12 = lookup[Int(self.uuid.5 & 0x0F)]
232+
string.14 = lookup[Int(self.uuid.6 >> 4)]
233+
string.15 = lookup[Int(self.uuid.6 & 0x0F)]
234+
string.16 = lookup[Int(self.uuid.7 >> 4)]
235+
string.17 = lookup[Int(self.uuid.7 & 0x0F)]
236+
string.19 = lookup[Int(self.uuid.8 >> 4)]
237+
string.20 = lookup[Int(self.uuid.8 & 0x0F)]
238+
string.21 = lookup[Int(self.uuid.9 >> 4)]
239+
string.22 = lookup[Int(self.uuid.9 & 0x0F)]
240+
string.24 = lookup[Int(self.uuid.10 >> 4)]
241+
string.25 = lookup[Int(self.uuid.10 & 0x0F)]
242+
string.26 = lookup[Int(self.uuid.11 >> 4)]
243+
string.27 = lookup[Int(self.uuid.11 & 0x0F)]
244+
string.28 = lookup[Int(self.uuid.12 >> 4)]
245+
string.29 = lookup[Int(self.uuid.12 & 0x0F)]
246+
string.30 = lookup[Int(self.uuid.13 >> 4)]
247+
string.31 = lookup[Int(self.uuid.13 & 0x0F)]
248+
string.32 = lookup[Int(self.uuid.14 >> 4)]
249+
string.33 = lookup[Int(self.uuid.14 & 0x0F)]
250+
string.34 = lookup[Int(self.uuid.15 >> 4)]
251+
string.35 = lookup[Int(self.uuid.15 & 0x0F)]
252252
}
253253

254254
return string

‎Sources/AWSLambdaRuntimeCore/LambdaRunner.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Logging
1717
import NIOCore
1818

1919
/// LambdaRunner manages the Lambda runtime workflow, or business logic.
20-
internal final class LambdaRunner {
20+
final class LambdaRunner {
2121
private let runtimeClient: LambdaRuntimeClient
2222
private let eventLoop: EventLoop
2323
private let allocator: ByteBufferAllocator
@@ -105,7 +105,7 @@ internal final class LambdaRunner {
105105
// Do we want to await the tasks in this case?
106106
let promise = context.eventLoop.makePromise(of: Void.self)
107107
promise.completeWithTask {
108-
return try await context.tasks.awaitAll().get()
108+
try await context.tasks.awaitAll().get()
109109
}
110110
return promise.futureResult
111111
}.map { _ in context }

‎Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ public final class LambdaRuntime<Handler: LambdaRuntimeHandler> {
204204
case shuttingdown
205205
case shutdown
206206

207-
internal var order: Int {
207+
var order: Int {
208208
switch self {
209209
case .idle:
210210
return 0

‎Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import NIOHTTP1
2121
/// * /runtime/invocation/response
2222
/// * /runtime/invocation/error
2323
/// * /runtime/init/error
24-
internal struct LambdaRuntimeClient {
24+
struct LambdaRuntimeClient {
2525
private let eventLoop: EventLoop
2626
private let allocator = ByteBufferAllocator()
2727
private let httpClient: HTTPClient
@@ -124,7 +124,7 @@ internal struct LambdaRuntimeClient {
124124
}
125125
}
126126

127-
internal enum LambdaRuntimeError: Error {
127+
enum LambdaRuntimeError: Error {
128128
case badStatusCode(HTTPResponseStatus)
129129
case upstreamError(String)
130130
case invocationMissingHeader(String)
@@ -134,10 +134,10 @@ internal enum LambdaRuntimeError: Error {
134134
}
135135

136136
extension LambdaRuntimeClient {
137-
internal static let defaultHeaders = HTTPHeaders([("user-agent", "Swift-Lambda/Unknown")])
137+
static let defaultHeaders = HTTPHeaders([("user-agent", "Swift-Lambda/Unknown")])
138138

139139
/// These headers must be sent along an invocation or initialization error report
140-
internal static let errorHeaders = HTTPHeaders([
140+
static let errorHeaders = HTTPHeaders([
141141
("user-agent", "Swift-Lambda/Unknown"),
142142
("lambda-runtime-function-error-type", "Unhandled"),
143143
])

‎Sources/AWSLambdaRuntimeCore/Terminator.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public final class LambdaTerminator {
5656
/// - eventLoop: The `EventLoop` to run the termination on.
5757
///
5858
/// - Returns: An `EventLoopFuture` with the result of the termination cycle.
59-
internal func terminate(eventLoop: EventLoop) -> EventLoopFuture<Void> {
59+
func terminate(eventLoop: EventLoop) -> EventLoopFuture<Void> {
6060
func terminate(_ iterator: IndexingIterator<[(name: String, handler: Handler)]>, errors: [Error], promise: EventLoopPromise<Void>) {
6161
var iterator = iterator
6262
guard let handler = iterator.next()?.handler else {

‎Sources/AWSLambdaRuntimeCore/Utils.swift

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import Dispatch
1616
import NIOPosix
1717

18-
internal enum Consts {
18+
enum Consts {
1919
static let apiPrefix = "/2018-06-01"
2020
static let invocationURLPrefix = "\(apiPrefix)/runtime/invocation"
2121
static let getNextInvocationURLSuffix = "/next"
@@ -27,7 +27,7 @@ internal enum Consts {
2727
}
2828

2929
/// AWS Lambda HTTP Headers, used to populate the `LambdaContext` object.
30-
internal enum AmazonHeaders {
30+
enum AmazonHeaders {
3131
static let requestID = "Lambda-Runtime-Aws-Request-Id"
3232
static let traceID = "Lambda-Runtime-Trace-Id"
3333
static let clientContext = "X-Amz-Client-Context"
@@ -37,7 +37,7 @@ internal enum AmazonHeaders {
3737
}
3838

3939
/// Helper function to trap signals
40-
internal func trap(signal sig: Signal, handler: @escaping (Signal) -> Void) -> DispatchSourceSignal {
40+
func trap(signal sig: Signal, handler: @escaping (Signal) -> Void) -> DispatchSourceSignal {
4141
let signalSource = DispatchSource.makeSignalSource(signal: sig.rawValue, queue: DispatchQueue.global())
4242
signal(sig.rawValue, SIG_IGN)
4343
signalSource.setEventHandler(handler: {
@@ -48,7 +48,7 @@ internal func trap(signal sig: Signal, handler: @escaping (Signal) -> Void) -> D
4848
return signalSource
4949
}
5050

51-
internal enum Signal: Int32 {
51+
enum Signal: Int32 {
5252
case HUP = 1
5353
case INT = 2
5454
case QUIT = 3
@@ -59,14 +59,14 @@ internal enum Signal: Int32 {
5959
}
6060

6161
extension DispatchWallTime {
62-
internal init(millisSinceEpoch: Int64) {
62+
init(millisSinceEpoch: Int64) {
6363
let nanoSinceEpoch = UInt64(millisSinceEpoch) * 1_000_000
6464
let seconds = UInt64(nanoSinceEpoch / 1_000_000_000)
6565
let nanoseconds = nanoSinceEpoch - (seconds * 1_000_000_000)
6666
self.init(timespec: timespec(tv_sec: Int(seconds), tv_nsec: Int(nanoseconds)))
6767
}
6868

69-
internal var millisSinceEpoch: Int64 {
69+
var millisSinceEpoch: Int64 {
7070
Int64(bitPattern: self.rawValue) / -1_000_000
7171
}
7272
}
@@ -117,7 +117,7 @@ extension AmazonHeaders {
117117
/// # References
118118
/// - [Generating trace IDs](https://docs.aws.amazon.com/xray/latest/devguide/xray-api-sendingdata.html#xray-api-traceids)
119119
/// - [Tracing header](https://docs.aws.amazon.com/xray/latest/devguide/xray-concepts.html#xray-concepts-tracingheader)
120-
internal static func generateXRayTraceID() -> String {
120+
static func generateXRayTraceID() -> String {
121121
// The version number, that is, 1.
122122
let version: UInt = 1
123123
// The time of the original request, in Unix epoch time, in 8 hexadecimal digits.

‎Sources/MockServer/main.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import NIOCore
1717
import NIOHTTP1
1818
import NIOPosix
1919

20-
internal struct MockServer {
20+
struct MockServer {
2121
private let group: EventLoopGroup
2222
private let host: String
2323
private let port: Int
@@ -48,7 +48,7 @@ internal struct MockServer {
4848
}
4949
}
5050

51-
internal final class HTTPHandler: ChannelInboundHandler {
51+
final class HTTPHandler: ChannelInboundHandler {
5252
public typealias InboundIn = HTTPServerRequestPart
5353
public typealias OutboundOut = HTTPServerResponsePart
5454

@@ -134,12 +134,12 @@ internal final class HTTPHandler: ChannelInboundHandler {
134134
}
135135
}
136136

137-
internal enum ServerError: Error {
137+
enum ServerError: Error {
138138
case notReady
139139
case cantBind
140140
}
141141

142-
internal enum AmazonHeaders {
142+
enum AmazonHeaders {
143143
static let requestID = "Lambda-Runtime-Aws-Request-Id"
144144
static let traceID = "Lambda-Runtime-Trace-Id"
145145
static let clientContext = "X-Amz-Client-Context"
@@ -148,7 +148,7 @@ internal enum AmazonHeaders {
148148
static let invokedFunctionARN = "Lambda-Runtime-Invoked-Function-Arn"
149149
}
150150

151-
internal enum Mode: String {
151+
enum Mode: String {
152152
case string
153153
case json
154154
}

‎Tests/AWSLambdaRuntimeCoreTests/DetachedTasksTests.swift

+10-11
Original file line numberDiff line numberDiff line change
@@ -13,51 +13,50 @@
1313
//===----------------------------------------------------------------------===//
1414

1515
@testable import AWSLambdaRuntimeCore
16+
import Logging
1617
import NIO
1718
import XCTest
18-
import Logging
1919

2020
class DetachedTasksTest: XCTestCase {
21-
2221
actor Expectation {
2322
var isFulfilled = false
2423
func fulfill() {
25-
isFulfilled = true
24+
self.isFulfilled = true
2625
}
2726
}
28-
27+
2928
func testAwaitTasks() async throws {
3029
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
3130
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
32-
31+
3332
let context = DetachedTasksContainer.Context(
3433
eventLoop: eventLoopGroup.next(),
3534
logger: Logger(label: "test")
3635
)
3736
let expectation = Expectation()
38-
37+
3938
let container = DetachedTasksContainer(context: context)
4039
await container.detached {
4140
try! await Task.sleep(for: .milliseconds(200))
4241
await expectation.fulfill()
4342
}
44-
43+
4544
try await container.awaitAll().get()
4645
let isFulfilled = await expectation.isFulfilled
4746
XCTAssert(isFulfilled)
4847
}
49-
48+
5049
func testAwaitChildrenTasks() async throws {
5150
let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
5251
defer { XCTAssertNoThrow(try eventLoopGroup.syncShutdownGracefully()) }
53-
52+
5453
let context = DetachedTasksContainer.Context(
5554
eventLoop: eventLoopGroup.next(),
5655
logger: Logger(label: "test")
5756
)
5857
let expectation1 = Expectation()
5958
let expectation2 = Expectation()
60-
59+
6160
let container = DetachedTasksContainer(context: context)
6261
await container.detached {
6362
await container.detached {
@@ -70,7 +69,7 @@ class DetachedTasksTest: XCTestCase {
7069
await expectation2.fulfill()
7170
}
7271
}
73-
72+
7473
try await container.awaitAll().get()
7574
let isFulfilled1 = await expectation1.isFulfilled
7675
let isFulfilled2 = await expectation2.isFulfilled

‎Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift

+8-8
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import NIOCore
1919
import NIOHTTP1
2020
import NIOPosix
2121

22-
internal final class MockLambdaServer {
22+
final class MockLambdaServer {
2323
private let logger = Logger(label: "MockLambdaServer")
2424
private let behavior: LambdaServerBehavior
2525
private let host: String
@@ -72,7 +72,7 @@ internal final class MockLambdaServer {
7272
}
7373
}
7474

75-
internal final class HTTPHandler: ChannelInboundHandler {
75+
final class HTTPHandler: ChannelInboundHandler {
7676
typealias InboundIn = HTTPServerRequestPart
7777
typealias OutboundOut = HTTPServerResponsePart
7878

@@ -213,35 +213,35 @@ internal final class HTTPHandler: ChannelInboundHandler {
213213
}
214214
}
215215

216-
internal protocol LambdaServerBehavior {
216+
protocol LambdaServerBehavior {
217217
func getInvocation() -> GetInvocationResult
218218
func processResponse(requestId: String, response: String?) -> Result<Void, ProcessResponseError>
219219
func processError(requestId: String, error: ErrorResponse) -> Result<Void, ProcessErrorError>
220220
func processInitError(error: ErrorResponse) -> Result<Void, ProcessErrorError>
221221
}
222222

223-
internal typealias GetInvocationResult = Result<(String, String), GetWorkError>
223+
typealias GetInvocationResult = Result<(String, String), GetWorkError>
224224

225-
internal enum GetWorkError: Int, Error {
225+
enum GetWorkError: Int, Error {
226226
case badRequest = 400
227227
case tooManyRequests = 429
228228
case internalServerError = 500
229229
}
230230

231-
internal enum ProcessResponseError: Int, Error {
231+
enum ProcessResponseError: Int, Error {
232232
case badRequest = 400
233233
case payloadTooLarge = 413
234234
case tooManyRequests = 429
235235
case internalServerError = 500
236236
}
237237

238-
internal enum ProcessErrorError: Int, Error {
238+
enum ProcessErrorError: Int, Error {
239239
case invalidErrorShape = 299
240240
case badRequest = 400
241241
case internalServerError = 500
242242
}
243243

244-
internal enum ServerError: Error {
244+
enum ServerError: Error {
245245
case notReady
246246
case cantBind
247247
}

‎Tests/AWSLambdaRuntimeCoreTests/Utils.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ struct TestError: Error, Equatable, CustomStringConvertible {
109109
}
110110

111111
extension Date {
112-
internal var millisSinceEpoch: Int64 {
112+
var millisSinceEpoch: Int64 {
113113
Int64(self.timeIntervalSince1970 * 1000)
114114
}
115115
}

0 commit comments

Comments
 (0)
Please sign in to comment.