@@ -67,10 +67,23 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
6767 NIOLoopBound < LambdaChannelHandler < LambdaRuntimeClient > > , any Error
6868 >
6969
70- private enum ConnectionState {
70+ private enum ConnectionState : Equatable {
7171 case disconnected
7272 case connecting( [ ConnectionContinuation ] )
7373 case connected( Channel , LambdaChannelHandler < LambdaRuntimeClient > )
74+
75+ static func == ( lhs: ConnectionState , rhs: ConnectionState ) -> Bool {
76+ switch ( lhs, rhs) {
77+ case ( . disconnected, . disconnected) :
78+ return true
79+ case ( . connecting, . connecting) :
80+ return true
81+ case ( . connected, . connected) :
82+ return true
83+ default :
84+ return false
85+ }
86+ }
7487 }
7588
7689 enum LambdaState {
@@ -92,14 +105,22 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
92105 case closed
93106 }
94107
95- @usableFromInline
96- var futureConnectionClosed : EventLoopFuture < LambdaRuntimeError > ? = nil
97-
98108 private let eventLoop : any EventLoop
99109 private let logger : Logger
100110 private let configuration : Configuration
101111
102112 private var connectionState : ConnectionState = . disconnected
113+
114+ // adding this dynamic property because I can not give access to `connectionState` directly
115+ // because it is private, depending on multiple private and non-Sendable types
116+ // the only thing we need to know outside of this class is if the connection state is disconnected
117+ @usableFromInline
118+ var isConnectionStateDisconnected : Bool {
119+ get {
120+ self . connectionState == . disconnected
121+ }
122+ }
123+
103124 private var lambdaState : LambdaState = . idle( previousRequestID: nil )
104125 private var closingState : ClosingState = . notClosing
105126
@@ -367,16 +388,6 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
367388 channel. closeFuture. whenComplete { result in
368389 self . assumeIsolated { runtimeClient in
369390 runtimeClient. channelClosed ( channel)
370-
371- // at this stage, we lost the connection to the Lambda Service,
372- // this is very unlikely to happen when running in a lambda function deployed in the cloud
373- // however, this happens when performance testing against the MockServer
374- // shutdown this runtime.
375- // The Lambda service will create a new runtime environment anyway
376- runtimeClient. logger. trace ( " Connection to Lambda Service HTTP Server lost, exiting " )
377- runtimeClient. futureConnectionClosed = runtimeClient. eventLoop. makeFailedFuture (
378- LambdaRuntimeError ( code: . connectionToControlPlaneLost)
379- )
380391 }
381392 }
382393
0 commit comments