After 11 months of work, we're pleased to announce the beta availability of the Swift Lambda Runtime v2 for Swift 6.x.
The v2 API prioritizes the following principles:
- Readability and maintainability: Extensive use of async/await improves code clarity and simplifies maintenance.
- Developer control: Developers own the main() function and have the flexibility to inject dependencies into the LambdaRuntime. This allows you to manage service lifecycles efficiently using Swift Service Lifecycle for coordinated startup and shutdown sequences.
- Simplified Codable support: The LambdaCodableAdapter struct eliminates the need for verbose boilerplate code when encoding and decoding events and responses.
- Strictly apply Swift 6 structured concurrency
A big thank you to
- @Aryan Shah who has written the majority of the heavy lifting to move from v1 to v2
- @fabianfett who led the redesign and early implementation of the new API
- @adam-fowler for your countless and patient code reviews and feedback.
Starting from this version, the Swift runtime for AWS Lambda supports Swift version 6.0 and more recent.
New Capabilities
The v2 API introduces three new features:
- Response Streaming: This functionality is ideal for handling large responses that need to be sent incrementally, or to reduce the time to first byte sent to the client. You have the possibility to send custom HTTP headers and status code when the function is exposed through a function URL (as of today, only the NodeJS and the Swift runtime support custom HTTP headers and status from streaming Function URLs)
- Background Work: Schedule tasks to run after returning a response to the AWS Lambda control plane.
- Support Swift Service Lifecycle. It allows to nicely coordinate this library's startup and shutdown sequence with other Swift libraries, such as, for example, the PostgresNIO database driver.
These new capabilities provide greater flexibility and control when building serverless functions in Swift with the swift-aws-lambda-runtime library.
New Contributors
- @aryan-25 made their first contribution in Require Swift 6 by aryan-25 · Pull Request #341 · swift-server/swift-aws-lambda-runtime · GitHub
- @jrosen081 made their first contribution in Add Support For Copying All Resources Into Final Executable by jrosen081 · Pull Request #386 · swift-server/swift-aws-lambda-runtime · GitHub
- @t089 made their first contribution in Adds default devcontainer configuration by t089 · Pull Request #433 · swift-server/swift-aws-lambda-runtime · GitHub
- @ptoffy made their first contribution in Add `S3EventNotifier` example by ptoffy · Pull Request #477 · swift-server/swift-aws-lambda-runtime · GitHub
- @mattcorey made their first contribution in Instructions for customizing the output path are incorrect by mattcorey · Pull Request #484 · swift-server/swift-aws-lambda-runtime · GitHub
- @FranzBusch made their first contribution in [CI] Add GHA CI and release flow by FranzBusch · Pull Request #340 · swift-server/swift-aws-lambda-runtime · GitHub
Full Changelog: Comparing 1.0.0-alpha.3...2.0.0-beta.1 · swift-server/swift-aws-lambda-runtime · GitHub