diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 39e033e2..f7522664 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -11,8 +11,8 @@ jobs: with: license_header_check_project_name: "SwiftAWSLambdaRuntime" shell_check_enabled: false - api_breakage_check_container_image: "swiftlang/swift:nightly-6.0-jammy" - docs_check_container_image: "swiftlang/swift:nightly-6.0-jammy" + api_breakage_check_container_image: "swift:6.0-noble" + docs_check_container_image: "swift:6.0-noble" unit-tests: name: Unit tests diff --git a/Plugins/AWSLambdaPackager/PluginUtils.swift b/Plugins/AWSLambdaPackager/PluginUtils.swift index 0cc3b5fe..11827200 100644 --- a/Plugins/AWSLambdaPackager/PluginUtils.swift +++ b/Plugins/AWSLambdaPackager/PluginUtils.swift @@ -32,7 +32,7 @@ struct Utils { let fd = dup(1) let stdout = fdopen(fd, "rw") - defer { fclose(stdout) } + defer { fclose(stdout!) } // We need to use an unsafe transfer here to get the fd into our Sendable closure. // This transfer is fine, because we write to the variable from a single SerialDispatchQueue here. diff --git a/Sources/AWSLambdaRuntime/Lambda+Codable.swift b/Sources/AWSLambdaRuntime/Lambda+Codable.swift index 531eb96b..8dc848d1 100644 --- a/Sources/AWSLambdaRuntime/Lambda+Codable.swift +++ b/Sources/AWSLambdaRuntime/Lambda+Codable.swift @@ -43,8 +43,8 @@ public struct LambdaJSONOutputEncoder: LambdaOutputEncoder { extension LambdaCodableAdapter { /// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output. /// - Parameters: - /// - encoder: The encoder object that will be used to encode the generic ``Output`` obtained from the `handler`'s `outputWriter` into a ``ByteBuffer``. - /// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`. + /// - encoder: The encoder object that will be used to encode the generic `Output` obtained from the `handler`'s `outputWriter` into a `ByteBuffer`. + /// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`. /// - handler: The handler object. public init( encoder: JSONEncoder, @@ -66,10 +66,10 @@ extension LambdaCodableAdapter { } extension LambdaRuntime { - /// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a non-`Void` return type**. + /// Initialize an instance with a `LambdaHandler` defined in the form of a closure **with a non-`Void` return type**. /// - Parameter body: The handler in the form of a closure. - /// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``. ``JSONEncoder()`` used as default. - /// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type. ``JSONDecoder()`` used as default. + /// - Parameter encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`. `JSONEncoder()` used as default. + /// - Parameter decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. `JSONDecoder()` used as default. public convenience init( body: @escaping (Event, LambdaContext) async throws -> Output, encoder: JSONEncoder = JSONEncoder(), @@ -93,9 +93,9 @@ extension LambdaRuntime { self.init(handler: handler) } - /// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a `Void` return type**. + /// Initialize an instance with a `LambdaHandler` defined in the form of a closure **with a `Void` return type**. /// - Parameter body: The handler in the form of a closure. - /// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type. ``JSONDecoder()`` used as default. + /// - Parameter decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. `JSONDecoder()` used as default. public convenience init( body: @escaping (Event, LambdaContext) async throws -> Void, decoder: JSONDecoder = JSONDecoder() diff --git a/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift b/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift index fdc4c0b4..7a0a9a22 100644 --- a/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift +++ b/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift @@ -15,9 +15,9 @@ import NIOCore /// The protocol a decoder must conform to so that it can be used with ``LambdaCodableAdapter`` to decode incoming -/// ``ByteBuffer`` events. +/// `ByteBuffer` events. public protocol LambdaEventDecoder { - /// Decode the ``ByteBuffer`` representing the received event into the generic ``Event`` type + /// Decode the `ByteBuffer` representing the received event into the generic `Event` type /// the handler will receive. /// - Parameters: /// - type: The type of the object to decode the buffer into. @@ -27,14 +27,14 @@ public protocol LambdaEventDecoder { } /// The protocol an encoder must conform to so that it can be used with ``LambdaCodableAdapter`` to encode the generic -/// ``Output`` object into a ``ByteBuffer``. +/// ``LambdaOutputEncoder/Output`` object into a `ByteBuffer`. public protocol LambdaOutputEncoder { associatedtype Output - /// Encode the generic type `Output` the handler has returned into a ``ByteBuffer``. + /// Encode the generic type `Output` the handler has returned into a `ByteBuffer`. /// - Parameters: - /// - value: The object to encode into a ``ByteBuffer``. - /// - buffer: The ``ByteBuffer`` where the encoded value will be written to. + /// - value: The object to encode into a `ByteBuffer`. + /// - buffer: The `ByteBuffer` where the encoded value will be written to. func encode(_ value: Output, into buffer: inout ByteBuffer) throws } @@ -62,7 +62,7 @@ public struct LambdaHandlerAdapter< self.handler = handler } - /// Passes the generic ``Event`` object to the ``LambdaHandler/handle(_:context:)`` function, and + /// Passes the generic `Event` object to the ``LambdaHandler/handle(_:context:)`` function, and /// the resulting output is then written to ``LambdaWithBackgroundProcessingHandler``'s `outputWriter`. /// - Parameters: /// - event: The received event. @@ -93,9 +93,9 @@ public struct LambdaCodableAdapter< @usableFromInline var byteBuffer: ByteBuffer = .init() /// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output. - /// - Parameters: - /// - encoder: The encoder object that will be used to encode the generic ``Output`` obtained from the `handler`'s `outputWriter` into a ``ByteBuffer``. - /// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`. + /// - Parameters: + /// - encoder: The encoder object that will be used to encode the generic `Output` obtained from the `handler`'s `outputWriter` into a `ByteBuffer`. + /// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`. /// - handler: The handler object. @inlinable public init(encoder: Encoder, decoder: Decoder, handler: Handler) where Output: Encodable { @@ -106,8 +106,8 @@ public struct LambdaCodableAdapter< /// Initializes an instance given a decoder, and a handler with a `Void` output. /// - Parameters: - /// - decoder: The decoder object that will be used to decode the received ``ByteBuffer`` event into the generic ``Event`` type served to the `handler`. - /// - handler: The handler object. + /// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`. + /// - handler: The handler object. @inlinable public init(decoder: Decoder, handler: Handler) where Output == Void, Encoder == VoidEncoder { self.encoder = VoidEncoder() @@ -145,7 +145,7 @@ where Output == Encoder.Output { /// Initializes an instance given an encoder and an underlying ``LambdaResponseStreamWriter``. /// - Parameters: - /// - encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``, which will then be passed to `streamWriter`. + /// - encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`, which will then be passed to `streamWriter`. /// - streamWriter: The underlying ``LambdaResponseStreamWriter`` that will be wrapped. @inlinable public init(encoder: Encoder, streamWriter: Base) { diff --git a/Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift b/Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift index e112e29a..9b6f8300 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift +++ b/Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift @@ -14,7 +14,7 @@ import NIOCore -/// The base handler protocol that receives a ``ByteBuffer`` representing the incoming event and returns the response as a ``ByteBuffer`` too. +/// The base handler protocol that receives a `ByteBuffer` representing the incoming event and returns the response as a `ByteBuffer` too. /// This handler protocol supports response streaming. Bytes can be streamed outwards through the ``LambdaResponseStreamWriter`` /// passed as an argument in the ``handle(_:responseWriter:context:)`` function. /// Background work can also be executed after returning the response. After closing the response stream by calling @@ -69,12 +69,12 @@ public protocol LambdaHandler { /// The body of the request sent to Lambda will be decoded into this type for the handler to consume. associatedtype Event: Decodable /// Generic output type. - /// This is the return type of the ``handle(_:context:)`` function. + /// This is the return type of the ``LambdaHandler/handle(_:context:)`` function. associatedtype Output /// Implement the business logic of the Lambda function here. /// - Parameters: - /// - event: The generic ``Event`` object representing the invocation's input data. + /// - event: The generic ``LambdaHandler/Event`` object representing the invocation's input data. /// - context: The ``LambdaContext`` containing the invocation's metadata. /// - Returns: A generic ``Output`` object representing the computed result. func handle(_ event: Event, context: LambdaContext) async throws -> Output @@ -83,8 +83,9 @@ public protocol LambdaHandler { /// This protocol is exactly like ``LambdaHandler``, with the only difference being the added support for executing background /// work after the result has been sent to the AWS Lambda control plane. /// This is achieved by not having a return type in the `handle` function. The output is instead written into a -/// ``LambdaResponseWriter``that is passed in as an argument, meaning that the ``handle(_:)`` function is then free to implement -/// any background work after the result has been sent to the AWS Lambda control plane. +/// ``LambdaResponseWriter``that is passed in as an argument, meaning that the +/// ``LambdaWithBackgroundProcessingHandler/handle(_:outputWriter:context:)`` function is then +/// free to implement any background work after the result has been sent to the AWS Lambda control plane. public protocol LambdaWithBackgroundProcessingHandler { /// Generic input type. /// 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 { /// Implement the business logic of the Lambda function here. /// - Parameters: - /// - event: The generic ``Event`` object representing the invocation's input data. + /// - event: The generic ``LambdaWithBackgroundProcessingHandler/Event`` object representing the invocation's input data. /// - outputWriter: The writer to send the computed response to. A call to `outputWriter.write(_:)` will return the response to the AWS Lambda response endpoint. /// Any background work can then be executed before returning. /// - context: The ``LambdaContext`` containing the invocation's metadata. @@ -111,7 +112,7 @@ public protocol LambdaWithBackgroundProcessingHandler { /// 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. public protocol LambdaResponseWriter { associatedtype Output - /// Sends the generic ``Output`` object (representing the computed result of the handler) + /// Sends the generic ``LambdaResponseWriter/Output`` object (representing the computed result of the handler) /// to the AWS Lambda response endpoint. /// This function simply serves as a mechanism to return the computed result from a handler function /// without an explicit `return`. @@ -131,18 +132,18 @@ public struct StreamingClosureHandler: StreamingLambdaHandler { self.body = body } - /// Calls the provided `self.body` closure with the ``ByteBuffer`` invocation event, the ``LambdaResponseStreamWriter``, and the ``LambdaContext`` + /// Calls the provided `self.body` closure with the `ByteBuffer` invocation event, the ``LambdaResponseStreamWriter``, and the ``LambdaContext`` /// - Parameters: /// - event: The invocation's input data. /// - responseWriter: A ``LambdaResponseStreamWriter`` to write the invocation's response to. - /// If no response or error is written to `responseWriter` an error will be reported to the invoker. + /// If no response or error is written to `responseWriter` an error will be reported to the invoker. /// - context: The ``LambdaContext`` containing the invocation's metadata. public func handle( - _ request: ByteBuffer, + _ event: ByteBuffer, responseWriter: some LambdaResponseStreamWriter, context: LambdaContext ) async throws { - try await self.body(request, responseWriter, context) + try await self.body(event, responseWriter, context) } } @@ -163,9 +164,9 @@ public struct ClosureHandler: LambdaHandler { self.body = body } - /// Calls the provided `self.body` closure with the generic ``Event`` object representing the incoming event, and the ``LambdaContext`` + /// Calls the provided `self.body` closure with the generic `Event` object representing the incoming event, and the ``LambdaContext`` /// - Parameters: - /// - event: The generic ``Event`` object representing the invocation's input data. + /// - event: The generic `Event` object representing the invocation's input data. /// - context: The ``LambdaContext`` containing the invocation's metadata. public func handle(_ event: Event, context: LambdaContext) async throws -> Output { try await self.body(event, context) @@ -183,8 +184,8 @@ extension LambdaRuntime { /// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a non-`Void` return type**, an encoder, and a decoder. /// - Parameter body: The handler in the form of a closure. - /// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``. - /// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type. + /// - Parameter encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`. + /// - Parameter decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. public convenience init< Event: Decodable, Output: Encodable, @@ -214,9 +215,9 @@ extension LambdaRuntime { } /// Initialize an instance with a ``LambdaHandler`` defined in the form of a closure **with a `Void` return type**, an encoder, and a decoder. - /// - Parameter body: The handler in the form of a closure. - /// - Parameter encoder: The encoder object that will be used to encode the generic ``Output`` into a ``ByteBuffer``. - /// - Parameter decoder: The decoder object that will be used to decode the incoming ``ByteBuffer`` event into the generic ``Event`` type. + /// - Parameters: + /// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. + /// - body: The handler in the form of a closure. public convenience init( decoder: Decoder, body: @escaping (Event, LambdaContext) async throws -> Void