[core] Only one LambdaRuntime.run() can be called at a time (fix #507) (#508)

This is a proposal to fix issue #507 

**changes**
- `LambdaRuntime.init()` uses a `Mutex<Bool>` to make sure only one
instance is created
- `LambdaRuntime.init()` can now throw an error in case an instance
already exists (I did not use `fatalError()` to make it easier to test)
- All `convenience init()` methods catch possible errors instead of
re-throwing it to a void breaking the user-facing API
- Renamed existing `LambdaRuntimeError` to `LambdaRuntimeClientError`
- Introduced a new type `LambdaRuntimeError` to represent the double
initialization error

---------

Co-authored-by: Fabian Fett <fabianfett@apple.com>
Co-authored-by: Adam Fowler <adamfowler71@gmail.com>
This commit is contained in:
Sébastien Stormacq
2025-07-04 13:55:58 +00:00
committed by GitHub
co-authored by Fabian Fett Adam Fowler
parent bf2385ae08
commit 344d30b401
8 changed files with 173 additions and 32 deletions
+1 -4
View File
@@ -15,10 +15,7 @@ let package = Package(
// 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: "ff-package-traits",
traits: [
.trait(name: "FoundationJSONSupport")
]
branch: "main"
)
],
targets: [