@@ -67,10 +67,23 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
67
67
NIOLoopBound < LambdaChannelHandler < LambdaRuntimeClient > > , any Error
68
68
>
69
69
70
- private enum ConnectionState {
70
+ private enum ConnectionState : Equatable {
71
71
case disconnected
72
72
case connecting( [ ConnectionContinuation ] )
73
73
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
+ }
74
87
}
75
88
76
89
enum LambdaState {
@@ -92,14 +105,22 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
92
105
case closed
93
106
}
94
107
95
- @usableFromInline
96
- var futureConnectionClosed : EventLoopFuture < LambdaRuntimeError > ? = nil
97
-
98
108
private let eventLoop : any EventLoop
99
109
private let logger : Logger
100
110
private let configuration : Configuration
101
111
102
112
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
+
103
124
private var lambdaState : LambdaState = . idle( previousRequestID: nil )
104
125
private var closingState : ClosingState = . notClosing
105
126
@@ -367,16 +388,6 @@ final actor LambdaRuntimeClient: LambdaRuntimeClientProtocol {
367
388
channel. closeFuture. whenComplete { result in
368
389
self . assumeIsolated { runtimeClient in
369
390
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
- )
380
391
}
381
392
}
382
393
0 commit comments