swift-aws-lambda-runtime
swift-aws-lambda-runtime copied to clipboard
[core] Only one `LambdaRuntime.run()` can be called at a time (fix #507)
This is a proposal to fix issue #507
changes
LambdaRuntime.init()uses aMutex<Bool>to make sure only one instance is createdLambdaRuntime.init()can now throw an error in case an instance already exists (I did not usefatalError()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
LambdaRuntimeErrortoLambdaRuntimeClientError - Introduced a new type
LambdaRuntimeErrorto represent the double initialization error
Compiler crashes on nightly build has been reported here https://github.com/swiftlang/swift/issues/80020
CI is now green, except API Breakage, which is expected.
@fabianfett I changed
MutexforAtomic- Test is now on
run()and not oninit() LamabdaRuntimeErrorreturned and is now public + one additional error case- unit test is adjusted and pass
Now that managing cancellation is working (thank you @adam https://github.com/swift-server/swift-aws-lambda-runtime/commit/b2811a5e1a96a98033ad857d9f93ff086dbba142)
This PR is ready to review before merged. API Breakage is expected as we are adding an error case.