@@ -104,7 +104,7 @@ private struct LambdaHTTPServer {
104
104
invocationEndpoint: String ? ,
105
105
host: String = " 127.0.0.1 " ,
106
106
port: Int = 7000 ,
107
- eventLoopGroup: MultiThreadedEventLoopGroup = . singleton,
107
+ eventLoopGroup: MultiThreadedEventLoopGroup = . singleton,
108
108
logger: Logger ,
109
109
_ closure: sending @escaping ( ) async throws -> Result
110
110
) async throws -> Result {
@@ -145,7 +145,8 @@ private struct LambdaHTTPServer {
145
145
// Sadly the Swift compiler does not understand that the passed in closure will only be
146
146
// invoked once. Because of this we need an unsafe transfer box here. Buuuh!
147
147
let closureBox = UnsafeTransferBox ( value: closure)
148
- let result = await withTaskGroup ( of: TaskResult< Result> . self , returning: Swift . Result < Result , any Error > . self) { group in
148
+ let result = await withTaskGroup ( of: TaskResult< Result> . self , returning: Swift . Result < Result , any Error > . self) {
149
+ group in
149
150
group. addTask {
150
151
let c = closureBox. value
151
152
do {
@@ -196,9 +197,12 @@ private struct LambdaHTTPServer {
196
197
return result
197
198
198
199
case . serverReturned( let result) :
199
- logger. error ( " Server shutdown before closure completed " , metadata: [
200
- " error " : " \( result. maybeError != nil ? " \( result. maybeError!) " : " none " ) "
201
- ] )
200
+ logger. error (
201
+ " Server shutdown before closure completed " ,
202
+ metadata: [
203
+ " error " : " \( result. maybeError != nil ? " \( result. maybeError!) " : " none " ) "
204
+ ]
205
+ )
202
206
switch await group. next ( ) ! {
203
207
case . closureResult( let result) :
204
208
return result
@@ -213,8 +217,6 @@ private struct LambdaHTTPServer {
213
217
return try result. get ( )
214
218
}
215
219
216
-
217
-
218
220
/// This method handles individual TCP connections
219
221
private func handleConnection(
220
222
channel: NIOAsyncChannel < HTTPServerRequestPart , HTTPServerResponsePart > ,
@@ -272,7 +274,11 @@ private struct LambdaHTTPServer {
272
274
/// - body: the HTTP request body
273
275
/// - Throws:
274
276
/// - Returns: the response to send back to the client or the Lambda function
275
- private func processRequest( head: HTTPRequestHead , body: ByteBuffer ? , logger: Logger ) async throws -> LocalServerResponse {
277
+ private func processRequest(
278
+ head: HTTPRequestHead ,
279
+ body: ByteBuffer ? ,
280
+ logger: Logger
281
+ ) async throws -> LocalServerResponse {
276
282
277
283
if let body {
278
284
logger. trace (
@@ -296,7 +302,7 @@ private struct LambdaHTTPServer {
296
302
// we always accept the /invoke request and push them to the pool
297
303
let requestId = " \( DispatchTime . now ( ) . uptimeNanoseconds) "
298
304
var logger = logger
299
- logger [ metadataKey: " requestID " ] = " \( requestId) "
305
+ logger [ metadataKey: " requestID " ] = " \( requestId) "
300
306
logger. trace ( " /invoke received invocation " )
301
307
await self . invocationPool. push ( LocalServerInvocation ( requestId: requestId, request: body) )
302
308
0 commit comments