Skip to content

Commit 40d7769

Browse files
committed
Update local server to Swift 6
1 parent 8724c47 commit 40d7769

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ let package = Package(
2323
.library(name: "AWSLambdaTesting", targets: ["AWSLambdaTesting"]),
2424
],
2525
dependencies: [
26-
.package(url: "https://github.com/apple/swift-nio.git", from: "2.72.0"),
26+
.package(url: "https://github.com/apple/swift-nio.git", from: "2.76.0"),
2727
.package(url: "https://github.com/apple/swift-log.git", from: "1.5.4"),
2828
],
2929
targets: [

Sources/AWSLambdaRuntimeCore/Lambda+LocalServer.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ private enum LocalLambda {
133133
}
134134

135135
func processRequest(context: ChannelHandlerContext, request: (head: HTTPRequestHead, body: ByteBuffer?)) {
136+
137+
let eventLoop = context.eventLoop
138+
let loopBoundContext = NIOLoopBound(context, eventLoop: eventLoop)
139+
136140
switch (request.head.method, request.head.uri) {
137141
// this endpoint is called by the client invoking the lambda
138142
case (.POST, let url) where url.hasSuffix(self.invocationEndpoint):
@@ -142,6 +146,7 @@ private enum LocalLambda {
142146
let requestID = "\(DispatchTime.now().uptimeNanoseconds)" // FIXME:
143147
let promise = context.eventLoop.makePromise(of: Response.self)
144148
promise.futureResult.whenComplete { result in
149+
let context = loopBoundContext.value
145150
switch result {
146151
case .failure(let error):
147152
self.logger.error("invocation error: \(error)")
@@ -178,6 +183,7 @@ private enum LocalLambda {
178183
// create a promise that we can fullfill when we get a new task
179184
let promise = context.eventLoop.makePromise(of: Invocation.self)
180185
promise.futureResult.whenComplete { result in
186+
let context = loopBoundContext.value
181187
switch result {
182188
case .failure(let error):
183189
self.logger.error("invocation error: \(error)")

0 commit comments

Comments
 (0)