Skip to content

Commit 43c4ecd

Browse files
authored
Merge branch 'main' into ff-remove-swift-testing-dependency
2 parents 968224c + d2bd7f1 commit 43c4ecd

File tree

5 files changed

+42
-41
lines changed

5 files changed

+42
-41
lines changed

.github/workflows/pull_request.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ jobs:
1111
with:
1212
license_header_check_project_name: "SwiftAWSLambdaRuntime"
1313
shell_check_enabled: false
14-
api_breakage_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
15-
docs_check_container_image: "swiftlang/swift:nightly-6.0-jammy"
14+
api_breakage_check_container_image: "swift:6.0-noble"
15+
docs_check_container_image: "swift:6.0-noble"
1616

1717
unit-tests:
1818
name: Unit tests

Plugins/AWSLambdaPackager/PluginUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct Utils {
3232

3333
let fd = dup(1)
3434
let stdout = fdopen(fd, "rw")
35-
defer { fclose(stdout) }
35+
defer { fclose(stdout!) }
3636

3737
// We need to use an unsafe transfer here to get the fd into our Sendable closure.
3838
// This transfer is fine, because we write to the variable from a single SerialDispatchQueue here.

Sources/AWSLambdaRuntime/Lambda+Codable.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public struct LambdaJSONOutputEncoder<Output: Encodable>: LambdaOutputEncoder {
4343
extension LambdaCodableAdapter {
4444
/// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output.
4545
/// - Parameters:
46-
/// - encoder: The encoder object that will be used to encode the generic ``Output`` obtained from the `handler`'s `outputWriter` into a ``ByteBuffer``.
47-
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`.
46+
/// - encoder: The encoder object that will be used to encode the generic `Output` obtained from the `handler`'s `outputWriter` into a `ByteBuffer`.
47+
/// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`.
4848
/// - handler: The handler object.
4949
public init(
5050
encoder: JSONEncoder,
@@ -66,10 +66,10 @@ extension LambdaCodableAdapter {
6666
}
6767

6868
extension LambdaRuntime {
69-
/// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a non-`Void` return type**.
69+
/// Initialize an instance with a `LambdaHandler` defined in the form of a closure **with a non-`Void` return type**.
7070
/// - Parameter body: The handler in the form of a closure.
71-
/// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``. ``JSONEncoder()`` used as default.
72-
/// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type. ``JSONDecoder()`` used as default.
71+
/// - Parameter encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`. `JSONEncoder()` used as default.
72+
/// - Parameter decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. `JSONDecoder()` used as default.
7373
public convenience init<Event: Decodable, Output>(
7474
body: @escaping (Event, LambdaContext) async throws -> Output,
7575
encoder: JSONEncoder = JSONEncoder(),
@@ -93,9 +93,9 @@ extension LambdaRuntime {
9393
self.init(handler: handler)
9494
}
9595

96-
/// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a `Void` return type**.
96+
/// Initialize an instance with a `LambdaHandler` defined in the form of a closure **with a `Void` return type**.
9797
/// - Parameter body: The handler in the form of a closure.
98-
/// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type. ``JSONDecoder()`` used as default.
98+
/// - Parameter decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. `JSONDecoder()` used as default.
9999
public convenience init<Event: Decodable>(
100100
body: @escaping (Event, LambdaContext) async throws -> Void,
101101
decoder: JSONDecoder = JSONDecoder()

Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import NIOCore
1616

1717
/// The protocol a decoder must conform to so that it can be used with ``LambdaCodableAdapter`` to decode incoming
18-
/// ``ByteBuffer`` events.
18+
/// `ByteBuffer` events.
1919
public protocol LambdaEventDecoder {
20-
/// Decode the ``ByteBuffer`` representing the received event into the generic ``Event`` type
20+
/// Decode the `ByteBuffer` representing the received event into the generic `Event` type
2121
/// the handler will receive.
2222
/// - Parameters:
2323
/// - type: The type of the object to decode the buffer into.
@@ -27,14 +27,14 @@ public protocol LambdaEventDecoder {
2727
}
2828

2929
/// The protocol an encoder must conform to so that it can be used with ``LambdaCodableAdapter`` to encode the generic
30-
/// ``Output`` object into a ``ByteBuffer``.
30+
/// ``LambdaOutputEncoder/Output`` object into a `ByteBuffer`.
3131
public protocol LambdaOutputEncoder {
3232
associatedtype Output
3333

34-
/// Encode the generic type `Output` the handler has returned into a ``ByteBuffer``.
34+
/// Encode the generic type `Output` the handler has returned into a `ByteBuffer`.
3535
/// - Parameters:
36-
/// - value: The object to encode into a ``ByteBuffer``.
37-
/// - buffer: The ``ByteBuffer`` where the encoded value will be written to.
36+
/// - value: The object to encode into a `ByteBuffer`.
37+
/// - buffer: The `ByteBuffer` where the encoded value will be written to.
3838
func encode(_ value: Output, into buffer: inout ByteBuffer) throws
3939
}
4040

@@ -62,7 +62,7 @@ public struct LambdaHandlerAdapter<
6262
self.handler = handler
6363
}
6464

65-
/// Passes the generic ``Event`` object to the ``LambdaHandler/handle(_:context:)`` function, and
65+
/// Passes the generic `Event` object to the ``LambdaHandler/handle(_:context:)`` function, and
6666
/// the resulting output is then written to ``LambdaWithBackgroundProcessingHandler``'s `outputWriter`.
6767
/// - Parameters:
6868
/// - event: The received event.
@@ -93,9 +93,9 @@ public struct LambdaCodableAdapter<
9393
@usableFromInline var byteBuffer: ByteBuffer = .init()
9494

9595
/// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output.
96-
/// - Parameters:
97-
/// - encoder: The encoder object that will be used to encode the generic ``Output`` obtained from the `handler`'s `outputWriter` into a ``ByteBuffer``.
98-
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`.
96+
/// - Parameters:
97+
/// - encoder: The encoder object that will be used to encode the generic `Output` obtained from the `handler`'s `outputWriter` into a `ByteBuffer`.
98+
/// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`.
9999
/// - handler: The handler object.
100100
@inlinable
101101
public init(encoder: Encoder, decoder: Decoder, handler: Handler) where Output: Encodable {
@@ -106,8 +106,8 @@ public struct LambdaCodableAdapter<
106106

107107
/// Initializes an instance given a decoder, and a handler with a `Void` output.
108108
/// - Parameters:
109-
/// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`.
110-
/// - handler: The handler object.
109+
/// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`.
110+
/// - handler: The handler object.
111111
@inlinable
112112
public init(decoder: Decoder, handler: Handler) where Output == Void, Encoder == VoidEncoder {
113113
self.encoder = VoidEncoder()
@@ -145,7 +145,7 @@ where Output == Encoder.Output {
145145

146146
/// Initializes an instance given an encoder and an underlying ``LambdaResponseStreamWriter``.
147147
/// - Parameters:
148-
/// - encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``, which will then be passed to `streamWriter`.
148+
/// - encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`, which will then be passed to `streamWriter`.
149149
/// - streamWriter: The underlying ``LambdaResponseStreamWriter`` that will be wrapped.
150150
@inlinable
151151
public init(encoder: Encoder, streamWriter: Base) {

Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import NIOCore
1616

17-
/// The base handler protocol that receives a ``ByteBuffer`` representing the incoming event and returns the response as a ``ByteBuffer`` too.
17+
/// The base handler protocol that receives a `ByteBuffer` representing the incoming event and returns the response as a `ByteBuffer` too.
1818
/// This handler protocol supports response streaming. Bytes can be streamed outwards through the ``LambdaResponseStreamWriter``
1919
/// passed as an argument in the ``handle(_:responseWriter:context:)`` function.
2020
/// Background work can also be executed after returning the response. After closing the response stream by calling
@@ -69,12 +69,12 @@ public protocol LambdaHandler {
6969
/// The body of the request sent to Lambda will be decoded into this type for the handler to consume.
7070
associatedtype Event: Decodable
7171
/// Generic output type.
72-
/// This is the return type of the ``handle(_:context:)`` function.
72+
/// This is the return type of the ``LambdaHandler/handle(_:context:)`` function.
7373
associatedtype Output
7474

7575
/// Implement the business logic of the Lambda function here.
7676
/// - Parameters:
77-
/// - event: The generic ``Event`` object representing the invocation's input data.
77+
/// - event: The generic ``LambdaHandler/Event`` object representing the invocation's input data.
7878
/// - context: The ``LambdaContext`` containing the invocation's metadata.
7979
/// - Returns: A generic ``Output`` object representing the computed result.
8080
func handle(_ event: Event, context: LambdaContext) async throws -> Output
@@ -83,8 +83,9 @@ public protocol LambdaHandler {
8383
/// This protocol is exactly like ``LambdaHandler``, with the only difference being the added support for executing background
8484
/// work after the result has been sent to the AWS Lambda control plane.
8585
/// This is achieved by not having a return type in the `handle` function. The output is instead written into a
86-
/// ``LambdaResponseWriter``that is passed in as an argument, meaning that the ``handle(_:)`` function is then free to implement
87-
/// any background work after the result has been sent to the AWS Lambda control plane.
86+
/// ``LambdaResponseWriter``that is passed in as an argument, meaning that the
87+
/// ``LambdaWithBackgroundProcessingHandler/handle(_:outputWriter:context:)`` function is then
88+
/// free to implement any background work after the result has been sent to the AWS Lambda control plane.
8889
public protocol LambdaWithBackgroundProcessingHandler {
8990
/// Generic input type.
9091
/// The body of the request sent to Lambda will be decoded into this type for the handler to consume.
@@ -95,7 +96,7 @@ public protocol LambdaWithBackgroundProcessingHandler {
9596

9697
/// Implement the business logic of the Lambda function here.
9798
/// - Parameters:
98-
/// - event: The generic ``Event`` object representing the invocation's input data.
99+
/// - event: The generic ``LambdaWithBackgroundProcessingHandler/Event`` object representing the invocation's input data.
99100
/// - outputWriter: The writer to send the computed response to. A call to `outputWriter.write(_:)` will return the response to the AWS Lambda response endpoint.
100101
/// Any background work can then be executed before returning.
101102
/// - context: The ``LambdaContext`` containing the invocation's metadata.
@@ -111,7 +112,7 @@ public protocol LambdaWithBackgroundProcessingHandler {
111112
/// have a return type and exit at that point. This allows for background work to be executed _after_ a response has been sent to the AWS Lambda response endpoint.
112113
public protocol LambdaResponseWriter<Output> {
113114
associatedtype Output
114-
/// Sends the generic ``Output`` object (representing the computed result of the handler)
115+
/// Sends the generic ``LambdaResponseWriter/Output`` object (representing the computed result of the handler)
115116
/// to the AWS Lambda response endpoint.
116117
/// This function simply serves as a mechanism to return the computed result from a handler function
117118
/// without an explicit `return`.
@@ -131,18 +132,18 @@ public struct StreamingClosureHandler: StreamingLambdaHandler {
131132
self.body = body
132133
}
133134

134-
/// Calls the provided `self.body` closure with the ``ByteBuffer`` invocation event, the ``LambdaResponseStreamWriter``, and the ``LambdaContext``
135+
/// Calls the provided `self.body` closure with the `ByteBuffer` invocation event, the ``LambdaResponseStreamWriter``, and the ``LambdaContext``
135136
/// - Parameters:
136137
/// - event: The invocation's input data.
137138
/// - responseWriter: A ``LambdaResponseStreamWriter`` to write the invocation's response to.
138-
/// If no response or error is written to `responseWriter` an error will be reported to the invoker.
139+
/// If no response or error is written to `responseWriter` an error will be reported to the invoker.
139140
/// - context: The ``LambdaContext`` containing the invocation's metadata.
140141
public func handle(
141-
_ request: ByteBuffer,
142+
_ event: ByteBuffer,
142143
responseWriter: some LambdaResponseStreamWriter,
143144
context: LambdaContext
144145
) async throws {
145-
try await self.body(request, responseWriter, context)
146+
try await self.body(event, responseWriter, context)
146147
}
147148
}
148149

@@ -163,9 +164,9 @@ public struct ClosureHandler<Event: Decodable, Output>: LambdaHandler {
163164
self.body = body
164165
}
165166

166-
/// Calls the provided `self.body` closure with the generic ``Event`` object representing the incoming event, and the ``LambdaContext``
167+
/// Calls the provided `self.body` closure with the generic `Event` object representing the incoming event, and the ``LambdaContext``
167168
/// - Parameters:
168-
/// - event: The generic ``Event`` object representing the invocation's input data.
169+
/// - event: The generic `Event` object representing the invocation's input data.
169170
/// - context: The ``LambdaContext`` containing the invocation's metadata.
170171
public func handle(_ event: Event, context: LambdaContext) async throws -> Output {
171172
try await self.body(event, context)
@@ -183,8 +184,8 @@ extension LambdaRuntime {
183184

184185
/// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a non-`Void` return type**, an encoder, and a decoder.
185186
/// - Parameter body: The handler in the form of a closure.
186-
/// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``.
187-
/// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type.
187+
/// - Parameter encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`.
188+
/// - Parameter decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type.
188189
public convenience init<
189190
Event: Decodable,
190191
Output: Encodable,
@@ -214,9 +215,9 @@ extension LambdaRuntime {
214215
}
215216

216217
/// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a `Void` return type**, an encoder, and a decoder.
217-
/// - Parameter body: The handler in the form of a closure.
218-
/// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``.
219-
/// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type.
218+
/// - Parameters:
219+
/// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type.
220+
/// - body: The handler in the form of a closure.
220221
public convenience init<Event: Decodable, Decoder: LambdaEventDecoder>(
221222
decoder: Decoder,
222223
body: @escaping (Event, LambdaContext) async throws -> Void

0 commit comments

Comments
 (0)