From 2a5bc9994690fdda25b49a87e9a435655b881cab Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Mon, 3 Nov 2025 11:43:36 +0100 Subject: [PATCH 1/3] fix broken links --- readme.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/readme.md b/readme.md index 986f5486..468f5592 100644 --- a/readme.md +++ b/readme.md @@ -6,14 +6,16 @@ You can read [the Swift AWS Lambda Runtime documentation](https://swiftpackagein This guide contains the following sections: - [The Swift AWS Lambda Runtime](#the-swift-aws-lambda-runtime) -- [Pre-requisites](#pre-requisites) +- [Prerequisites](#prerequisites) - [Getting started](#getting-started) - [Developing your Swift Lambda functions](#developing-your-swift-lambda-functions) - [Testing Locally](#testing-locally) - [Deploying your Swift Lambda functions](#deploying-your-swift-lambda-functions) - [Swift AWS Lambda Runtime - Design Principles](#swift-aws-lambda-runtime---design-principles) -The Swift runtime client is an experimental package. It is subject to change and intended only for evaluation purposes. +The Swift runtime client is [an incubated packages as part of the Swift Server Workgroup incubation process](https://www.swift.org/sswg/incubated-packages.html). It is an experimental package, subject to change, and intended only for evaluation purposes. + +Open [issues on GitHub for support requests](https://github.com/awslabs/swift-aws-lambda-runtime/issues). ## The Swift AWS Lambda Runtime @@ -27,7 +29,7 @@ Combine this with Swift's developer friendliness, expressiveness, and emphasis o 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. -## Pre-requisites +## Prerequisites - Ensure you have the Swift 6.x toolchain installed. You can [install Swift toolchains](https://www.swift.org/install/macos/) from Swift.org @@ -378,7 +380,7 @@ let runtime = LambdaRuntime { try await runtime.run() ``` - You can learn how to deploy and invoke this function in [the API Gateway example README file](Examples/APIGateway/README.md). + You can learn how to deploy and invoke this function in [the API Gateway example README file](Examples/APIGatewayV2/README.md). ### Integration with Swift Service LifeCycle @@ -530,9 +532,9 @@ Please refer to [the full deployment guide available in the documentation](https ## Swift AWS Lambda Runtime - Design Principles -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 [design document](Sources/AWSLambdaRuntime/Docs.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/AWSLambdaRuntime/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/Docs.docc/Proposals/0001-v2-api.md). ### Key Design Principles From c5150330e36825a672961c65b48f4da39ba1995b Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Mon, 3 Nov 2025 11:47:04 +0100 Subject: [PATCH 2/3] fix wording --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 468f5592..dd103518 100644 --- a/readme.md +++ b/readme.md @@ -13,7 +13,7 @@ This guide contains the following sections: - [Deploying your Swift Lambda functions](#deploying-your-swift-lambda-functions) - [Swift AWS Lambda Runtime - Design Principles](#swift-aws-lambda-runtime---design-principles) -The Swift runtime client is [an incubated packages as part of the Swift Server Workgroup incubation process](https://www.swift.org/sswg/incubated-packages.html). It is an experimental package, subject to change, and intended only for evaluation purposes. +The Swift runtime client is [incubating as part of the Swift Server Workgroup incubation process](https://www.swift.org/sswg/incubated-packages.html). It is an experimental package, subject to change, and intended only for evaluation purposes. Open [issues on GitHub for support requests](https://github.com/awslabs/swift-aws-lambda-runtime/issues). From 5a1ac2d0592f8c5e9e192e852c98f0f64c00f8c5 Mon Sep 17 00:00:00 2001 From: Sebastien Stormacq Date: Mon, 3 Nov 2025 12:01:39 +0100 Subject: [PATCH 3/3] update swift service lifecycle section --- readme.md | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/readme.md b/readme.md index dd103518..0a744502 100644 --- a/readme.md +++ b/readme.md @@ -384,7 +384,48 @@ try await runtime.run() ### Integration with Swift Service LifeCycle -Support for [Swift Service Lifecycle](https://github.com/swift-server/swift-service-lifecycle) is currently being implemented. You can follow https://github.com/awslabs/swift-aws-lambda-runtime/issues/374 for more details and the current status. Your contributions are welcome. +The Swift AWS Lambda Runtime provides built-in support for [Swift Service Lifecycle](https://github.com/swift-server/swift-service-lifecycle), allowing you to manage the lifecycle of your Lambda runtime alongside other services like database clients, HTTP clients, or any other resources that need proper initialization and cleanup. + +Here's how to integrate your Lambda function with ServiceLifecycle to manage multiple services: + +```swift +import AWSLambdaRuntime +import ServiceLifecycle +import PostgresNIO + +@main +struct LambdaFunction { + private func start() async throws { + // Create a database client + let pgClient = PostgresClient(configuration: /* your config */) + + // Create the Lambda runtime + let lambdaRuntime = LambdaRuntime(body: self.handler) + + // Use ServiceLifecycle to manage both the database client and Lambda runtime + let serviceGroup = ServiceGroup( + services: [pgClient, lambdaRuntime], + gracefulShutdownSignals: [.sigterm], + cancellationSignals: [.sigint], + logger: self.logger + ) + + // Start all services - this will handle initialization and cleanup + try await serviceGroup.run() + } + + private func handler(event: String, context: LambdaContext) async throws -> String { + // Your Lambda function logic here + return "Hello, World!" + } + + static func main() async throws { + try await LambdaFunction().start() + } +} +``` + +You can see a complete working example in the [ServiceLifecycle+Postgres example](Examples/ServiceLifecycle+Postgres/README.md), which demonstrates how to manage a PostgreSQL client alongside the Lambda runtime using ServiceLifecycle. ### Use Lambda Background Tasks