Skip to content

Commit 467d012

Browse files
committed
Use NIOLoopBound
1 parent ec68898 commit 467d012

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

Sources/AWSLambdaRuntimeCore/LambdaRuntimeClient.swift

+2-13
Original file line numberDiff line numberDiff line change
@@ -410,17 +410,6 @@ private protocol LambdaChannelHandlerDelegate {
410410
func connectionErrorHappened(_ error: any Error, channel: any Channel)
411411
}
412412

413-
struct UnsafeContext: @unchecked Sendable {
414-
private let _context: ChannelHandlerContext
415-
var context: ChannelHandlerContext {
416-
self._context.eventLoop.preconditionInEventLoop()
417-
return _context
418-
}
419-
init(_ context: ChannelHandlerContext) {
420-
self._context = context
421-
}
422-
}
423-
424413
private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate> {
425414
let nextInvocationPath = Consts.invocationURLPrefix + Consts.getNextInvocationURLSuffix
426415

@@ -486,7 +475,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
486475
(continuation: CheckedContinuation<Invocation, any Error>) in
487476
self.state = .connected(context, .waitingForNextInvocation(continuation))
488477

489-
let unsafeContext = UnsafeContext(context)
478+
let unsafeContext = NIOLoopBound(context, eventLoop: context.eventLoop)
490479
context.eventLoop.execute { [nextInvocationPath, defaultHeaders] in
491480
// Send next request. The function `sendNextRequest` requires `self` which is not
492481
// Sendable so just inlined the code instead
@@ -496,7 +485,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
496485
uri: nextInvocationPath,
497486
headers: defaultHeaders
498487
)
499-
let context = unsafeContext.context
488+
let context = unsafeContext.value
500489
context.write(Self.wrapOutboundOut(.head(httpRequest)), promise: nil)
501490
context.write(Self.wrapOutboundOut(.end(nil)), promise: nil)
502491
context.flush()

0 commit comments

Comments
 (0)