From 534b34a1ac4c1ab8a42e7947e61051d186abe04e Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Sat, 1 Mar 2025 14:08:11 +0100 Subject: [PATCH 01/14] Apply package traits --- Package.swift | 28 ++- .../ControlPlaneRequest.swift | 0 .../ControlPlaneRequestEncoder.swift | 0 .../Docs.docc}/Deployment.md | 0 .../Docs.docc}/Documentation.md | 0 .../Docs.docc}/Proposals/0001-v2-api.md | 0 .../Docs.docc}/Resources/code/.shellcheckrc | 0 .../Resources/code/03-01-01-package-init.sh | 0 .../Resources/code/03-01-02-package-init.sh | 0 .../Resources/code/03-01-03-package-init.sh | 0 .../Resources/code/03-01-04-package-init.sh | 0 .../Resources/code/03-02-01-package.swift | 0 .../Resources/code/03-02-02-package.swift | 0 .../Resources/code/03-02-03-package.swift | 0 .../Resources/code/03-02-04-package.swift | 0 .../Resources/code/03-02-05-package.swift | 0 .../Resources/code/03-03-01-main.swift | 0 .../Resources/code/03-03-02-main.swift | 0 .../Resources/code/03-03-03-main.swift | 0 .../Resources/code/03-03-04-main.swift | 0 .../Resources/code/03-03-05-main.swift | 0 .../Resources/code/03-03-06-main.swift | 0 .../Resources/code/03-03-07-main.swift | 0 .../Resources/code/03-04-02-console-output.sh | 0 .../Resources/code/03-04-03-curl.sh | 0 .../Resources/code/03-04-04-curl.sh | 0 .../Resources/code/03-04-06-terminal.sh | 0 .../Resources/code/03-04-07-terminal.sh | 0 .../Resources/code/04-01-02-plugin-archive.sh | 0 .../Resources/code/04-01-03-plugin-archive.sh | 0 .../Resources/code/04-01-04-plugin-archive.sh | 0 .../Resources/code/04-03-01-aws-cli.sh | 0 .../code/04-03-02-lambda-invoke-hidden.sh | 0 .../Resources/code/04-03-02-lambda-invoke.sh | 0 .../Resources/code/04-03-03-lambda-invoke.sh | 0 .../Resources/code/04-03-04-lambda-invoke.sh | 0 .../Resources/code/04-03-05-lambda-invoke.sh | 0 .../deployment/console-10-regions.png | Bin .../deployment/console-20-dashboard.png | Bin .../deployment/console-30-create-function.png | Bin .../deployment/console-40-select-zip-file.png | Bin .../deployment/console-50-upload-zip.png | Bin .../console-60-prepare-test-event.png | Bin .../console-70-view-invocation-response.png | Bin .../deployment/console-80-delete-function.png | Bin .../deployment/console-80-delete-role.png | Bin .../tutorials/00-swift_on_lambda.png | Bin .../tutorials/01-swift_on_lambda.png | Bin .../tutorials/03-01-terminal-package-init.png | Bin .../Resources/tutorials/03-01-xcode@2x.png | Bin .../tutorials/03-01-xcode~dark@2x.png | Bin .../tutorials/03-02-swift-package-manager.png | Bin .../tutorials/03-03-swift-code-xcode.png | Bin .../tutorials/03-04-01-compile-run@2x.png.png | Bin .../03-04-01-compile-run~dark@2x.png | Bin .../tutorials/03-04-test-locally.png | Bin .../tutorials/03-swift_on_lambda.png | Bin .../tutorials/04-01-01-docker-started@2x.png | Bin .../tutorials/04-01-compile-for-linux.png | Bin .../tutorials/04-02-01-console-login@2x.png | Bin .../tutorials/04-02-02-console-login@2x.png | Bin .../tutorials/04-02-03-select-region@2x.png | Bin .../tutorials/04-02-04-select-lambda@2x.png | Bin .../04-02-04-select-lambda~dark@2x.png | Bin .../tutorials/04-02-05-create-function@2x.png | Bin .../04-02-05-create-function~dark@2x.png | Bin .../tutorials/04-02-06-create-function@2x.png | Bin .../04-02-06-create-function~dark@2x.png | Bin .../tutorials/04-02-07-upload-zip@2x.png | Bin .../tutorials/04-02-07-upload-zip~dark@2x.png | Bin .../tutorials/04-02-08-upload-zip@2x.png | Bin .../tutorials/04-02-08-upload-zip~dark@2x.png | Bin .../tutorials/04-02-09-test-lambda@2x.png | Bin .../04-02-09-test-lambda~dark@2x.png | Bin .../04-02-10-test-lambda-result@2x.png | Bin .../04-02-10-test-lambda-result~dark@2x.png | Bin .../tutorials/04-02-create-lambda.png | Bin .../tutorials/04-03-invoke-lambda.png | Bin .../tutorials/04-swift_on_lambda.png | Bin .../Docs.docc}/quick-setup.md | 0 .../Docs.docc}/tutorials/01-overview.tutorial | 0 .../tutorials/02-what-is-lambda.tutorial | 0 .../tutorials/03-prerequisites.tutorial | 0 .../tutorials/03-write-function.tutorial | 0 .../tutorials/04-deploy-function.tutorial | 0 .../tutorials/table-of-content.tutorial | 0 .../Context+Foundation.swift | 4 +- .../FoundationSupport/Lambda+JSON.swift | 138 +++++++++++ .../Vendored/ByteBuffer-foundation.swift | 2 + .../Vendored/JSON+ByteBuffer.swift | 2 + Sources/AWSLambdaRuntime/Lambda+Codable.swift | 217 ++++++++++-------- .../Lambda+LocalServer.swift | 4 +- .../Lambda.swift | 0 .../LambdaContext.swift | 0 .../LambdaHandlers.swift | 0 .../LambdaRequestID.swift | 0 .../LambdaRuntime+ServiceLifecycle.swift | 12 + .../LambdaRuntime.swift | 2 +- .../LambdaRuntimeClient.swift | 0 .../LambdaRuntimeClientProtocol.swift | 0 .../LambdaRuntimeError.swift | 0 .../Utils.swift | 0 .../AWSLambdaRuntimeCore/Lambda+Codable.swift | 162 ------------- .../ControlPlaneRequestEncoderTests.swift | 2 +- .../InvocationTests.swift | 2 +- .../LambdaMockClient.swift | 2 +- .../LambdaRequestIDTests.swift | 2 +- .../LambdaRunLoopTests.swift | 2 +- .../LambdaRuntimeClientTests.swift | 2 +- .../MockLambdaServer.swift | 2 +- .../AWSLambdaRuntimeCoreTests/UtilsTest.swift | 2 +- 111 files changed, 304 insertions(+), 283 deletions(-) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/ControlPlaneRequest.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/ControlPlaneRequestEncoder.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Deployment.md (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Documentation.md (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Proposals/0001-v2-api.md (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/.shellcheckrc (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-01-01-package-init.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-01-02-package-init.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-01-03-package-init.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-01-04-package-init.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-02-01-package.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-02-02-package.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-02-03-package.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-02-04-package.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-02-05-package.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-01-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-02-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-03-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-04-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-05-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-06-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-03-07-main.swift (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-04-02-console-output.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-04-03-curl.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-04-04-curl.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-04-06-terminal.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/03-04-07-terminal.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-01-02-plugin-archive.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-01-03-plugin-archive.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-01-04-plugin-archive.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-03-01-aws-cli.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-03-02-lambda-invoke-hidden.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-03-02-lambda-invoke.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-03-03-lambda-invoke.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-03-04-lambda-invoke.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/code/04-03-05-lambda-invoke.sh (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-10-regions.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-20-dashboard.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-30-create-function.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-40-select-zip-file.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-50-upload-zip.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-60-prepare-test-event.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-70-view-invocation-response.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-80-delete-function.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/deployment/console-80-delete-role.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/00-swift_on_lambda.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/01-swift_on_lambda.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-01-terminal-package-init.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-01-xcode@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-01-xcode~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-02-swift-package-manager.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-03-swift-code-xcode.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-04-01-compile-run@2x.png.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-04-01-compile-run~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-04-test-locally.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/03-swift_on_lambda.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-01-01-docker-started@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-01-compile-for-linux.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-01-console-login@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-02-console-login@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-03-select-region@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-04-select-lambda@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-04-select-lambda~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-05-create-function@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-05-create-function~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-06-create-function@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-06-create-function~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-07-upload-zip@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-07-upload-zip~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-08-upload-zip@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-08-upload-zip~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-09-test-lambda@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-09-test-lambda~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-10-test-lambda-result@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-10-test-lambda-result~dark@2x.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-02-create-lambda.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-03-invoke-lambda.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/Resources/tutorials/04-swift_on_lambda.png (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/quick-setup.md (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/tutorials/01-overview.tutorial (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/tutorials/02-what-is-lambda.tutorial (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/tutorials/03-prerequisites.tutorial (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/tutorials/03-write-function.tutorial (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/tutorials/04-deploy-function.tutorial (100%) rename Sources/{AWSLambdaRuntimeCore/Documentation.docc => AWSLambdaRuntime/Docs.docc}/tutorials/table-of-content.tutorial (100%) rename Sources/AWSLambdaRuntime/{ => FoundationSupport}/Context+Foundation.swift (93%) create mode 100644 Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift rename Sources/AWSLambdaRuntime/{ => FoundationSupport}/Vendored/ByteBuffer-foundation.swift (98%) rename Sources/AWSLambdaRuntime/{ => FoundationSupport}/Vendored/JSON+ByteBuffer.swift (98%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/Lambda+LocalServer.swift (99%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/Lambda.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaContext.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaHandlers.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaRequestID.swift (100%) create mode 100644 Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaRuntime.swift (99%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaRuntimeClient.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaRuntimeClientProtocol.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/LambdaRuntimeError.swift (100%) rename Sources/{AWSLambdaRuntimeCore => AWSLambdaRuntime}/Utils.swift (100%) delete mode 100644 Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift diff --git a/Package.swift b/Package.swift index 9eac9771..47c817c6 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:6.0 +// swift-tools-version:6.1 import PackageDescription @@ -8,34 +8,38 @@ let package = Package( products: [ // this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods .library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]), - // this has all the main functionality for lambda and it does not link Foundation - .library(name: "AWSLambdaRuntimeCore", targets: ["AWSLambdaRuntimeCore"]), // plugin to package the lambda, creating an archive that can be uploaded to AWS // requires Linux or at least macOS v15 .plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]), // for testing only .library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]), ], + traits: [ + "FoundationJSONSupport", + "ServiceLifecycleSupport", + "LocalServerSupport", + .default( + enabledTraits: [ + "FoundationJSONSupport", + "ServiceLifecycleSupport", + "LocalServerSupport", + ] + ) + ], dependencies: [ .package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4"), + .package(url: "https://github.com/apple/swift-service-lifecycle.git", from: "2.6.3", traits: ["ServiceLifecycleSupport"]), ], targets: [ .target( name: "AWSLambdaRuntime", dependencies: [ - .byName(name: "AWSLambdaRuntimeCore"), .product(name: "NIOCore", package: "swift-nio"), - ] - ), - .target( - name: "AWSLambdaRuntimeCore", - dependencies: [ .product(name: "DequeModule", package: "swift-collections"), .product(name: "Logging", package: "swift-log"), .product(name: "NIOHTTP1", package: "swift-nio"), - .product(name: "NIOCore", package: "swift-nio"), .product(name: "NIOPosix", package: "swift-nio"), ] ), @@ -58,7 +62,7 @@ let package = Package( .testTarget( name: "AWSLambdaRuntimeCoreTests", dependencies: [ - .byName(name: "AWSLambdaRuntimeCore"), + .byName(name: "AWSLambdaRuntime"), .product(name: "NIOTestUtils", package: "swift-nio"), .product(name: "NIOFoundationCompat", package: "swift-nio"), ] @@ -66,7 +70,7 @@ let package = Package( .testTarget( name: "AWSLambdaRuntimeTests", dependencies: [ - .byName(name: "AWSLambdaRuntimeCore"), +// .byName(name: "AWSLambdaRuntimeCore"), .byName(name: "AWSLambdaRuntime"), ] ), diff --git a/Sources/AWSLambdaRuntimeCore/ControlPlaneRequest.swift b/Sources/AWSLambdaRuntime/ControlPlaneRequest.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/ControlPlaneRequest.swift rename to Sources/AWSLambdaRuntime/ControlPlaneRequest.swift diff --git a/Sources/AWSLambdaRuntimeCore/ControlPlaneRequestEncoder.swift b/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/ControlPlaneRequestEncoder.swift rename to Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Deployment.md b/Sources/AWSLambdaRuntime/Docs.docc/Deployment.md similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Deployment.md rename to Sources/AWSLambdaRuntime/Docs.docc/Deployment.md diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Documentation.md b/Sources/AWSLambdaRuntime/Docs.docc/Documentation.md similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Documentation.md rename to Sources/AWSLambdaRuntime/Docs.docc/Documentation.md diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals/0001-v2-api.md b/Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals/0001-v2-api.md rename to Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/.shellcheckrc b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/.shellcheckrc similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/.shellcheckrc rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/.shellcheckrc diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-01-package-init.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-01-package-init.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-01-package-init.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-01-package-init.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-02-package-init.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-02-package-init.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-02-package-init.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-02-package-init.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-03-package-init.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-03-package-init.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-03-package-init.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-03-package-init.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-04-package-init.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-04-package-init.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-01-04-package-init.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-01-04-package-init.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-01-package.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-01-package.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-01-package.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-01-package.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-02-package.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-02-package.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-02-package.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-02-package.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-03-package.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-03-package.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-03-package.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-03-package.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-04-package.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-04-package.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-04-package.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-04-package.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-05-package.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-05-package.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-02-05-package.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-02-05-package.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-01-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-01-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-01-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-01-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-02-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-02-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-02-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-02-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-03-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-03-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-03-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-03-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-04-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-04-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-04-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-04-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-05-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-05-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-05-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-05-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-06-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-06-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-06-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-06-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-07-main.swift b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-07-main.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-03-07-main.swift rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-03-07-main.swift diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-02-console-output.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-02-console-output.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-02-console-output.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-02-console-output.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-03-curl.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-03-curl.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-03-curl.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-03-curl.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-04-curl.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-04-curl.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-04-curl.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-04-curl.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-06-terminal.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-06-terminal.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-06-terminal.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-06-terminal.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-07-terminal.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/03-04-07-terminal.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-02-plugin-archive.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-02-plugin-archive.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-02-plugin-archive.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-02-plugin-archive.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-03-plugin-archive.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-03-plugin-archive.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-03-plugin-archive.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-03-plugin-archive.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-04-plugin-archive.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-04-plugin-archive.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-01-04-plugin-archive.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-01-04-plugin-archive.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-01-aws-cli.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-01-aws-cli.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-01-aws-cli.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-01-aws-cli.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-02-lambda-invoke-hidden.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-02-lambda-invoke-hidden.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-02-lambda-invoke-hidden.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-02-lambda-invoke-hidden.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-02-lambda-invoke.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-02-lambda-invoke.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-02-lambda-invoke.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-02-lambda-invoke.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-03-lambda-invoke.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-03-lambda-invoke.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-03-lambda-invoke.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-03-lambda-invoke.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-04-lambda-invoke.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-04-lambda-invoke.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-04-lambda-invoke.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-04-lambda-invoke.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-05-lambda-invoke.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-05-lambda-invoke.sh similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/code/04-03-05-lambda-invoke.sh rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/code/04-03-05-lambda-invoke.sh diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-10-regions.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-10-regions.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-10-regions.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-10-regions.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-20-dashboard.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-20-dashboard.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-20-dashboard.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-20-dashboard.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-30-create-function.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-30-create-function.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-30-create-function.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-30-create-function.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-40-select-zip-file.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-40-select-zip-file.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-40-select-zip-file.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-40-select-zip-file.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-50-upload-zip.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-50-upload-zip.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-50-upload-zip.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-50-upload-zip.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-60-prepare-test-event.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-60-prepare-test-event.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-60-prepare-test-event.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-60-prepare-test-event.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-70-view-invocation-response.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-70-view-invocation-response.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-70-view-invocation-response.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-70-view-invocation-response.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-80-delete-function.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-80-delete-function.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-80-delete-function.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-80-delete-function.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-80-delete-role.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-80-delete-role.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/deployment/console-80-delete-role.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/deployment/console-80-delete-role.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/00-swift_on_lambda.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/00-swift_on_lambda.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/00-swift_on_lambda.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/00-swift_on_lambda.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/01-swift_on_lambda.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/01-swift_on_lambda.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/01-swift_on_lambda.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/01-swift_on_lambda.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-01-terminal-package-init.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-01-terminal-package-init.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-01-terminal-package-init.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-01-terminal-package-init.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-01-xcode@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-01-xcode@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-01-xcode@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-01-xcode@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-01-xcode~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-01-xcode~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-01-xcode~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-01-xcode~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-02-swift-package-manager.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-02-swift-package-manager.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-02-swift-package-manager.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-02-swift-package-manager.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-03-swift-code-xcode.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-03-swift-code-xcode.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-03-swift-code-xcode.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-03-swift-code-xcode.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-04-01-compile-run@2x.png.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-04-01-compile-run@2x.png.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-04-01-compile-run@2x.png.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-04-01-compile-run@2x.png.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-04-01-compile-run~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-04-01-compile-run~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-04-01-compile-run~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-04-01-compile-run~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-04-test-locally.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-04-test-locally.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-04-test-locally.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-04-test-locally.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-swift_on_lambda.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-swift_on_lambda.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/03-swift_on_lambda.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/03-swift_on_lambda.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-01-01-docker-started@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-01-01-docker-started@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-01-01-docker-started@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-01-01-docker-started@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-01-compile-for-linux.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-01-compile-for-linux.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-01-compile-for-linux.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-01-compile-for-linux.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-01-console-login@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-01-console-login@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-01-console-login@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-01-console-login@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-02-console-login@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-02-console-login@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-02-console-login@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-02-console-login@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-03-select-region@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-03-select-region@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-03-select-region@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-03-select-region@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-04-select-lambda@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-04-select-lambda@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-04-select-lambda@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-04-select-lambda@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-04-select-lambda~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-04-select-lambda~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-04-select-lambda~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-04-select-lambda~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-05-create-function@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-05-create-function@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-05-create-function@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-05-create-function@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-05-create-function~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-05-create-function~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-05-create-function~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-05-create-function~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-06-create-function@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-06-create-function@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-06-create-function@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-06-create-function@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-06-create-function~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-06-create-function~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-06-create-function~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-06-create-function~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-07-upload-zip@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-07-upload-zip@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-07-upload-zip@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-07-upload-zip@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-07-upload-zip~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-07-upload-zip~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-07-upload-zip~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-07-upload-zip~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-08-upload-zip@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-08-upload-zip@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-08-upload-zip@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-08-upload-zip@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-08-upload-zip~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-08-upload-zip~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-08-upload-zip~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-08-upload-zip~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-09-test-lambda@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-09-test-lambda@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-09-test-lambda@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-09-test-lambda@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-09-test-lambda~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-09-test-lambda~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-09-test-lambda~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-09-test-lambda~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-10-test-lambda-result@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-10-test-lambda-result@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-10-test-lambda-result@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-10-test-lambda-result@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-10-test-lambda-result~dark@2x.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-10-test-lambda-result~dark@2x.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-10-test-lambda-result~dark@2x.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-10-test-lambda-result~dark@2x.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-create-lambda.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-create-lambda.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-02-create-lambda.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-02-create-lambda.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-03-invoke-lambda.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-03-invoke-lambda.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-03-invoke-lambda.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-03-invoke-lambda.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-swift_on_lambda.png b/Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-swift_on_lambda.png similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/Resources/tutorials/04-swift_on_lambda.png rename to Sources/AWSLambdaRuntime/Docs.docc/Resources/tutorials/04-swift_on_lambda.png diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/quick-setup.md b/Sources/AWSLambdaRuntime/Docs.docc/quick-setup.md similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/quick-setup.md rename to Sources/AWSLambdaRuntime/Docs.docc/quick-setup.md diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/01-overview.tutorial b/Sources/AWSLambdaRuntime/Docs.docc/tutorials/01-overview.tutorial similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/01-overview.tutorial rename to Sources/AWSLambdaRuntime/Docs.docc/tutorials/01-overview.tutorial diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/02-what-is-lambda.tutorial b/Sources/AWSLambdaRuntime/Docs.docc/tutorials/02-what-is-lambda.tutorial similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/02-what-is-lambda.tutorial rename to Sources/AWSLambdaRuntime/Docs.docc/tutorials/02-what-is-lambda.tutorial diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/03-prerequisites.tutorial b/Sources/AWSLambdaRuntime/Docs.docc/tutorials/03-prerequisites.tutorial similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/03-prerequisites.tutorial rename to Sources/AWSLambdaRuntime/Docs.docc/tutorials/03-prerequisites.tutorial diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/03-write-function.tutorial b/Sources/AWSLambdaRuntime/Docs.docc/tutorials/03-write-function.tutorial similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/03-write-function.tutorial rename to Sources/AWSLambdaRuntime/Docs.docc/tutorials/03-write-function.tutorial diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/04-deploy-function.tutorial b/Sources/AWSLambdaRuntime/Docs.docc/tutorials/04-deploy-function.tutorial similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/04-deploy-function.tutorial rename to Sources/AWSLambdaRuntime/Docs.docc/tutorials/04-deploy-function.tutorial diff --git a/Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/table-of-content.tutorial b/Sources/AWSLambdaRuntime/Docs.docc/tutorials/table-of-content.tutorial similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Documentation.docc/tutorials/table-of-content.tutorial rename to Sources/AWSLambdaRuntime/Docs.docc/tutorials/table-of-content.tutorial diff --git a/Sources/AWSLambdaRuntime/Context+Foundation.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift similarity index 93% rename from Sources/AWSLambdaRuntime/Context+Foundation.swift rename to Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift index 105b7765..a60e32e4 100644 --- a/Sources/AWSLambdaRuntime/Context+Foundation.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift @@ -12,8 +12,7 @@ // //===----------------------------------------------------------------------===// -import AWSLambdaRuntimeCore - +#if FoundationJSONSupport #if canImport(FoundationEssentials) import FoundationEssentials #else @@ -26,3 +25,4 @@ extension LambdaContext { return Date(timeIntervalSince1970: secondsSinceEpoch) } } +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift new file mode 100644 index 00000000..c834989b --- /dev/null +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift @@ -0,0 +1,138 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the SwiftAWSLambdaRuntime open source project +// +// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + +#if FoundationJSONSupport +import NIOCore + +#if canImport(FoundationEssentials) +import FoundationEssentials +#else +import struct Foundation.Data +import class Foundation.JSONDecoder +import class Foundation.JSONEncoder +#endif + +public struct LambdaJSONEventDecoder: LambdaEventDecoder { + @usableFromInline let jsonDecoder: JSONDecoder + + @inlinable + public init(_ jsonDecoder: JSONDecoder) { + self.jsonDecoder = jsonDecoder + } + + @inlinable + public func decode(_ type: Event.Type, from buffer: NIOCore.ByteBuffer) throws -> Event + where Event: Decodable { + try buffer.getJSONDecodable( + Event.self, + decoder: self.jsonDecoder, + at: buffer.readerIndex, + length: buffer.readableBytes + )! // must work, enough readable bytes + } +} + +public struct LambdaJSONOutputEncoder: LambdaOutputEncoder { + @usableFromInline let jsonEncoder: JSONEncoder + + @inlinable + public init(_ jsonEncoder: JSONEncoder) { + self.jsonEncoder = jsonEncoder + } + + @inlinable + public func encode(_ value: Output, into buffer: inout ByteBuffer) throws { + try buffer.writeJSONEncodable(value, encoder: self.jsonEncoder) + } +} + +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`. By default, a JSONEncoder is used. + /// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`. By default, a JSONDecoder is used. + /// - handler: The handler object. + public init( + encoder: JSONEncoder = JSONEncoder(), + decoder: JSONDecoder = JSONDecoder(), + handler: sending Handler + ) + where + Output: Encodable, + Output == Handler.Output, + Encoder == LambdaJSONOutputEncoder, + Decoder == LambdaJSONEventDecoder + { + self.init( + encoder: LambdaJSONOutputEncoder(encoder), + decoder: LambdaJSONEventDecoder(decoder), + handler: handler + ) + } +} + +extension LambdaRuntime { + /// Initialize an instance with a `LambdaHandler` defined in the form of a closure **with a non-`Void` return type**. + /// - Parameters: + /// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. `JSONDecoder()` used as default. + /// - encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`. `JSONEncoder()` used as default. + /// - body: The handler in the form of a closure. + public convenience init( + decoder: JSONDecoder = JSONDecoder(), + encoder: JSONEncoder = JSONEncoder(), + body: sending @escaping (Event, LambdaContext) async throws -> Output + ) + where + Handler == LambdaCodableAdapter< + LambdaHandlerAdapter>, + Event, + Output, + LambdaJSONEventDecoder, + LambdaJSONOutputEncoder + > + { + let handler = LambdaCodableAdapter( + encoder: encoder, + decoder: decoder, + handler: LambdaHandlerAdapter(handler: ClosureHandler(body: body)) + ) + + self.init(handler: handler) + } + + /// 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. + public convenience init( + decoder: JSONDecoder = JSONDecoder(), + body: sending @escaping (Event, LambdaContext) async throws -> Void + ) + where + Handler == LambdaCodableAdapter< + LambdaHandlerAdapter>, + Event, + Void, + LambdaJSONEventDecoder, + VoidEncoder + > + { + let handler = LambdaCodableAdapter( + decoder: LambdaJSONEventDecoder(decoder), + handler: LambdaHandlerAdapter(handler: ClosureHandler(body: body)) + ) + + self.init(handler: handler) + } +} +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/Vendored/ByteBuffer-foundation.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift similarity index 98% rename from Sources/AWSLambdaRuntime/Vendored/ByteBuffer-foundation.swift rename to Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift index 8dbd7326..320381a0 100644 --- a/Sources/AWSLambdaRuntime/Vendored/ByteBuffer-foundation.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift @@ -26,6 +26,7 @@ // //===----------------------------------------------------------------------===// +#if FoundationJSONSupport import NIOCore #if canImport(FoundationEssentials) @@ -104,3 +105,4 @@ extension ByteBuffer { } } } +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/Vendored/JSON+ByteBuffer.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift similarity index 98% rename from Sources/AWSLambdaRuntime/Vendored/JSON+ByteBuffer.swift rename to Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift index 092b2368..81b8e940 100644 --- a/Sources/AWSLambdaRuntime/Vendored/JSON+ByteBuffer.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift @@ -26,6 +26,7 @@ // //===----------------------------------------------------------------------===// +#if FoundationJSONSupport import NIOCore #if canImport(FoundationEssentials) @@ -147,3 +148,4 @@ extension JSONEncoder { return buffer } } +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/Lambda+Codable.swift b/Sources/AWSLambdaRuntime/Lambda+Codable.swift index ccb37dd8..a77c0542 100644 --- a/Sources/AWSLambdaRuntime/Lambda+Codable.swift +++ b/Sources/AWSLambdaRuntime/Lambda+Codable.swift @@ -2,7 +2,7 @@ // // This source file is part of the SwiftAWSLambdaRuntime open source project // -// Copyright (c) 2017-2022 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Copyright (c) 2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information @@ -12,126 +12,151 @@ // //===----------------------------------------------------------------------===// -@_exported import AWSLambdaRuntimeCore import NIOCore -#if canImport(FoundationEssentials) -import FoundationEssentials -#else -import struct Foundation.Data -import class Foundation.JSONDecoder -import class Foundation.JSONEncoder -#endif +/// The protocol a decoder must conform to so that it can be used with ``LambdaCodableAdapter`` to decode incoming +/// `ByteBuffer` events. +public protocol LambdaEventDecoder { + /// 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. + /// - buffer: The buffer to be decoded. + /// - Returns: An object containing the decoded data. + func decode(_ type: Event.Type, from buffer: ByteBuffer) throws -> Event +} + +/// The protocol an encoder must conform to so that it can be used with ``LambdaCodableAdapter`` to encode the generic +/// ``LambdaOutputEncoder/Output`` object into a `ByteBuffer`. +public protocol LambdaOutputEncoder { + associatedtype Output + + /// 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. + func encode(_ value: Output, into buffer: inout ByteBuffer) throws +} + +public struct VoidEncoder: LambdaOutputEncoder { + public typealias Output = Void -public struct LambdaJSONEventDecoder: LambdaEventDecoder { - @usableFromInline let jsonDecoder: JSONDecoder + public init() {} @inlinable - public init(_ jsonDecoder: JSONDecoder) { - self.jsonDecoder = jsonDecoder + public func encode(_ value: Void, into buffer: inout NIOCore.ByteBuffer) throws {} +} + +/// Adapts a ``LambdaHandler`` conforming handler to conform to ``LambdaWithBackgroundProcessingHandler``. +public struct LambdaHandlerAdapter< + Event: Decodable, + Output, + Handler: LambdaHandler +>: LambdaWithBackgroundProcessingHandler where Handler.Event == Event, Handler.Output == Output { + @usableFromInline let handler: Handler + + /// Initializes an instance given a concrete handler. + /// - Parameter handler: The ``LambdaHandler`` conforming handler that is to be adapted to ``LambdaWithBackgroundProcessingHandler``. + @inlinable + public init(handler: sending Handler) { + self.handler = handler } + /// 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. + /// - outputWriter: The writer to write the computed response to. + /// - context: The ``LambdaContext`` containing the invocation's metadata. @inlinable - public func decode(_ type: Event.Type, from buffer: NIOCore.ByteBuffer) throws -> Event - where Event: Decodable { - try buffer.getJSONDecodable( - Event.self, - decoder: self.jsonDecoder, - at: buffer.readerIndex, - length: buffer.readableBytes - )! // must work, enough readable bytes + public func handle( + _ event: Event, + outputWriter: some LambdaResponseWriter, + context: LambdaContext + ) async throws { + let output = try await self.handler.handle(event, context: context) + try await outputWriter.write(output) } } -public struct LambdaJSONOutputEncoder: LambdaOutputEncoder { - @usableFromInline let jsonEncoder: JSONEncoder +/// Adapts a ``LambdaWithBackgroundProcessingHandler`` conforming handler to conform to ``StreamingLambdaHandler``. +public struct LambdaCodableAdapter< + Handler: LambdaWithBackgroundProcessingHandler, + Event: Decodable, + Output, + Decoder: LambdaEventDecoder, + Encoder: LambdaOutputEncoder +>: StreamingLambdaHandler where Handler.Event == Event, Handler.Output == Output, Encoder.Output == Output { + @usableFromInline let handler: Handler + @usableFromInline let encoder: Encoder + @usableFromInline let decoder: Decoder + @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`. + /// - handler: The handler object. @inlinable - public init(_ jsonEncoder: JSONEncoder) { - self.jsonEncoder = jsonEncoder + public init(encoder: sending Encoder, decoder: sending Decoder, handler: sending Handler) where Output: Encodable { + self.encoder = encoder + self.decoder = decoder + self.handler = handler } + /// 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. @inlinable - public func encode(_ value: Output, into buffer: inout ByteBuffer) throws { - try buffer.writeJSONEncodable(value, encoder: self.jsonEncoder) + public init(decoder: sending Decoder, handler: Handler) where Output == Void, Encoder == VoidEncoder { + self.encoder = VoidEncoder() + self.decoder = decoder + self.handler = handler } -} -extension LambdaCodableAdapter { - /// Initializes an instance given an encoder, decoder, and a handler with a non-`Void` output. + /// A ``StreamingLambdaHandler/handle(_:responseWriter:context:)`` wrapper. /// - Parameters: - /// - encoder: The encoder object that will be used to encode the generic `Output` obtained from the `handler`'s `outputWriter` into a `ByteBuffer`. By default, a JSONEncoder is used. - /// - decoder: The decoder object that will be used to decode the received `ByteBuffer` event into the generic `Event` type served to the `handler`. By default, a JSONDecoder is used. - /// - handler: The handler object. - public init( - encoder: JSONEncoder = JSONEncoder(), - decoder: JSONDecoder = JSONDecoder(), - handler: sending Handler - ) - where - Output: Encodable, - Output == Handler.Output, - Encoder == LambdaJSONOutputEncoder, - Decoder == LambdaJSONEventDecoder - { - self.init( - encoder: LambdaJSONOutputEncoder(encoder), - decoder: LambdaJSONEventDecoder(decoder), - handler: handler + /// - event: The received event. + /// - outputWriter: The writer to write the computed response to. + /// - context: The ``LambdaContext`` containing the invocation's metadata. + @inlinable + public mutating func handle( + _ request: ByteBuffer, + responseWriter: Writer, + context: LambdaContext + ) async throws { + let event = try self.decoder.decode(Event.self, from: request) + + let writer = LambdaCodableResponseWriter( + encoder: self.encoder, + streamWriter: responseWriter ) + try await self.handler.handle(event, outputWriter: writer, context: context) } } -extension LambdaRuntime { - /// Initialize an instance with a `LambdaHandler` defined in the form of a closure **with a non-`Void` return type**. - /// - Parameters: - /// - decoder: The decoder object that will be used to decode the incoming `ByteBuffer` event into the generic `Event` type. `JSONDecoder()` used as default. - /// - encoder: The encoder object that will be used to encode the generic `Output` into a `ByteBuffer`. `JSONEncoder()` used as default. - /// - body: The handler in the form of a closure. - public convenience init( - decoder: JSONDecoder = JSONDecoder(), - encoder: JSONEncoder = JSONEncoder(), - body: sending @escaping (Event, LambdaContext) async throws -> Output - ) - where - Handler == LambdaCodableAdapter< - LambdaHandlerAdapter>, - Event, - Output, - LambdaJSONEventDecoder, - LambdaJSONOutputEncoder - > - { - let handler = LambdaCodableAdapter( - encoder: encoder, - decoder: decoder, - handler: LambdaHandlerAdapter(handler: ClosureHandler(body: body)) - ) +/// A ``LambdaResponseStreamWriter`` wrapper that conforms to ``LambdaResponseWriter``. +public struct LambdaCodableResponseWriter: + LambdaResponseWriter +where Output == Encoder.Output { + @usableFromInline let underlyingStreamWriter: Base + @usableFromInline let encoder: Encoder - self.init(handler: handler) + /// 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`. + /// - streamWriter: The underlying ``LambdaResponseStreamWriter`` that will be wrapped. + @inlinable + public init(encoder: Encoder, streamWriter: Base) { + self.encoder = encoder + self.underlyingStreamWriter = streamWriter } - /// 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. - public convenience init( - decoder: JSONDecoder = JSONDecoder(), - body: sending @escaping (Event, LambdaContext) async throws -> Void - ) - where - Handler == LambdaCodableAdapter< - LambdaHandlerAdapter>, - Event, - Void, - LambdaJSONEventDecoder, - VoidEncoder - > - { - let handler = LambdaCodableAdapter( - decoder: LambdaJSONEventDecoder(decoder), - handler: LambdaHandlerAdapter(handler: ClosureHandler(body: body)) - ) - - self.init(handler: handler) + @inlinable + public func write(_ output: Output) async throws { + var outputBuffer = ByteBuffer() + try self.encoder.encode(output, into: &outputBuffer) + try await self.underlyingStreamWriter.writeAndFinish(outputBuffer) } } diff --git a/Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift b/Sources/AWSLambdaRuntime/Lambda+LocalServer.swift similarity index 99% rename from Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift rename to Sources/AWSLambdaRuntime/Lambda+LocalServer.swift index bee880cc..4d85f7b2 100644 --- a/Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift +++ b/Sources/AWSLambdaRuntime/Lambda+LocalServer.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#if DEBUG +#if LocalServerSupport import DequeModule import Dispatch import Logging @@ -524,7 +524,6 @@ private struct LambdaHTTPServer { } } } -#endif extension Result { var maybeError: Failure? { @@ -536,3 +535,4 @@ extension Result { } } } +#endif diff --git a/Sources/AWSLambdaRuntimeCore/Lambda.swift b/Sources/AWSLambdaRuntime/Lambda.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Lambda.swift rename to Sources/AWSLambdaRuntime/Lambda.swift diff --git a/Sources/AWSLambdaRuntimeCore/LambdaContext.swift b/Sources/AWSLambdaRuntime/LambdaContext.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/LambdaContext.swift rename to Sources/AWSLambdaRuntime/LambdaContext.swift diff --git a/Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift b/Sources/AWSLambdaRuntime/LambdaHandlers.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/LambdaHandlers.swift rename to Sources/AWSLambdaRuntime/LambdaHandlers.swift diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRequestID.swift b/Sources/AWSLambdaRuntime/LambdaRequestID.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/LambdaRequestID.swift rename to Sources/AWSLambdaRuntime/LambdaRequestID.swift diff --git a/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift b/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift new file mode 100644 index 00000000..70235e9e --- /dev/null +++ b/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift @@ -0,0 +1,12 @@ +// +// LambdaRuntime+ServiceLifecycle.swift +// swift-aws-lambda-runtime +// +// Created by Fabian Fett on 01.03.25. +// + +#if ServiceLifecycleSupport +import ServiceLifecycle + +extension LambdaRuntime: Service {} +#endif diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift b/Sources/AWSLambdaRuntime/LambdaRuntime.swift similarity index 99% rename from Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift rename to Sources/AWSLambdaRuntime/LambdaRuntime.swift index 317ee7ea..6bc2403c 100644 --- a/Sources/AWSLambdaRuntimeCore/LambdaRuntime.swift +++ b/Sources/AWSLambdaRuntime/LambdaRuntime.swift @@ -82,7 +82,7 @@ public final class LambdaRuntime: @unchecked Sendable where Handler: St } else { - #if DEBUG + #if LocalServerSupport // we're not running on Lambda and we're compiled in DEBUG mode, // let's start a local server for testing try await Lambda.withLocalServer(invocationEndpoint: Lambda.env("LOCAL_LAMBDA_SERVER_INVOCATION_ENDPOINT")) diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift b/Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift rename to Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRuntimeClientProtocol.swift b/Sources/AWSLambdaRuntime/LambdaRuntimeClientProtocol.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/LambdaRuntimeClientProtocol.swift rename to Sources/AWSLambdaRuntime/LambdaRuntimeClientProtocol.swift diff --git a/Sources/AWSLambdaRuntimeCore/LambdaRuntimeError.swift b/Sources/AWSLambdaRuntime/LambdaRuntimeError.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/LambdaRuntimeError.swift rename to Sources/AWSLambdaRuntime/LambdaRuntimeError.swift diff --git a/Sources/AWSLambdaRuntimeCore/Utils.swift b/Sources/AWSLambdaRuntime/Utils.swift similarity index 100% rename from Sources/AWSLambdaRuntimeCore/Utils.swift rename to Sources/AWSLambdaRuntime/Utils.swift diff --git a/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift b/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift deleted file mode 100644 index a77c0542..00000000 --- a/Sources/AWSLambdaRuntimeCore/Lambda+Codable.swift +++ /dev/null @@ -1,162 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// This source file is part of the SwiftAWSLambdaRuntime open source project -// -// Copyright (c) 2024 Apple Inc. and the SwiftAWSLambdaRuntime project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -import NIOCore - -/// The protocol a decoder must conform to so that it can be used with ``LambdaCodableAdapter`` to decode incoming -/// `ByteBuffer` events. -public protocol LambdaEventDecoder { - /// 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. - /// - buffer: The buffer to be decoded. - /// - Returns: An object containing the decoded data. - func decode(_ type: Event.Type, from buffer: ByteBuffer) throws -> Event -} - -/// The protocol an encoder must conform to so that it can be used with ``LambdaCodableAdapter`` to encode the generic -/// ``LambdaOutputEncoder/Output`` object into a `ByteBuffer`. -public protocol LambdaOutputEncoder { - associatedtype Output - - /// 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. - func encode(_ value: Output, into buffer: inout ByteBuffer) throws -} - -public struct VoidEncoder: LambdaOutputEncoder { - public typealias Output = Void - - public init() {} - - @inlinable - public func encode(_ value: Void, into buffer: inout NIOCore.ByteBuffer) throws {} -} - -/// Adapts a ``LambdaHandler`` conforming handler to conform to ``LambdaWithBackgroundProcessingHandler``. -public struct LambdaHandlerAdapter< - Event: Decodable, - Output, - Handler: LambdaHandler ->: LambdaWithBackgroundProcessingHandler where Handler.Event == Event, Handler.Output == Output { - @usableFromInline let handler: Handler - - /// Initializes an instance given a concrete handler. - /// - Parameter handler: The ``LambdaHandler`` conforming handler that is to be adapted to ``LambdaWithBackgroundProcessingHandler``. - @inlinable - public init(handler: sending Handler) { - self.handler = handler - } - - /// 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. - /// - outputWriter: The writer to write the computed response to. - /// - context: The ``LambdaContext`` containing the invocation's metadata. - @inlinable - public func handle( - _ event: Event, - outputWriter: some LambdaResponseWriter, - context: LambdaContext - ) async throws { - let output = try await self.handler.handle(event, context: context) - try await outputWriter.write(output) - } -} - -/// Adapts a ``LambdaWithBackgroundProcessingHandler`` conforming handler to conform to ``StreamingLambdaHandler``. -public struct LambdaCodableAdapter< - Handler: LambdaWithBackgroundProcessingHandler, - Event: Decodable, - Output, - Decoder: LambdaEventDecoder, - Encoder: LambdaOutputEncoder ->: StreamingLambdaHandler where Handler.Event == Event, Handler.Output == Output, Encoder.Output == Output { - @usableFromInline let handler: Handler - @usableFromInline let encoder: Encoder - @usableFromInline let decoder: Decoder - @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`. - /// - handler: The handler object. - @inlinable - public init(encoder: sending Encoder, decoder: sending Decoder, handler: sending Handler) where Output: Encodable { - self.encoder = encoder - self.decoder = decoder - self.handler = handler - } - - /// 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. - @inlinable - public init(decoder: sending Decoder, handler: Handler) where Output == Void, Encoder == VoidEncoder { - self.encoder = VoidEncoder() - self.decoder = decoder - self.handler = handler - } - - /// A ``StreamingLambdaHandler/handle(_:responseWriter:context:)`` wrapper. - /// - Parameters: - /// - event: The received event. - /// - outputWriter: The writer to write the computed response to. - /// - context: The ``LambdaContext`` containing the invocation's metadata. - @inlinable - public mutating func handle( - _ request: ByteBuffer, - responseWriter: Writer, - context: LambdaContext - ) async throws { - let event = try self.decoder.decode(Event.self, from: request) - - let writer = LambdaCodableResponseWriter( - encoder: self.encoder, - streamWriter: responseWriter - ) - try await self.handler.handle(event, outputWriter: writer, context: context) - } -} - -/// A ``LambdaResponseStreamWriter`` wrapper that conforms to ``LambdaResponseWriter``. -public struct LambdaCodableResponseWriter: - LambdaResponseWriter -where Output == Encoder.Output { - @usableFromInline let underlyingStreamWriter: Base - @usableFromInline let encoder: Encoder - - /// 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`. - /// - streamWriter: The underlying ``LambdaResponseStreamWriter`` that will be wrapped. - @inlinable - public init(encoder: Encoder, streamWriter: Base) { - self.encoder = encoder - self.underlyingStreamWriter = streamWriter - } - - @inlinable - public func write(_ output: Output) async throws { - var outputBuffer = ByteBuffer() - try self.encoder.encode(output, into: &outputBuffer) - try await self.underlyingStreamWriter.writeAndFinish(outputBuffer) - } -} diff --git a/Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestEncoderTests.swift b/Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestEncoderTests.swift index df1a4044..5a51f8b4 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestEncoderTests.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/ControlPlaneRequestEncoderTests.swift @@ -17,7 +17,7 @@ import NIOEmbedded import NIOHTTP1 import XCTest -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime final class ControlPlaneRequestEncoderTests: XCTestCase { let host = "192.168.0.1" diff --git a/Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift b/Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift index fca58391..ea4eef1f 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/InvocationTests.swift @@ -15,7 +15,7 @@ import NIOHTTP1 import Testing -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime #if canImport(FoundationEssentials) import FoundationEssentials diff --git a/Tests/AWSLambdaRuntimeCoreTests/LambdaMockClient.swift b/Tests/AWSLambdaRuntimeCoreTests/LambdaMockClient.swift index 613276ed..727658fd 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/LambdaMockClient.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/LambdaMockClient.swift @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -import AWSLambdaRuntimeCore +import AWSLambdaRuntime import Logging import NIOCore diff --git a/Tests/AWSLambdaRuntimeCoreTests/LambdaRequestIDTests.swift b/Tests/AWSLambdaRuntimeCoreTests/LambdaRequestIDTests.swift index 45886c64..a144e20c 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/LambdaRequestIDTests.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/LambdaRequestIDTests.swift @@ -15,7 +15,7 @@ import NIOCore import Testing -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime #if canImport(FoundationEssentials) import FoundationEssentials diff --git a/Tests/AWSLambdaRuntimeCoreTests/LambdaRunLoopTests.swift b/Tests/AWSLambdaRuntimeCoreTests/LambdaRunLoopTests.swift index f57f051b..493985d8 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/LambdaRunLoopTests.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/LambdaRunLoopTests.swift @@ -16,7 +16,7 @@ import Logging import NIOCore import Testing -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime #if canImport(FoundationEssentials) import FoundationEssentials diff --git a/Tests/AWSLambdaRuntimeCoreTests/LambdaRuntimeClientTests.swift b/Tests/AWSLambdaRuntimeCoreTests/LambdaRuntimeClientTests.swift index 5d430a0f..53afbaf6 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/LambdaRuntimeClientTests.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/LambdaRuntimeClientTests.swift @@ -19,7 +19,7 @@ import Testing import struct Foundation.UUID -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime @Suite struct LambdaRuntimeClientTests { diff --git a/Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift b/Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift index dc325742..11f43ba4 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/MockLambdaServer.swift @@ -17,7 +17,7 @@ import NIOCore import NIOHTTP1 import NIOPosix -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime #if canImport(FoundationEssentials) import FoundationEssentials diff --git a/Tests/AWSLambdaRuntimeCoreTests/UtilsTest.swift b/Tests/AWSLambdaRuntimeCoreTests/UtilsTest.swift index bdc0b0e5..0b3b5917 100644 --- a/Tests/AWSLambdaRuntimeCoreTests/UtilsTest.swift +++ b/Tests/AWSLambdaRuntimeCoreTests/UtilsTest.swift @@ -14,7 +14,7 @@ import XCTest -@testable import AWSLambdaRuntimeCore +@testable import AWSLambdaRuntime class UtilsTest: XCTestCase { func testGenerateXRayTraceID() { From 789792a7714aa36794fb32d1a905113cddc87cc1 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Sat, 1 Mar 2025 14:23:20 +0100 Subject: [PATCH 02/14] Fixes --- .github/workflows/pull_request.yml | 6 +++--- Package.swift | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9c1e88a3..e429c262 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,9 +12,9 @@ jobs: license_header_check_project_name: "SwiftAWSLambdaRuntime" shell_check_enabled: true python_lint_check_enabled: true - api_breakage_check_container_image: "swift:6.0-noble" - docs_check_container_image: "swift:6.0-noble" - format_check_container_image: "swiftlang/swift:nightly-6.0-jammy" + api_breakage_check_container_image: "swiftlang/swift:nightly-6.1-jammy" + docs_check_container_image: "swiftlang/swift:nightly-6.1-jammy" + format_check_container_image: "swiftlang/swift:nightly-6.1-jammy" yamllint_check_enabled: true unit-tests: diff --git a/Package.swift b/Package.swift index 47c817c6..d562f521 100644 --- a/Package.swift +++ b/Package.swift @@ -30,7 +30,7 @@ let package = Package( .package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"), .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4"), - .package(url: "https://github.com/apple/swift-service-lifecycle.git", from: "2.6.3", traits: ["ServiceLifecycleSupport"]), + .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.3"), ], targets: [ .target( @@ -41,6 +41,7 @@ let package = Package( .product(name: "Logging", package: "swift-log"), .product(name: "NIOHTTP1", package: "swift-nio"), .product(name: "NIOPosix", package: "swift-nio"), + .product(name: "ServiceLifecycle", package: "swift-service-lifecycle", condition: .when(traits: ["ServiceLifecycleSupport"])) ] ), .plugin( From 3403c5978ac811df917b07f927daac724517d314 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Sat, 1 Mar 2025 14:27:35 +0100 Subject: [PATCH 03/14] Use 6.1 for examples --- .github/workflows/integration_tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index 1a67f637..af02f0d4 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -39,7 +39,7 @@ on: matrix_linux_swift_container_image: type: string description: "Container image for the matrix job. Defaults to matching latest Swift Ubuntu image." - default: "swift:amazonlinux2" + default: "swiftlang/swift:nightly-6.1-jammy" ## We are cancelling previously triggered workflow runs concurrency: From d106ab2a1dd790d99bff3961c87167c0536469d0 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Tue, 4 Mar 2025 12:52:51 +0100 Subject: [PATCH 04/14] How it is used. --- Examples/HelloJSON/Package.swift | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Examples/HelloJSON/Package.swift b/Examples/HelloJSON/Package.swift index 4ec236fd..7ac3986c 100644 --- a/Examples/HelloJSON/Package.swift +++ b/Examples/HelloJSON/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:6.0 +// swift-tools-version:6.1 import PackageDescription @@ -13,7 +13,13 @@ let package = Package( ], dependencies: [ // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below - .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "main") + .package( + url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", + branch: "ff-package-traits", + traits: [ + .trait(name: "FoundationJSONSupport"), + ] + ) ], targets: [ .executableTarget( From df50337d9daa62c195e6265d26a69350b5150d21 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 12:48:06 +0100 Subject: [PATCH 05/14] Allow Swift 6.0 again --- Package@swift-6.0.swift | 97 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 Package@swift-6.0.swift diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift new file mode 100644 index 00000000..a437e4ee --- /dev/null +++ b/Package@swift-6.0.swift @@ -0,0 +1,97 @@ +// swift-tools-version:6.0 + +import PackageDescription + +let package = Package( + name: "swift-aws-lambda-runtime", + platforms: [.macOS(.v15)], + products: [ + // this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods + .library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]), + // plugin to package the lambda, creating an archive that can be uploaded to AWS + // requires Linux or at least macOS v15 + .plugin(name: "AWSLambdaPackager", targets: ["AWSLambdaPackager"]), + // for testing only + .library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]), + ], + dependencies: [ + .package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"), + .package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"), + .package(url: "https://github.com/apple/swift-collections.git", from: "1.1.4"), + .package(url: "https://github.com/swift-server/swift-service-lifecycle.git", from: "2.6.3"), + ], + targets: [ + .target( + name: "AWSLambdaRuntime", + dependencies: [ + .product(name: "NIOCore", package: "swift-nio"), + .product(name: "DequeModule", package: "swift-collections"), + .product(name: "Logging", package: "swift-log"), + .product(name: "NIOHTTP1", package: "swift-nio"), + .product(name: "NIOPosix", package: "swift-nio"), + .product(name: "ServiceLifecycle", package: "swift-service-lifecycle") + ], + swiftSettings: [ + .define("FoundationJSONSupport"), + .define("ServiceLifecycleSupport"), + .define("LocalServerSupport"), + ] + ), + .plugin( + name: "AWSLambdaPackager", + capability: .command( + intent: .custom( + verb: "archive", + description: + "Archive the Lambda binary and prepare it for uploading to AWS. Requires docker on macOS or non Amazonlinux 2 distributions." + ), + permissions: [ + .allowNetworkConnections( + scope: .docker, + reason: "This plugin uses Docker to create the AWS Lambda ZIP package." + ) + ] + ) + ), + .testTarget( + name: "AWSLambdaRuntimeCoreTests", + dependencies: [ + .byName(name: "AWSLambdaRuntime"), + .product(name: "NIOTestUtils", package: "swift-nio"), + .product(name: "NIOFoundationCompat", package: "swift-nio"), + ] + ), + .testTarget( + name: "AWSLambdaRuntimeTests", + dependencies: [ +// .byName(name: "AWSLambdaRuntimeCore"), + .byName(name: "AWSLambdaRuntime"), + ] + ), + // testing helper + .target( + name: "AWSLambdaTesting", + dependencies: [ + .byName(name: "AWSLambdaRuntime"), + .product(name: "NIOCore", package: "swift-nio"), + .product(name: "NIOPosix", package: "swift-nio"), + ] + ), + .testTarget( + name: "AWSLambdaTestingTests", + dependencies: [ + .byName(name: "AWSLambdaTesting") + ] + ), + // for perf testing + .executableTarget( + name: "MockServer", + dependencies: [ + .product(name: "Logging", package: "swift-log"), + .product(name: "NIOHTTP1", package: "swift-nio"), + .product(name: "NIOCore", package: "swift-nio"), + .product(name: "NIOPosix", package: "swift-nio"), + ] + ), + ] +) From 438f4cb2f877ea88f75e7cc2801d7c3b937c87cf Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 15:57:07 +0100 Subject: [PATCH 06/14] Fix header --- .../LambdaRuntime+ServiceLifecycle.swift | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift b/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift index 70235e9e..54ecb537 100644 --- a/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift +++ b/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift @@ -1,9 +1,16 @@ +//===----------------------------------------------------------------------===// // -// LambdaRuntime+ServiceLifecycle.swift -// swift-aws-lambda-runtime +// This source file is part of the SwiftAWSLambdaRuntime open source project // -// Created by Fabian Fett on 01.03.25. +// Copyright (c) 2025 Apple Inc. and the SwiftAWSLambdaRuntime project authors +// Licensed under Apache License v2.0 // +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of SwiftAWSLambdaRuntime project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// #if ServiceLifecycleSupport import ServiceLifecycle From b21fffacecd13e66086890566da18f88ab916853 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 15:57:50 +0100 Subject: [PATCH 07/14] swift format --- .../AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift | 2 +- Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift | 2 +- .../FoundationSupport/Vendored/ByteBuffer-foundation.swift | 2 +- .../FoundationSupport/Vendored/JSON+ByteBuffer.swift | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift index a60e32e4..72b7a65d 100644 --- a/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift @@ -25,4 +25,4 @@ extension LambdaContext { return Date(timeIntervalSince1970: secondsSinceEpoch) } } -#endif // trait: FoundationJSONSupport +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift index c834989b..9bd4d30f 100644 --- a/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift @@ -135,4 +135,4 @@ extension LambdaRuntime { self.init(handler: handler) } } -#endif // trait: FoundationJSONSupport +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift index 320381a0..482e020f 100644 --- a/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift @@ -105,4 +105,4 @@ extension ByteBuffer { } } } -#endif // trait: FoundationJSONSupport +#endif // trait: FoundationJSONSupport diff --git a/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift index 81b8e940..89ce9b87 100644 --- a/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift +++ b/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift @@ -148,4 +148,4 @@ extension JSONEncoder { return buffer } } -#endif // trait: FoundationJSONSupport +#endif // trait: FoundationJSONSupport From 7ea52d29d0b94dba4e74c6408d2c67a0b12cc585 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 15:59:48 +0100 Subject: [PATCH 08/14] docs? --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index e429c262..5c971750 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -13,7 +13,7 @@ jobs: shell_check_enabled: true python_lint_check_enabled: true api_breakage_check_container_image: "swiftlang/swift:nightly-6.1-jammy" - docs_check_container_image: "swiftlang/swift:nightly-6.1-jammy" + docs_check_container_image: "swiftlang/swift:nightly-6.1-noble" format_check_container_image: "swiftlang/swift:nightly-6.1-jammy" yamllint_check_enabled: true From ac1b2fb785de17a3e2e7cca1180f15b1c442fc0e Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 16:20:57 +0100 Subject: [PATCH 09/14] swift-format --- Package.swift | 11 +++++++---- Package@swift-6.0.swift | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index d562f521..8ffa99eb 100644 --- a/Package.swift +++ b/Package.swift @@ -24,7 +24,7 @@ let package = Package( "ServiceLifecycleSupport", "LocalServerSupport", ] - ) + ), ], dependencies: [ .package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"), @@ -41,7 +41,11 @@ let package = Package( .product(name: "Logging", package: "swift-log"), .product(name: "NIOHTTP1", package: "swift-nio"), .product(name: "NIOPosix", package: "swift-nio"), - .product(name: "ServiceLifecycle", package: "swift-service-lifecycle", condition: .when(traits: ["ServiceLifecycleSupport"])) + .product( + name: "ServiceLifecycle", + package: "swift-service-lifecycle", + condition: .when(traits: ["ServiceLifecycleSupport"]) + ), ] ), .plugin( @@ -71,8 +75,7 @@ let package = Package( .testTarget( name: "AWSLambdaRuntimeTests", dependencies: [ -// .byName(name: "AWSLambdaRuntimeCore"), - .byName(name: "AWSLambdaRuntime"), + .byName(name: "AWSLambdaRuntime") ] ), // testing helper diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index a437e4ee..41204520 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -64,7 +64,6 @@ let package = Package( .testTarget( name: "AWSLambdaRuntimeTests", dependencies: [ -// .byName(name: "AWSLambdaRuntimeCore"), .byName(name: "AWSLambdaRuntime"), ] ), From c4255e974c7550098aa4f434db5089cff7343b4a Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 16:22:49 +0100 Subject: [PATCH 10/14] Fix docs --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 5c971750..520c539d 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -13,7 +13,7 @@ jobs: shell_check_enabled: true python_lint_check_enabled: true api_breakage_check_container_image: "swiftlang/swift:nightly-6.1-jammy" - docs_check_container_image: "swiftlang/swift:nightly-6.1-noble" + docs_check_container_image: "swift:6.0-noble" format_check_container_image: "swiftlang/swift:nightly-6.1-jammy" yamllint_check_enabled: true From 137ff130c415b04efb318675882473555a64cc91 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 18:33:49 +0100 Subject: [PATCH 11/14] format again and docs --- .spi.yml | 2 +- Package@swift-6.0.swift | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.spi.yml b/.spi.yml index 16792833..9c13e3e4 100644 --- a/.spi.yml +++ b/.spi.yml @@ -1,4 +1,4 @@ version: 1 builder: configs: - - documentation_targets: [AWSLambdaRuntimeCore, AWSLambdaRuntime] + - documentation_targets: [AWSLambdaRuntime] diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index 41204520..865a8c08 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -29,7 +29,7 @@ let package = Package( .product(name: "Logging", package: "swift-log"), .product(name: "NIOHTTP1", package: "swift-nio"), .product(name: "NIOPosix", package: "swift-nio"), - .product(name: "ServiceLifecycle", package: "swift-service-lifecycle") + .product(name: "ServiceLifecycle", package: "swift-service-lifecycle"), ], swiftSettings: [ .define("FoundationJSONSupport"), @@ -64,7 +64,7 @@ let package = Package( .testTarget( name: "AWSLambdaRuntimeTests", dependencies: [ - .byName(name: "AWSLambdaRuntime"), + .byName(name: "AWSLambdaRuntime") ] ), // testing helper From 8bf647d31f056905eb2fa5cb79011748c00c79d8 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 19:25:11 +0100 Subject: [PATCH 12/14] swift-format --- Examples/HelloJSON/Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Examples/HelloJSON/Package.swift b/Examples/HelloJSON/Package.swift index 7ac3986c..9f26ff9d 100644 --- a/Examples/HelloJSON/Package.swift +++ b/Examples/HelloJSON/Package.swift @@ -14,10 +14,10 @@ let package = Package( dependencies: [ // during CI, the dependency on local version of swift-aws-lambda-runtime is added dynamically below .package( - url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", + url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", branch: "ff-package-traits", traits: [ - .trait(name: "FoundationJSONSupport"), + .trait(name: "FoundationJSONSupport") ] ) ], From 3271584339e5ff977bd6caef16af56d39ff27766 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 19:28:41 +0100 Subject: [PATCH 13/14] Fix docs --- Package.swift | 1 - Package@swift-6.0.swift | 1 - Sources/AWSLambdaRuntime/Docs.docc/Documentation.md | 2 +- .../AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md | 2 +- .../Docs.docc/Resources/code/03-04-02-console-output.sh | 2 +- .../Docs.docc/Resources/code/03-04-07-terminal.sh | 2 +- Sources/AWSLambdaRuntime/Docs.docc/index.md | 6 +++--- readme.md | 8 ++++---- 8 files changed, 11 insertions(+), 13 deletions(-) diff --git a/Package.swift b/Package.swift index 8ffa99eb..3bd026f9 100644 --- a/Package.swift +++ b/Package.swift @@ -6,7 +6,6 @@ let package = Package( name: "swift-aws-lambda-runtime", platforms: [.macOS(.v15)], products: [ - // this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods .library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]), // plugin to package the lambda, creating an archive that can be uploaded to AWS // requires Linux or at least macOS v15 diff --git a/Package@swift-6.0.swift b/Package@swift-6.0.swift index 865a8c08..ff45ec88 100644 --- a/Package@swift-6.0.swift +++ b/Package@swift-6.0.swift @@ -6,7 +6,6 @@ let package = Package( name: "swift-aws-lambda-runtime", platforms: [.macOS(.v15)], products: [ - // this library exports `AWSLambdaRuntimeCore` and adds Foundation convenience methods .library(name: "AWSLambdaRuntime", targets: ["AWSLambdaRuntime"]), // plugin to package the lambda, creating an archive that can be uploaded to AWS // requires Linux or at least macOS v15 diff --git a/Sources/AWSLambdaRuntime/Docs.docc/Documentation.md b/Sources/AWSLambdaRuntime/Docs.docc/Documentation.md index 4016bcbd..e820ce26 100644 --- a/Sources/AWSLambdaRuntime/Docs.docc/Documentation.md +++ b/Sources/AWSLambdaRuntime/Docs.docc/Documentation.md @@ -1,4 +1,4 @@ -# ``AWSLambdaRuntimeCore`` +# ``AWSLambdaRuntime`` An AWS Lambda runtime for the Swift programming language diff --git a/Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md b/Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md index e4ff259b..624182d0 100644 --- a/Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md +++ b/Sources/AWSLambdaRuntime/Docs.docc/Proposals/0001-v2-api.md @@ -40,7 +40,7 @@ Server ecosystem is to shift to newer, more readable, Swift concurrency construc #### No ownership of the main() function A Lambda function can currently be implemented through conformance to the various handler protocols defined in -`AWSLambdaRuntimeCore/LambdaHandler`. Each of these protocols have an extension which implements a `static func main()`. +``AWSLambdaRuntime/LambdaHandler``. Each of these protocols have an extension which implements a `static func main()`. This allows users to annotate their `LambdaHandler` conforming object with `@main`. The `static func main()` calls the internal `Lambda.run()` function, which starts the Lambda function. Since the `Lambda.run()` method is internal, users cannot override the default implementation. This has proven challenging for users who want to diff --git a/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-02-console-output.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-02-console-output.sh index 3d862f5d..11c59fb9 100644 --- a/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-02-console-output.sh +++ b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-02-console-output.sh @@ -1,2 +1,2 @@ -2025-01-02T14:59:29+0100 info LocalLambdaServer : [AWSLambdaRuntimeCore] +2025-01-02T14:59:29+0100 info LocalLambdaServer : [AWSLambdaRuntime] LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke diff --git a/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh index 6e4d6a3d..1348bddc 100644 --- a/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh +++ b/Sources/AWSLambdaRuntime/Docs.docc/Resources/code/03-04-07-terminal.sh @@ -3,4 +3,4 @@ swift run Building for debugging... [1/1] Write swift-version--58304C5D6DBC2206.txt Build of product 'PalindromeLambda' complete! (0.11s) -2025-01-02T15:12:49+0100 info LocalLambdaServer : [AWSLambdaRuntimeCore] LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke +2025-01-02T15:12:49+0100 info LocalLambdaServer : [AWSLambdaRuntime] LocalLambdaServer started and listening on 127.0.0.1:7000, receiving events on /invoke diff --git a/Sources/AWSLambdaRuntime/Docs.docc/index.md b/Sources/AWSLambdaRuntime/Docs.docc/index.md index 4d7e1607..e099a7a9 100644 --- a/Sources/AWSLambdaRuntime/Docs.docc/index.md +++ b/Sources/AWSLambdaRuntime/Docs.docc/index.md @@ -339,6 +339,6 @@ Swift provides great Unicode support via [ICU](http://site.icu-project.org/home) -[lh]: ./AWSLambdaRuntimeCore/Protocols/LambdaHandler.html -[ellh]: ./AWSLambdaRuntimeCore/Protocols/EventLoopLambdaHandler.html -[bblh]: ./AWSLambdaRuntimeCore/Protocols/ByteBufferLambdaHandler.html +[lh]: ./AWSLambdaRuntime/Protocols/LambdaHandler.html +[ellh]: ./AWSLambdaRuntime/Protocols/EventLoopLambdaHandler.html +[bblh]: ./AWSLambdaRuntime/Protocols/ByteBufferLambdaHandler.html diff --git a/readme.md b/readme.md index f945b1e1..37596ed2 100644 --- a/readme.md +++ b/readme.md @@ -39,7 +39,7 @@ Swift AWS Lambda Runtime was designed to make building Lambda functions in Swift To get started, read [the Swift AWS Lambda runtime tutorial](https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime/main/tutorials/table-of-content). It provides developers with detailed step-by-step instructions to develop, build, and deploy a Lambda function. -We also wrote a comprehensive [deployment guide](https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime/main/documentation/awslambdaruntimecore/deployment). +We also wrote a comprehensive [deployment guide](https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime/main/documentation/awslambdaruntime/deployment). Or, if you're impatient to start with runtime v2, try these six steps: @@ -379,7 +379,7 @@ LOCAL_LAMBDA_SERVER_INVOCATION_ENDPOINT=/2015-03-31/functions/function/invocatio ## Deploying your Swift Lambda functions -There is a full deployment guide available in [the documentation](https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime/main/documentation/awslambdaruntimecore/deployment). +There is a full deployment guide available in [the documentation](https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime/main/documentation/awslambdaruntime/deployment). There are multiple ways to deploy your Swift code to AWS Lambda. The very first time, you'll probably use the AWS Console to create a new Lambda function and upload your code as a zip file. However, as you iterate on your code, you'll want to automate the deployment process. @@ -421,9 +421,9 @@ Please refer to the full deployment guide available in [the documentation](https ## Swift AWS Lambda Runtime - Design Principles -The [design document](Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals/0001-v2-api.md) details the v2 API proposal for the swift-aws-lambda-runtime library, which aims to enhance the developer experience for building serverless functions in Swift. +The [design document](Sources/AWSLambdaRuntime/Documentation.docc/Proposals/0001-v2-api.md) details the v2 API proposal for the swift-aws-lambda-runtime library, which aims to enhance the developer experience for building serverless functions in Swift. -The proposal has been reviewed and [incorporated feedback from the community](https://forums.swift.org/t/aws-lambda-v2-api-proposal/73819). The full v2 API design document is available [in this repository](Sources/AWSLambdaRuntimeCore/Documentation.docc/Proposals/0001-v2-api.md). +The proposal has been reviewed and [incorporated feedback from the community](https://forums.swift.org/t/aws-lambda-v2-api-proposal/73819). The full v2 API design document is available [in this repository](Sources/AWSLambdaRuntime/Documentation.docc/Proposals/0001-v2-api.md). ### Key Design Principles From 701141c76f2ad7be8705a3b2d4ab710d7a1b9787 Mon Sep 17 00:00:00 2001 From: Fabian Fett Date: Wed, 5 Mar 2025 19:39:15 +0100 Subject: [PATCH 14/14] Remove now unnecessary index doc. --- Sources/AWSLambdaRuntime/Docs.docc/index.md | 344 -------------------- 1 file changed, 344 deletions(-) delete mode 100644 Sources/AWSLambdaRuntime/Docs.docc/index.md diff --git a/Sources/AWSLambdaRuntime/Docs.docc/index.md b/Sources/AWSLambdaRuntime/Docs.docc/index.md deleted file mode 100644 index e099a7a9..00000000 --- a/Sources/AWSLambdaRuntime/Docs.docc/index.md +++ /dev/null @@ -1,344 +0,0 @@ -# ``AWSLambdaRuntime`` - -An implementation of the AWS Lambda Runtime API in Swift. - -## Overview - -Many modern systems have client components like iOS, macOS or watchOS applications as well as server components that those clients interact with. Serverless functions are often the easiest and most efficient way for client application developers to extend their applications into the cloud. - -Serverless functions are increasingly becoming a popular choice for running event-driven or otherwise ad-hoc compute tasks in the cloud. They power mission critical microservices and data intensive workloads. In many cases, serverless functions allow developers to more easily scale and control compute costs given their on-demand nature. - -When using serverless functions, attention must be given to resource utilization as it directly impacts the costs of the system. This is where Swift shines! With its low memory footprint, deterministic performance, and quick start time, Swift is a fantastic match for the serverless functions architecture. - -Combine this with Swift's developer friendliness, expressiveness, and emphasis on safety, and we have a solution that is great for developers at all skill levels, scalable, and cost effective. - -Swift AWS Lambda Runtime was designed to make building Lambda functions in Swift simple and safe. The library is an implementation of the [AWS Lambda Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html) and uses an embedded asynchronous HTTP Client based on [SwiftNIO](http://github.com/apple/swift-nio) that is fine-tuned for performance in the AWS Runtime context. The library provides a multi-tier API that allows building a range of Lambda functions: From quick and simple closures to complex, performance-sensitive event handlers. - -## Getting started - -If you have never used AWS Lambda or Docker before, check out this [getting started guide](https://swiftpackageindex.com/swift-server/swift-aws-lambda-runtime/1.0.0-alpha.3/tutorials/table-of-content) which helps you with every step from zero to a running Lambda. - -First, create a SwiftPM project and pull Swift AWS Lambda Runtime as dependency into your project - - ```swift - // swift-tools-version:5.6 - - import PackageDescription - - let package = Package( - name: "my-lambda", - products: [ - .executable(name: "MyLambda", targets: ["MyLambda"]), - ], - dependencies: [ - .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "0.1.0"), - ], - targets: [ - .executableTarget(name: "MyLambda", dependencies: [ - .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), - ]), - ] - ) - ``` - -Next, create a `main.swift` and implement your Lambda. - - ### Using Closures - - The simplest way to use `AWSLambdaRuntime` is to pass in a closure, for example: - - ```swift - // Import the module - import AWSLambdaRuntime - - // in this example we are receiving and responding with strings - Lambda.run { (context, name: String, callback: @escaping (Result) -> Void) in - callback(.success("Hello, \(name)")) - } - ``` - - More commonly, the event would be a JSON, which is modeled using `Codable`, for example: - - ```swift - // Import the module - import AWSLambdaRuntime - - // Request, uses Codable for transparent JSON encoding - private struct Request: Codable { - let name: String - } - - // Response, uses Codable for transparent JSON encoding - private struct Response: Codable { - let message: String - } - - // In this example we are receiving and responding with `Codable`. - Lambda.run { (context, request: Request, callback: @escaping (Result) -> Void) in - callback(.success(Response(message: "Hello, \(request.name)"))) - } - ``` - - Since most Lambda functions are triggered by events originating in the AWS platform like `SNS`, `SQS` or `APIGateway`, the [Swift AWS Lambda Events](http://github.com/swift-server/swift-aws-lambda-events) package includes an `AWSLambdaEvents` module that provides implementations for most common AWS event types further simplifying writing Lambda functions. For example, handling an `SQS` message: - -First, add a dependency on the event packages: - - ```swift - // swift-tools-version:5.6 - - import PackageDescription - - let package = Package( - name: "my-lambda", - products: [ - .executable(name: "MyLambda", targets: ["MyLambda"]), - ], - dependencies: [ - .package(url: "https://github.com/swift-server/swift-aws-lambda-runtime.git", from: "0.1.0"), - ], - targets: [ - .executableTarget(name: "MyLambda", dependencies: [ - .product(name: "AWSLambdaRuntime", package: "swift-aws-lambda-runtime"), - .product(name: "AWSLambdaEvents", package: "swift-aws-lambda-runtime"), - ]), - ] - ) - ``` - - - ```swift - // Import the modules - import AWSLambdaRuntime - import AWSLambdaEvents - - // In this example we are receiving an SQS Event, with no response (Void). - Lambda.run { (context, message: SQS.Event, callback: @escaping (Result) -> Void) in - ... - callback(.success(Void())) - } - ``` - - Modeling Lambda functions as Closures is both simple and safe. Swift AWS Lambda Runtime will ensure that the user-provided code is offloaded from the network processing thread such that even if the code becomes slow to respond or gets stuck, the underlying process can continue to function. This safety comes at a small performance penalty from context switching between threads. In many cases, the simplicity and safety of using the Closure based API is often preferred over the complexity of the performance-oriented API. - - -## Deploying to AWS Lambda - -To deploy Lambda functions to AWS Lambda, you need to compile the code for Amazon Linux which is the OS used on AWS Lambda microVMs, package it as a Zip file, and upload to AWS. - -AWS offers several tools to interact and deploy Lambda functions to AWS Lambda including [SAM](https://aws.amazon.com/serverless/sam/) and the [AWS CLI](https://aws.amazon.com/cli/). - -To build the Lambda function for Amazon Linux, use the Docker image published by Swift.org on [Swift toolchains and Docker images for Amazon Linux 2](https://swift.org/download/). - -## Architecture - -The library defines three protocols for the implementation of a Lambda Handler. From low-level to more convenient: - -### ByteBufferLambdaHandler - -An `EventLoopFuture` based processing protocol for a Lambda that takes a `ByteBuffer` and returns a `ByteBuffer?` asynchronously. - -[`ByteBufferLambdaHandler`][bblh] is the lowest level protocol designed to power the higher level [`EventLoopLambdaHandler`][ellh] and [`LambdaHandler`][lh] based APIs. Users are not expected to use this protocol, though some performance sensitive applications that operate at the `ByteBuffer` level or have special serialization needs may choose to do so. - -```swift -public protocol ByteBufferLambdaHandler { - /// The Lambda handling method - /// Concrete Lambda handlers implement this method to provide the Lambda functionality. - /// - /// - parameters: - /// - context: Runtime `Context`. - /// - event: The event or request payload encoded as `ByteBuffer`. - /// - /// - Returns: An `EventLoopFuture` to report the result of the Lambda back to the runtime engine. - /// The `EventLoopFuture` should be completed with either a response encoded as `ByteBuffer` or an `Error` - func handle(context: Lambda.Context, event: ByteBuffer) -> EventLoopFuture -} -``` - -### EventLoopLambdaHandler - -[`EventLoopLambdaHandler`][ellh] is a strongly typed, `EventLoopFuture` based asynchronous processing protocol for a Lambda that takes a user defined `In` and returns a user defined `Out`. - -[`EventLoopLambdaHandler`][ellh] extends [`ByteBufferLambdaHandler`][bblh], providing `ByteBuffer` -> `In` decoding and `Out` -> `ByteBuffer?` encoding for `Codable` and `String`. - -[`EventLoopLambdaHandler`][ellh] executes the user provided Lambda on the same `EventLoop` as the core runtime engine, making the processing fast but requires more care from the implementation to never block the `EventLoop`. It is designed for performance sensitive applications that use `Codable` or `String` based Lambda functions. - -```swift -public protocol EventLoopLambdaHandler: ByteBufferLambdaHandler { - associatedtype In - associatedtype Out - - /// The Lambda handling method - /// Concrete Lambda handlers implement this method to provide the Lambda functionality. - /// - /// - parameters: - /// - context: Runtime `Context`. - /// - event: Event of type `In` representing the event or request. - /// - /// - Returns: An `EventLoopFuture` to report the result of the Lambda back to the runtime engine. - /// The `EventLoopFuture` should be completed with either a response of type `Out` or an `Error` - func handle(context: Lambda.Context, event: In) -> EventLoopFuture - - /// Encode a response of type `Out` to `ByteBuffer` - /// Concrete Lambda handlers implement this method to provide coding functionality. - /// - parameters: - /// - allocator: A `ByteBufferAllocator` to help allocate the `ByteBuffer`. - /// - value: Response of type `Out`. - /// - /// - Returns: A `ByteBuffer` with the encoded version of the `value`. - func encode(allocator: ByteBufferAllocator, value: Out) throws -> ByteBuffer? - - /// Decode a`ByteBuffer` to a request or event of type `In` - /// Concrete Lambda handlers implement this method to provide coding functionality. - /// - /// - parameters: - /// - buffer: The `ByteBuffer` to decode. - /// - /// - Returns: A request or event of type `In`. - func decode(buffer: ByteBuffer) throws -> In -} -``` - -### LambdaHandler - -[`LambdaHandler`][lh] is a strongly typed, completion handler based asynchronous processing protocol for a Lambda that takes a user defined `In` and returns a user defined `Out`. - -[`LambdaHandler`][lh] extends [`ByteBufferLambdaHandler`][bblh], performing `ByteBuffer` -> `In` decoding and `Out` -> `ByteBuffer` encoding for `Codable` and `String`. - -[`LambdaHandler`][lh] offloads the user provided Lambda execution to a `DispatchQueue` making processing safer but slower. - -```swift -public protocol LambdaHandler: EventLoopLambdaHandler { - /// Defines to which `DispatchQueue` the Lambda execution is offloaded to. - var offloadQueue: DispatchQueue { get } - - /// The Lambda handling method - /// Concrete Lambda handlers implement this method to provide the Lambda functionality. - /// - /// - parameters: - /// - context: Runtime `Context`. - /// - event: Event of type `In` representing the event or request. - /// - callback: Completion handler to report the result of the Lambda back to the runtime engine. - /// The completion handler expects a `Result` with either a response of type `Out` or an `Error` - func handle(context: Lambda.Context, event: In, callback: @escaping (Result) -> Void) -} -``` - -### Closures - -In addition to protocol-based Lambda, the library provides support for Closure-based ones, as demonstrated in the overview section above. Closure-based Lambdas are based on the [`LambdaHandler`][lh] protocol which mean they are safer. For most use cases, Closure-based Lambda is a great fit and users are encouraged to use them. - -The library includes implementations for `Codable` and `String` based Lambda. Since AWS Lambda is primarily JSON based, this covers the most common use cases. - -```swift -public typealias CodableClosure = (Lambda.Context, In, @escaping (Result) -> Void) -> Void -``` - -```swift -public typealias StringClosure = (Lambda.Context, String, @escaping (Result) -> Void) -> Void -``` - -This design allows for additional event types as well, and such Lambda implementation can extend one of the above protocols and provided their own `ByteBuffer` -> `In` decoding and `Out` -> `ByteBuffer` encoding. - -### Context - -When calling the user provided Lambda function, the library provides a `Context` class that provides metadata about the execution context, as well as utilities for logging and allocating buffers. - -```swift -public final class Context { - /// The request ID, which identifies the request that triggered the function invocation. - public let requestID: String - - /// The AWS X-Ray tracing header. - public let traceID: String - - /// The ARN of the Lambda function, version, or alias that's specified in the invocation. - public let invokedFunctionARN: String - - /// The timestamp that the function times out - public let deadline: DispatchWallTime - - /// For invocations from the AWS Mobile SDK, data about the Amazon Cognito identity provider. - public let cognitoIdentity: String? - - /// For invocations from the AWS Mobile SDK, data about the client application and device. - public let clientContext: String? - - /// `Logger` to log with - /// - /// - note: The `LogLevel` can be configured using the `LOG_LEVEL` environment variable. - public let logger: Logger - - /// The `EventLoop` the Lambda is executed on. Use this to schedule work with. - /// This is useful when implementing the `EventLoopLambdaHandler` protocol. - /// - /// - note: The `EventLoop` is shared with the Lambda runtime engine and should be handled with extra care. - /// Most importantly the `EventLoop` must never be blocked. - public let eventLoop: EventLoop - - /// `ByteBufferAllocator` to allocate `ByteBuffer` - /// This is useful when implementing `EventLoopLambdaHandler` - public let allocator: ByteBufferAllocator -} -``` - -### Configuration - -The library’s behavior can be fine tuned using environment variables based configuration. The library supported the following environment variables: - -* `LOG_LEVEL`: Define the logging level as defined by [SwiftLog](https://github.com/apple/swift-log). Set to INFO by default. -* `MAX_REQUESTS`: Max cycles the library should handle before exiting. Set to none by default. -* `STOP_SIGNAL`: Signal to capture for termination. Set to `TERM` by default. -* `REQUEST_TIMEOUT`: Max time to wait for responses to come back from the AWS Runtime engine. Set to none by default. - - -### AWS Lambda Runtime Engine Integration - -The library is designed to integrate with AWS Lambda Runtime Engine via the [AWS Lambda Runtime API](https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html) which was introduced as part of [AWS Lambda Custom Runtimes](https://aws.amazon.com/about-aws/whats-new/2018/11/aws-lambda-now-supports-custom-runtimes-and-layers/) in 2018. The latter is an HTTP server that exposes three main RESTful endpoint: - -* `/runtime/invocation/next` -* `/runtime/invocation/response` -* `/runtime/invocation/error` - -A single Lambda execution workflow is made of the following steps: - -1. The library calls AWS Lambda Runtime Engine `/next` endpoint to retrieve the next invocation request. -2. The library parses the response HTTP headers and populate the `Context` object. -3. The library reads the `/next` response body and attempt to decode it. Typically it decodes to user provided `In` type which extends `Decodable`, but users may choose to write Lambda functions that receive the input as `String` or `ByteBuffer` which require less, or no decoding. -4. The library hands off the `Context` and `In` event to the user provided handler. In the case of [`LambdaHandler`][lh] based handler this is done on a dedicated `DispatchQueue`, providing isolation between user's and the library's code. -5. User provided handler processes the request asynchronously, invoking a callback or returning a future upon completion, which returns a `Result` type with the `Out` or `Error` populated. -6. In case of error, the library posts to AWS Lambda Runtime Engine `/error` endpoint to provide the error details, which will show up on AWS Lambda logs. -7. In case of success, the library will attempt to encode the response. Typically it encodes from user provided `Out` type which extends `Encodable`, but users may choose to write Lambda functions that return a `String` or `ByteBuffer`, which require less, or no encoding. The library then posts the response to AWS Lambda Runtime Engine `/response` endpoint to provide the response to the callee. - -The library encapsulates the workflow via the internal `LambdaRuntimeClient` and `LambdaRunner` structs respectively. - -### Lifecycle Management - -AWS Lambda Runtime Engine controls the Application lifecycle and in the happy case never terminates the application, only suspends its execution when no work is available. - -As such, the library's main entry point is designed to run forever in a blocking fashion, performing the workflow described above in an endless loop. - -That loop is broken if/when an internal error occurs, such as a failure to communicate with AWS Lambda Runtime Engine API, or under other unexpected conditions. - -By default, the library also registers a Signal handler that traps `INT` and `TERM`, which are typical Signals used in modern deployment platforms to communicate shutdown request. - -### Integration with AWS Platform Events - -AWS Lambda functions can be invoked directly from the AWS Lambda console UI, AWS Lambda API, AWS SDKs, AWS CLI, and AWS toolkits. More commonly, they are invoked as a reaction to an event coming from the AWS platform. To make it easier to integrate with AWS platform events, [Swift AWS Lambda Runtime Events](http://github.com/swift-server/swift-aws-lambda-events) library is available, designed to work together with this runtime library. [Swift AWS Lambda Runtime Events](http://github.com/swift-server/swift-aws-lambda-events) includes an `AWSLambdaEvents` target which provides abstractions for many commonly used events. - -## Performance - -Lambda functions performance is usually measured across two axes: - -- **Cold start times**: The time it takes for a Lambda function to startup, ask for an invocation and process the first invocation. - -- **Warm invocation times**: The time it takes for a Lambda function to process an invocation after the Lambda has been invoked at least once. - -Larger packages size (Zip file uploaded to AWS Lambda) negatively impact the cold start time, since AWS needs to download and unpack the package before starting the process. - -Swift provides great Unicode support via [ICU](http://site.icu-project.org/home). Therefore, Swift-based Lambda functions include the ICU libraries which tend to be large. This impacts the download time mentioned above and an area for further optimization. Some of the alternatives worth exploring are using the system ICU that comes with Amazon Linux (albeit older than the one Swift ships with) or working to remove the ICU dependency altogether. We welcome ideas and contributions to this end. - - - -[lh]: ./AWSLambdaRuntime/Protocols/LambdaHandler.html -[ellh]: ./AWSLambdaRuntime/Protocols/EventLoopLambdaHandler.html -[bblh]: ./AWSLambdaRuntime/Protocols/ByteBufferLambdaHandler.html