Skip to content

Fix docs CI #392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Plugins/AWSLambdaPackager/PluginUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 7 additions & 7 deletions Sources/AWSLambdaRuntime/Lambda+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public struct LambdaJSONOutputEncoder<Output: Encodable>: 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,
Expand All @@ -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<Event: Decodable, Output>(
body: @escaping (Event, LambdaContext) async throws -> Output,
encoder: JSONEncoder = JSONEncoder(),
Expand All @@ -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<Event: Decodable>(
body: @escaping (Event, LambdaContext) async throws -> Void,
decoder: JSONDecoder = JSONDecoder()
Expand Down
26 changes: 13 additions & 13 deletions Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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()
Expand Down Expand Up @@ -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) {
Expand Down
37 changes: 19 additions & 18 deletions Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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<Output> {
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`.
Expand All @@ -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)
}
}

Expand All @@ -163,9 +164,9 @@ public struct ClosureHandler<Event: Decodable, Output>: 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)
Expand All @@ -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,
Expand Down Expand Up @@ -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<Event: Decodable, Decoder: LambdaEventDecoder>(
decoder: Decoder,
body: @escaping (Event, LambdaContext) async throws -> Void
Expand Down
Loading