You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Swift runtime client is an experimental package. It is subject to change and intended only for evaluation purposes.
16
+
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.
17
+
18
+
Open [issues on GitHub for support requests](https://github.com/awslabs/swift-aws-lambda-runtime/issues).
17
19
18
20
## The Swift AWS Lambda Runtime
19
21
@@ -27,7 +29,7 @@ Combine this with Swift's developer friendliness, expressiveness, and emphasis o
27
29
28
30
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.
29
31
30
-
## Pre-requisites
32
+
## Prerequisites
31
33
32
34
- Ensure you have the Swift 6.x toolchain installed. You can [install Swift toolchains](https://www.swift.org/install/macos/) from Swift.org
33
35
@@ -378,11 +380,52 @@ let runtime = LambdaRuntime {
378
380
tryawait runtime.run()
379
381
```
380
382
381
-
You can learn how to deploy and invoke this function in [the API Gateway example README file](Examples/APIGateway/README.md).
383
+
You can learn how to deploy and invoke this function in [the API Gateway example README file](Examples/APIGatewayV2/README.md).
382
384
383
385
### Integration with Swift Service LifeCycle
384
386
385
-
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.
387
+
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.
388
+
389
+
Here's how to integrate your Lambda function with ServiceLifecycle to manage multiple services:
390
+
391
+
```swift
392
+
importAWSLambdaRuntime
393
+
importServiceLifecycle
394
+
importPostgresNIO
395
+
396
+
@main
397
+
structLambdaFunction {
398
+
privatefuncstart() asyncthrows {
399
+
// Create a database client
400
+
let pgClient =PostgresClient(configuration: /* your config */)
401
+
402
+
// Create the Lambda runtime
403
+
let lambdaRuntime =LambdaRuntime(body: self.handler)
404
+
405
+
// Use ServiceLifecycle to manage both the database client and Lambda runtime
406
+
let serviceGroup =ServiceGroup(
407
+
services: [pgClient, lambdaRuntime],
408
+
gracefulShutdownSignals: [.sigterm],
409
+
cancellationSignals: [.sigint],
410
+
logger: self.logger
411
+
)
412
+
413
+
// Start all services - this will handle initialization and cleanup
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.
386
429
387
430
### Use Lambda Background Tasks
388
431
@@ -530,9 +573,9 @@ Please refer to [the full deployment guide available in the documentation](https
530
573
531
574
## Swift AWS Lambda Runtime - Design Principles
532
575
533
-
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.
576
+
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.
534
577
535
-
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).
578
+
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).
0 commit comments