-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Labels
kind/bugFeature doesn't work as expected.Feature doesn't work as expected.🆕 semver/minorAdds new public API.Adds new public API.
Milestone
Description
Now that user controls the main
function with the runtime v2, nothing prevents users to create multiple runtimes.
I tested the code below on Lambda and it works. Any of the two runtimes can pickup the invocation and respond. In my exemple, they're booth taking the same input parameter and there is not too much consequences. But if the user codes the two handler with different input types, the Lambda function will crash when the "incorrect" runtime picks up the event.
We should enforce the runtime as a singleton.
demo code
import AWSLambdaRuntime
let runtime1 = LambdaRuntime {
(event: String, context: LambdaContext) in
"Hello1 \(event)"
}
let runtime2 = LambdaRuntime {
(event: String, context: LambdaContext) in
"Hello2 \(event)"
}
try await withThrowingTaskGroup(of: Void.self) { group in
group.addTask {
try await runtime1.run()
}
group.addTask {
try await runtime2.run()
}
try await group.waitForAll()
}
Metadata
Metadata
Assignees
Labels
kind/bugFeature doesn't work as expected.Feature doesn't work as expected.🆕 semver/minorAdds new public API.Adds new public API.