@@ -82,29 +82,23 @@ internal struct CodableVoidClosureWrapper<In: Decodable>: LambdaHandler {
82
82
83
83
#if compiler(>=5.5) && $AsyncAwait
84
84
extension Lambda {
85
- /// An async Lambda Closure that takes a `In: Decodable` and returns an `Out: Encodable`
86
- public typealias CodableAsyncClosure < In: Decodable , Out: Encodable > = ( Lambda . Context , In ) async throws -> Out
87
-
88
85
/// Run a Lambda defined by implementing the `CodableAsyncClosure` function.
89
86
///
90
87
/// - parameters:
91
88
/// - closure: `CodableAsyncClosure` based Lambda.
92
89
///
93
90
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
94
- public static func run< In: Decodable , Out: Encodable > ( _ closure: @escaping CodableAsyncClosure < In , Out > ) {
91
+ public static func run< In: Decodable , Out: Encodable > ( _ closure: @escaping ( In , Lambda . Context ) async throws -> Out ) {
95
92
self . run ( CodableAsyncWrapper ( closure) )
96
93
}
97
94
98
- /// An asynchronous Lambda Closure that takes a `In: Decodable` and returns nothing.
99
- public typealias CodableVoidAsyncClosure < In: Decodable > = ( Lambda . Context , In ) async throws -> Void
100
-
101
95
/// Run a Lambda defined by implementing the `CodableVoidAsyncClosure` function.
102
96
///
103
97
/// - parameters:
104
98
/// - closure: `CodableVoidAsyncClosure` based Lambda.
105
99
///
106
100
/// - note: This is a blocking operation that will run forever, as its lifecycle is managed by the AWS Lambda Runtime Engine.
107
- public static func run< In: Decodable > ( _ closure: @escaping CodableVoidAsyncClosure < In > ) {
101
+ public static func run< In: Decodable > ( _ closure: @escaping ( In , Lambda . Context ) async throws -> Void ) {
108
102
self . run ( CodableVoidAsyncWrapper ( closure) )
109
103
}
110
104
}
@@ -113,29 +107,29 @@ internal struct CodableAsyncWrapper<In: Decodable, Out: Encodable>: AsyncLambdaH
113
107
typealias In = In
114
108
typealias Out = Out
115
109
116
- private let closure : Lambda . CodableAsyncClosure < In , Out >
110
+ private let closure : ( In , Lambda . Context ) async throws -> Out
117
111
118
- init ( _ closure: @escaping Lambda . CodableAsyncClosure < In , Out > ) {
112
+ init ( _ closure: @escaping ( In , Lambda . Context ) async throws -> Out ) {
119
113
self . closure = closure
120
114
}
121
115
122
- func handle( context : Lambda . Context , event : In ) async throws -> Out {
123
- try await self . closure ( context , event )
116
+ func handle( event : In , context : Lambda . Context ) async throws -> Out {
117
+ try await self . closure ( event , context )
124
118
}
125
119
}
126
120
127
121
internal struct CodableVoidAsyncWrapper < In: Decodable > : AsyncLambdaHandler {
128
122
typealias In = In
129
123
typealias Out = Void
130
124
131
- private let closure : Lambda . CodableVoidAsyncClosure < In >
125
+ private let closure : ( In , Lambda . Context ) async throws -> Void
132
126
133
- init ( _ closure: @escaping Lambda . CodableVoidAsyncClosure < In > ) {
127
+ init ( _ closure: @escaping ( In , Lambda . Context ) async throws -> Void ) {
134
128
self . closure = closure
135
129
}
136
130
137
- func handle( context : Lambda . Context , event : In ) async throws {
138
- try await self . closure ( context , event )
131
+ func handle( event : In , context : Lambda . Context ) async throws {
132
+ try await self . closure ( event , context )
139
133
}
140
134
}
141
135
#endif
0 commit comments