@@ -17,7 +17,7 @@ import Foundation
17
17
import Logging
18
18
import NIOCore
19
19
20
- package struct LambdaMockWriter : LambdaResponseStreamWriter {
20
+ struct LambdaMockWriter : LambdaResponseStreamWriter {
21
21
var underlying : LambdaMockClient
22
22
23
23
package init ( underlying: LambdaMockClient ) {
@@ -41,43 +41,14 @@ package struct LambdaMockWriter: LambdaResponseStreamWriter {
41
41
}
42
42
}
43
43
44
- package struct LambdaError : Error , Equatable {
45
- private enum Code : Equatable {
46
- case cannotCallNextEndpointWhenAlreadyWaitingForEvent
47
- case cannotCallNextEndpointWhenAlreadyProcessingAnEvent
48
- case cannotReportResultWhenNoEventHasBeenProcessed
49
- }
50
-
51
- private let code : Code
52
-
53
- private init ( code: Code ) {
54
- self . code = code
55
- }
56
-
57
- package func shortDescription( ) -> String {
58
- switch self . code {
59
- case . cannotCallNextEndpointWhenAlreadyWaitingForEvent:
60
- " Cannot call the next endpoint when already waiting for an event "
61
- case . cannotCallNextEndpointWhenAlreadyProcessingAnEvent:
62
- " Cannot call the next endpoint when an event is already being processed "
63
- case . cannotReportResultWhenNoEventHasBeenProcessed:
64
- " Cannot report a result when no event has been processed "
65
- }
66
- }
67
-
68
- package static let cannotCallNextEndpointWhenAlreadyWaitingForEvent = LambdaError (
69
- code: . cannotCallNextEndpointWhenAlreadyWaitingForEvent
70
- )
71
- package static let cannotCallNextEndpointWhenAlreadyProcessingAnEvent = LambdaError (
72
- code: . cannotCallNextEndpointWhenAlreadyProcessingAnEvent
73
- )
74
- package static let cannotReportResultWhenNoEventHasBeenProcessed = LambdaError (
75
- code: . cannotReportResultWhenNoEventHasBeenProcessed
76
- )
44
+ enum LambdaError : Error , Equatable {
45
+ case cannotCallNextEndpointWhenAlreadyWaitingForEvent
46
+ case cannotCallNextEndpointWhenAlreadyProcessingAnEvent
47
+ case cannotReportResultWhenNoEventHasBeenProcessed
77
48
}
78
49
79
- package final actor LambdaMockClient : LambdaRuntimeClientProtocol {
80
- package typealias Writer = LambdaMockWriter
50
+ final actor LambdaMockClient : LambdaRuntimeClientProtocol {
51
+ typealias Writer = LambdaMockWriter
81
52
82
53
private struct StateMachine {
83
54
private enum State {
@@ -203,7 +174,7 @@ package final actor LambdaMockClient: LambdaRuntimeClientProtocol {
203
174
let eventProcessedHandler : CheckedContinuation < ByteBuffer , any Error >
204
175
}
205
176
206
- package func invoke( event: ByteBuffer ) async throws -> ByteBuffer {
177
+ func invoke( event: ByteBuffer ) async throws -> ByteBuffer {
207
178
try await withCheckedThrowingContinuation { eventProcessedHandler in
208
179
do {
209
180
let metadata = try InvocationMetadata (
@@ -236,7 +207,7 @@ package final actor LambdaMockClient: LambdaRuntimeClientProtocol {
236
207
}
237
208
}
238
209
239
- package func nextInvocation( ) async throws -> ( Invocation , Writer ) {
210
+ func nextInvocation( ) async throws -> ( Invocation , Writer ) {
240
211
let invocation = try await withCheckedThrowingContinuation { eventArrivedHandler in
241
212
switch self . stateMachine. next ( eventArrivedHandler) {
242
213
case . readyToProcess( let event) :
@@ -251,7 +222,7 @@ package final actor LambdaMockClient: LambdaRuntimeClientProtocol {
251
222
return ( invocation, Writer ( underlying: self ) )
252
223
}
253
224
254
- package func write( _ buffer: ByteBuffer ) async throws {
225
+ func write( _ buffer: ByteBuffer ) async throws {
255
226
switch self . stateMachine. writeResult ( buffer: buffer) {
256
227
case . readyForMore:
257
228
break
@@ -260,7 +231,7 @@ package final actor LambdaMockClient: LambdaRuntimeClientProtocol {
260
231
}
261
232
}
262
233
263
- package func finish( ) async throws {
234
+ func finish( ) async throws {
264
235
try self . stateMachine. finish ( )
265
236
}
266
237
}
0 commit comments