File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Sources/AWSLambdaRuntimeCore Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,25 @@ public enum Lambda {
5555 fatalError ( " \( error) " )
5656 }
5757 }
58+
59+ #if compiler(>=5.4) && $AsyncAwait
60+ public static func run( _ factory: @escaping ( InitializationContext ) async throws -> Handler ) {
61+ self . run { context -> EventLoopFuture < Handler > in
62+ @asyncHandler func _createLambda( _ context: InitializationContext , promise: EventLoopPromise < Handler > ) {
63+ do {
64+ let handler = try await factory ( context)
65+ promise. succeed ( handler)
66+ } catch {
67+ promise. fail ( error)
68+ }
69+ }
70+
71+ let promise = context. eventLoop. makePromise ( of: Handler . self)
72+ _createLambda ( context, promise: promise)
73+ return promise. futureResult
74+ }
75+ }
76+ #endif
5877
5978 /// Run a Lambda defined by implementing the `LambdaHandler` protocol provided via a factory, typically a constructor.
6079 ///
You can’t perform that action at this time.
0 commit comments