@@ -406,17 +406,6 @@ private protocol LambdaChannelHandlerDelegate {
406
406
func connectionErrorHappened( _ error: any Error , channel: any Channel )
407
407
}
408
408
409
- struct UnsafeContext : @unchecked Sendable {
410
- private let _context : ChannelHandlerContext
411
- var context : ChannelHandlerContext {
412
- self . _context. eventLoop. preconditionInEventLoop ( )
413
- return _context
414
- }
415
- init ( _ context: ChannelHandlerContext ) {
416
- self . _context = context
417
- }
418
- }
419
-
420
409
private final class LambdaChannelHandler < Delegate: LambdaChannelHandlerDelegate > {
421
410
let nextInvocationPath = Consts . invocationURLPrefix + Consts. getNextInvocationURLSuffix
422
411
@@ -482,7 +471,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
482
471
( continuation: CheckedContinuation < Invocation , any Error > ) in
483
472
self . state = . connected( context, . waitingForNextInvocation( continuation) )
484
473
485
- let unsafeContext = UnsafeContext ( context)
474
+ let unsafeContext = NIOLoopBound ( context, eventLoop : context . eventLoop )
486
475
context. eventLoop. execute { [ nextInvocationPath, defaultHeaders] in
487
476
// Send next request. The function `sendNextRequest` requires `self` which is not
488
477
// Sendable so just inlined the code instead
@@ -492,7 +481,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
492
481
uri: nextInvocationPath,
493
482
headers: defaultHeaders
494
483
)
495
- let context = unsafeContext. context
484
+ let context = unsafeContext. value
496
485
context. write ( Self . wrapOutboundOut ( . head( httpRequest) ) , promise: nil )
497
486
context. write ( Self . wrapOutboundOut ( . end( nil ) ) , promise: nil )
498
487
context. flush ( )
0 commit comments