@@ -410,17 +410,6 @@ private protocol LambdaChannelHandlerDelegate {
410
410
func connectionErrorHappened( _ error: any Error , channel: any Channel )
411
411
}
412
412
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
-
424
413
private final class LambdaChannelHandler < Delegate: LambdaChannelHandlerDelegate > {
425
414
let nextInvocationPath = Consts . invocationURLPrefix + Consts. getNextInvocationURLSuffix
426
415
@@ -486,7 +475,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
486
475
( continuation: CheckedContinuation < Invocation , any Error > ) in
487
476
self . state = . connected( context, . waitingForNextInvocation( continuation) )
488
477
489
- let unsafeContext = UnsafeContext ( context)
478
+ let unsafeContext = NIOLoopBound ( context, eventLoop : context . eventLoop )
490
479
context. eventLoop. execute { [ nextInvocationPath, defaultHeaders] in
491
480
// Send next request. The function `sendNextRequest` requires `self` which is not
492
481
// Sendable so just inlined the code instead
@@ -496,7 +485,7 @@ private final class LambdaChannelHandler<Delegate: LambdaChannelHandlerDelegate>
496
485
uri: nextInvocationPath,
497
486
headers: defaultHeaders
498
487
)
499
- let context = unsafeContext. context
488
+ let context = unsafeContext. value
500
489
context. write ( Self . wrapOutboundOut ( . head( httpRequest) ) , promise: nil )
501
490
context. write ( Self . wrapOutboundOut ( . end( nil ) ) , promise: nil )
502
491
context. flush ( )
0 commit comments