Coverage Report

Created: 2026-02-14 07:10

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/grpc-swift/FuzzTesting/Sources/EchoModel/echo.grpc.swift
Line
Count
Source
1
//
2
// DO NOT EDIT.
3
// swift-format-ignore-file
4
//
5
// Generated by the protocol buffer compiler.
6
// Source: echo.proto
7
//
8
import GRPC
9
import NIO
10
import NIOConcurrencyHelpers
11
import SwiftProtobuf
12
13
14
/// Usage: instantiate `Echo_EchoClient`, then call methods of this protocol to make API calls.
15
public protocol Echo_EchoClientProtocol: GRPCClient {
16
  var serviceName: String { get }
17
  var interceptors: Echo_EchoClientInterceptorFactoryProtocol? { get }
18
19
  func get(
20
    _ request: Echo_EchoRequest,
21
    callOptions: CallOptions?
22
  ) -> UnaryCall<Echo_EchoRequest, Echo_EchoResponse>
23
24
  func expand(
25
    _ request: Echo_EchoRequest,
26
    callOptions: CallOptions?,
27
    handler: @escaping (Echo_EchoResponse) -> Void
28
  ) -> ServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
29
30
  func collect(
31
    callOptions: CallOptions?
32
  ) -> ClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
33
34
  func update(
35
    callOptions: CallOptions?,
36
    handler: @escaping (Echo_EchoResponse) -> Void
37
  ) -> BidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
38
}
39
40
extension Echo_EchoClientProtocol {
41
0
  public var serviceName: String {
42
0
    return "echo.Echo"
43
0
  }
44
45
  /// Immediately returns an echo of a request.
46
  ///
47
  /// - Parameters:
48
  ///   - request: Request to send to Get.
49
  ///   - callOptions: Call options.
50
  /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
51
  public func get(
52
    _ request: Echo_EchoRequest,
53
    callOptions: CallOptions? = nil
54
0
  ) -> UnaryCall<Echo_EchoRequest, Echo_EchoResponse> {
55
0
    return self.makeUnaryCall(
56
0
      path: Echo_EchoClientMetadata.Methods.get.path,
57
0
      request: request,
58
0
      callOptions: callOptions ?? self.defaultCallOptions,
59
0
      interceptors: self.interceptors?.makeGetInterceptors() ?? []
60
0
    )
61
0
  }
62
63
  /// Splits a request into words and returns each word in a stream of messages.
64
  ///
65
  /// - Parameters:
66
  ///   - request: Request to send to Expand.
67
  ///   - callOptions: Call options.
68
  ///   - handler: A closure called when each response is received from the server.
69
  /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
70
  public func expand(
71
    _ request: Echo_EchoRequest,
72
    callOptions: CallOptions? = nil,
73
    handler: @escaping (Echo_EchoResponse) -> Void
74
0
  ) -> ServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
75
0
    return self.makeServerStreamingCall(
76
0
      path: Echo_EchoClientMetadata.Methods.expand.path,
77
0
      request: request,
78
0
      callOptions: callOptions ?? self.defaultCallOptions,
79
0
      interceptors: self.interceptors?.makeExpandInterceptors() ?? [],
80
0
      handler: handler
81
0
    )
82
0
  }
83
84
  /// Collects a stream of messages and returns them concatenated when the caller closes.
85
  ///
86
  /// Callers should use the `send` method on the returned object to send messages
87
  /// to the server. The caller should send an `.end` after the final message has been sent.
88
  ///
89
  /// - Parameters:
90
  ///   - callOptions: Call options.
91
  /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
92
  public func collect(
93
    callOptions: CallOptions? = nil
94
0
  ) -> ClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
95
0
    return self.makeClientStreamingCall(
96
0
      path: Echo_EchoClientMetadata.Methods.collect.path,
97
0
      callOptions: callOptions ?? self.defaultCallOptions,
98
0
      interceptors: self.interceptors?.makeCollectInterceptors() ?? []
99
0
    )
100
0
  }
101
102
  /// Streams back messages as they are received in an input stream.
103
  ///
104
  /// Callers should use the `send` method on the returned object to send messages
105
  /// to the server. The caller should send an `.end` after the final message has been sent.
106
  ///
107
  /// - Parameters:
108
  ///   - callOptions: Call options.
109
  ///   - handler: A closure called when each response is received from the server.
110
  /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
111
  public func update(
112
    callOptions: CallOptions? = nil,
113
    handler: @escaping (Echo_EchoResponse) -> Void
114
0
  ) -> BidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
115
0
    return self.makeBidirectionalStreamingCall(
116
0
      path: Echo_EchoClientMetadata.Methods.update.path,
117
0
      callOptions: callOptions ?? self.defaultCallOptions,
118
0
      interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
119
0
      handler: handler
120
0
    )
121
0
  }
122
}
123
124
@available(*, deprecated)
125
extension Echo_EchoClient: @unchecked Sendable {}
126
127
@available(*, deprecated, renamed: "Echo_EchoNIOClient")
128
public final class Echo_EchoClient: Echo_EchoClientProtocol {
129
0
  private let lock = Lock()
130
  private var _defaultCallOptions: CallOptions
131
  private var _interceptors: Echo_EchoClientInterceptorFactoryProtocol?
132
  public let channel: GRPCChannel
133
  public var defaultCallOptions: CallOptions {
134
0
    get { self.lock.withLock { return self._defaultCallOptions } }
135
0
    set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
136
  }
137
  public var interceptors: Echo_EchoClientInterceptorFactoryProtocol? {
138
0
    get { self.lock.withLock { return self._interceptors } }
139
0
    set { self.lock.withLockVoid { self._interceptors = newValue } }
140
  }
141
142
  /// Creates a client for the echo.Echo service.
143
  ///
144
  /// - Parameters:
145
  ///   - channel: `GRPCChannel` to the service host.
146
  ///   - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
147
  ///   - interceptors: A factory providing interceptors for each RPC.
148
  public init(
149
    channel: GRPCChannel,
150
    defaultCallOptions: CallOptions = CallOptions(),
151
    interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
152
0
  ) {
153
0
    self.channel = channel
154
0
    self._defaultCallOptions = defaultCallOptions
155
0
    self._interceptors = interceptors
156
0
  }
157
}
158
159
public struct Echo_EchoNIOClient: Echo_EchoClientProtocol {
160
  public var channel: GRPCChannel
161
  public var defaultCallOptions: CallOptions
162
  public var interceptors: Echo_EchoClientInterceptorFactoryProtocol?
163
164
  /// Creates a client for the echo.Echo service.
165
  ///
166
  /// - Parameters:
167
  ///   - channel: `GRPCChannel` to the service host.
168
  ///   - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
169
  ///   - interceptors: A factory providing interceptors for each RPC.
170
  public init(
171
    channel: GRPCChannel,
172
    defaultCallOptions: CallOptions = CallOptions(),
173
    interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
174
0
  ) {
175
0
    self.channel = channel
176
0
    self.defaultCallOptions = defaultCallOptions
177
0
    self.interceptors = interceptors
178
0
  }
179
}
180
181
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
182
public protocol Echo_EchoAsyncClientProtocol: GRPCClient {
183
  static var serviceDescriptor: GRPCServiceDescriptor { get }
184
  var interceptors: Echo_EchoClientInterceptorFactoryProtocol? { get }
185
186
  func makeGetCall(
187
    _ request: Echo_EchoRequest,
188
    callOptions: CallOptions?
189
  ) -> GRPCAsyncUnaryCall<Echo_EchoRequest, Echo_EchoResponse>
190
191
  func makeExpandCall(
192
    _ request: Echo_EchoRequest,
193
    callOptions: CallOptions?
194
  ) -> GRPCAsyncServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
195
196
  func makeCollectCall(
197
    callOptions: CallOptions?
198
  ) -> GRPCAsyncClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
199
200
  func makeUpdateCall(
201
    callOptions: CallOptions?
202
  ) -> GRPCAsyncBidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
203
}
204
205
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
206
extension Echo_EchoAsyncClientProtocol {
207
0
  public static var serviceDescriptor: GRPCServiceDescriptor {
208
0
    return Echo_EchoClientMetadata.serviceDescriptor
209
0
  }
210
211
0
  public var interceptors: Echo_EchoClientInterceptorFactoryProtocol? {
212
0
    return nil
213
0
  }
214
215
  public func makeGetCall(
216
    _ request: Echo_EchoRequest,
217
    callOptions: CallOptions? = nil
218
0
  ) -> GRPCAsyncUnaryCall<Echo_EchoRequest, Echo_EchoResponse> {
219
0
    return self.makeAsyncUnaryCall(
220
0
      path: Echo_EchoClientMetadata.Methods.get.path,
221
0
      request: request,
222
0
      callOptions: callOptions ?? self.defaultCallOptions,
223
0
      interceptors: self.interceptors?.makeGetInterceptors() ?? []
224
0
    )
225
0
  }
226
227
  public func makeExpandCall(
228
    _ request: Echo_EchoRequest,
229
    callOptions: CallOptions? = nil
230
0
  ) -> GRPCAsyncServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
231
0
    return self.makeAsyncServerStreamingCall(
232
0
      path: Echo_EchoClientMetadata.Methods.expand.path,
233
0
      request: request,
234
0
      callOptions: callOptions ?? self.defaultCallOptions,
235
0
      interceptors: self.interceptors?.makeExpandInterceptors() ?? []
236
0
    )
237
0
  }
238
239
  public func makeCollectCall(
240
    callOptions: CallOptions? = nil
241
0
  ) -> GRPCAsyncClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
242
0
    return self.makeAsyncClientStreamingCall(
243
0
      path: Echo_EchoClientMetadata.Methods.collect.path,
244
0
      callOptions: callOptions ?? self.defaultCallOptions,
245
0
      interceptors: self.interceptors?.makeCollectInterceptors() ?? []
246
0
    )
247
0
  }
248
249
  public func makeUpdateCall(
250
    callOptions: CallOptions? = nil
251
0
  ) -> GRPCAsyncBidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
252
0
    return self.makeAsyncBidirectionalStreamingCall(
253
0
      path: Echo_EchoClientMetadata.Methods.update.path,
254
0
      callOptions: callOptions ?? self.defaultCallOptions,
255
0
      interceptors: self.interceptors?.makeUpdateInterceptors() ?? []
256
0
    )
257
0
  }
258
}
259
260
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
261
extension Echo_EchoAsyncClientProtocol {
262
  public func get(
263
    _ request: Echo_EchoRequest,
264
    callOptions: CallOptions? = nil
265
0
  ) async throws -> Echo_EchoResponse {
266
0
    return try await self.performAsyncUnaryCall(
267
0
      path: Echo_EchoClientMetadata.Methods.get.path,
268
0
      request: request,
269
0
      callOptions: callOptions ?? self.defaultCallOptions,
270
0
      interceptors: self.interceptors?.makeGetInterceptors() ?? []
271
0
    )
272
0
  }
273
274
  public func expand(
275
    _ request: Echo_EchoRequest,
276
    callOptions: CallOptions? = nil
277
0
  ) -> GRPCAsyncResponseStream<Echo_EchoResponse> {
278
0
    return self.performAsyncServerStreamingCall(
279
0
      path: Echo_EchoClientMetadata.Methods.expand.path,
280
0
      request: request,
281
0
      callOptions: callOptions ?? self.defaultCallOptions,
282
0
      interceptors: self.interceptors?.makeExpandInterceptors() ?? []
283
0
    )
284
0
  }
285
286
  public func collect<RequestStream>(
287
    _ requests: RequestStream,
288
    callOptions: CallOptions? = nil
289
0
  ) async throws -> Echo_EchoResponse where RequestStream: Sequence, RequestStream.Element == Echo_EchoRequest {
290
0
    return try await self.performAsyncClientStreamingCall(
291
0
      path: Echo_EchoClientMetadata.Methods.collect.path,
292
0
      requests: requests,
293
0
      callOptions: callOptions ?? self.defaultCallOptions,
294
0
      interceptors: self.interceptors?.makeCollectInterceptors() ?? []
295
0
    )
296
0
  }
297
298
  public func collect<RequestStream>(
299
    _ requests: RequestStream,
300
    callOptions: CallOptions? = nil
301
0
  ) async throws -> Echo_EchoResponse where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Echo_EchoRequest {
302
0
    return try await self.performAsyncClientStreamingCall(
303
0
      path: Echo_EchoClientMetadata.Methods.collect.path,
304
0
      requests: requests,
305
0
      callOptions: callOptions ?? self.defaultCallOptions,
306
0
      interceptors: self.interceptors?.makeCollectInterceptors() ?? []
307
0
    )
308
0
  }
309
310
  public func update<RequestStream>(
311
    _ requests: RequestStream,
312
    callOptions: CallOptions? = nil
313
0
  ) -> GRPCAsyncResponseStream<Echo_EchoResponse> where RequestStream: Sequence, RequestStream.Element == Echo_EchoRequest {
314
0
    return self.performAsyncBidirectionalStreamingCall(
315
0
      path: Echo_EchoClientMetadata.Methods.update.path,
316
0
      requests: requests,
317
0
      callOptions: callOptions ?? self.defaultCallOptions,
318
0
      interceptors: self.interceptors?.makeUpdateInterceptors() ?? []
319
0
    )
320
0
  }
321
322
  public func update<RequestStream>(
323
    _ requests: RequestStream,
324
    callOptions: CallOptions? = nil
325
0
  ) -> GRPCAsyncResponseStream<Echo_EchoResponse> where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Echo_EchoRequest {
326
0
    return self.performAsyncBidirectionalStreamingCall(
327
0
      path: Echo_EchoClientMetadata.Methods.update.path,
328
0
      requests: requests,
329
0
      callOptions: callOptions ?? self.defaultCallOptions,
330
0
      interceptors: self.interceptors?.makeUpdateInterceptors() ?? []
331
0
    )
332
0
  }
333
}
334
335
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
336
public struct Echo_EchoAsyncClient: Echo_EchoAsyncClientProtocol {
337
  public var channel: GRPCChannel
338
  public var defaultCallOptions: CallOptions
339
  public var interceptors: Echo_EchoClientInterceptorFactoryProtocol?
340
341
  public init(
342
    channel: GRPCChannel,
343
    defaultCallOptions: CallOptions = CallOptions(),
344
    interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
345
0
  ) {
346
0
    self.channel = channel
347
0
    self.defaultCallOptions = defaultCallOptions
348
0
    self.interceptors = interceptors
349
0
  }
350
}
351
352
public protocol Echo_EchoClientInterceptorFactoryProtocol: Sendable {
353
354
  /// - Returns: Interceptors to use when invoking 'get'.
355
  func makeGetInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
356
357
  /// - Returns: Interceptors to use when invoking 'expand'.
358
  func makeExpandInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
359
360
  /// - Returns: Interceptors to use when invoking 'collect'.
361
  func makeCollectInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
362
363
  /// - Returns: Interceptors to use when invoking 'update'.
364
  func makeUpdateInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
365
}
366
367
public enum Echo_EchoClientMetadata {
368
  public static let serviceDescriptor = GRPCServiceDescriptor(
369
    name: "Echo",
370
    fullName: "echo.Echo",
371
    methods: [
372
      Echo_EchoClientMetadata.Methods.get,
373
      Echo_EchoClientMetadata.Methods.expand,
374
      Echo_EchoClientMetadata.Methods.collect,
375
      Echo_EchoClientMetadata.Methods.update,
376
    ]
377
  )
378
379
  public enum Methods {
380
    public static let get = GRPCMethodDescriptor(
381
      name: "Get",
382
      path: "/echo.Echo/Get",
383
      type: GRPCCallType.unary
384
    )
385
386
    public static let expand = GRPCMethodDescriptor(
387
      name: "Expand",
388
      path: "/echo.Echo/Expand",
389
      type: GRPCCallType.serverStreaming
390
    )
391
392
    public static let collect = GRPCMethodDescriptor(
393
      name: "Collect",
394
      path: "/echo.Echo/Collect",
395
      type: GRPCCallType.clientStreaming
396
    )
397
398
    public static let update = GRPCMethodDescriptor(
399
      name: "Update",
400
      path: "/echo.Echo/Update",
401
      type: GRPCCallType.bidirectionalStreaming
402
    )
403
  }
404
}
405
406
@available(swift, deprecated: 5.6)
407
extension Echo_EchoTestClient: @unchecked Sendable {}
408
409
@available(swift, deprecated: 5.6, message: "Test clients are not Sendable but the 'GRPCClient' API requires clients to be Sendable. Using a localhost client and server is the recommended alternative.")
410
public final class Echo_EchoTestClient: Echo_EchoClientProtocol {
411
  private let fakeChannel: FakeChannel
412
  public var defaultCallOptions: CallOptions
413
  public var interceptors: Echo_EchoClientInterceptorFactoryProtocol?
414
415
0
  public var channel: GRPCChannel {
416
0
    return self.fakeChannel
417
0
  }
418
419
  public init(
420
    fakeChannel: FakeChannel = FakeChannel(),
421
    defaultCallOptions callOptions: CallOptions = CallOptions(),
422
    interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
423
0
  ) {
424
0
    self.fakeChannel = fakeChannel
425
0
    self.defaultCallOptions = callOptions
426
0
    self.interceptors = interceptors
427
0
  }
428
429
  /// Make a unary response for the Get RPC. This must be called
430
  /// before calling 'get'. See also 'FakeUnaryResponse'.
431
  ///
432
  /// - Parameter requestHandler: a handler for request parts sent by the RPC.
433
  public func makeGetResponseStream(
434
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
435
0
  ) -> FakeUnaryResponse<Echo_EchoRequest, Echo_EchoResponse> {
436
0
    return self.fakeChannel.makeFakeUnaryResponse(path: Echo_EchoClientMetadata.Methods.get.path, requestHandler: requestHandler)
437
0
  }
438
439
  public func enqueueGetResponse(
440
    _ response: Echo_EchoResponse,
441
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
442
0
  ) {
443
0
    let stream = self.makeGetResponseStream(requestHandler)
444
0
    // This is the only operation on the stream; try! is fine.
445
0
    try! stream.sendMessage(response)
446
0
  }
447
448
  /// Returns true if there are response streams enqueued for 'Get'
449
0
  public var hasGetResponsesRemaining: Bool {
450
0
    return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.get.path)
451
0
  }
452
453
  /// Make a streaming response for the Expand RPC. This must be called
454
  /// before calling 'expand'. See also 'FakeStreamingResponse'.
455
  ///
456
  /// - Parameter requestHandler: a handler for request parts sent by the RPC.
457
  public func makeExpandResponseStream(
458
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
459
0
  ) -> FakeStreamingResponse<Echo_EchoRequest, Echo_EchoResponse> {
460
0
    return self.fakeChannel.makeFakeStreamingResponse(path: Echo_EchoClientMetadata.Methods.expand.path, requestHandler: requestHandler)
461
0
  }
462
463
  public func enqueueExpandResponses(
464
    _ responses: [Echo_EchoResponse],
465
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
466
0
  ) {
467
0
    let stream = self.makeExpandResponseStream(requestHandler)
468
0
    // These are the only operation on the stream; try! is fine.
469
0
    responses.forEach { try! stream.sendMessage($0) }
470
0
    try! stream.sendEnd()
471
0
  }
472
473
  /// Returns true if there are response streams enqueued for 'Expand'
474
0
  public var hasExpandResponsesRemaining: Bool {
475
0
    return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.expand.path)
476
0
  }
477
478
  /// Make a unary response for the Collect RPC. This must be called
479
  /// before calling 'collect'. See also 'FakeUnaryResponse'.
480
  ///
481
  /// - Parameter requestHandler: a handler for request parts sent by the RPC.
482
  public func makeCollectResponseStream(
483
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
484
0
  ) -> FakeUnaryResponse<Echo_EchoRequest, Echo_EchoResponse> {
485
0
    return self.fakeChannel.makeFakeUnaryResponse(path: Echo_EchoClientMetadata.Methods.collect.path, requestHandler: requestHandler)
486
0
  }
487
488
  public func enqueueCollectResponse(
489
    _ response: Echo_EchoResponse,
490
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
491
0
  ) {
492
0
    let stream = self.makeCollectResponseStream(requestHandler)
493
0
    // This is the only operation on the stream; try! is fine.
494
0
    try! stream.sendMessage(response)
495
0
  }
496
497
  /// Returns true if there are response streams enqueued for 'Collect'
498
0
  public var hasCollectResponsesRemaining: Bool {
499
0
    return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.collect.path)
500
0
  }
501
502
  /// Make a streaming response for the Update RPC. This must be called
503
  /// before calling 'update'. See also 'FakeStreamingResponse'.
504
  ///
505
  /// - Parameter requestHandler: a handler for request parts sent by the RPC.
506
  public func makeUpdateResponseStream(
507
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
508
0
  ) -> FakeStreamingResponse<Echo_EchoRequest, Echo_EchoResponse> {
509
0
    return self.fakeChannel.makeFakeStreamingResponse(path: Echo_EchoClientMetadata.Methods.update.path, requestHandler: requestHandler)
510
0
  }
511
512
  public func enqueueUpdateResponses(
513
    _ responses: [Echo_EchoResponse],
514
0
    _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
515
0
  ) {
516
0
    let stream = self.makeUpdateResponseStream(requestHandler)
517
0
    // These are the only operation on the stream; try! is fine.
518
0
    responses.forEach { try! stream.sendMessage($0) }
519
0
    try! stream.sendEnd()
520
0
  }
521
522
  /// Returns true if there are response streams enqueued for 'Update'
523
0
  public var hasUpdateResponsesRemaining: Bool {
524
0
    return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.update.path)
525
0
  }
526
}
527
528
/// To build a server, implement a class that conforms to this protocol.
529
public protocol Echo_EchoProvider: CallHandlerProvider {
530
  var interceptors: Echo_EchoServerInterceptorFactoryProtocol? { get }
531
532
  /// Immediately returns an echo of a request.
533
  func get(request: Echo_EchoRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Echo_EchoResponse>
534
535
  /// Splits a request into words and returns each word in a stream of messages.
536
  func expand(request: Echo_EchoRequest, context: StreamingResponseCallContext<Echo_EchoResponse>) -> EventLoopFuture<GRPCStatus>
537
538
  /// Collects a stream of messages and returns them concatenated when the caller closes.
539
  func collect(context: UnaryResponseCallContext<Echo_EchoResponse>) -> EventLoopFuture<(StreamEvent<Echo_EchoRequest>) -> Void>
540
541
  /// Streams back messages as they are received in an input stream.
542
  func update(context: StreamingResponseCallContext<Echo_EchoResponse>) -> EventLoopFuture<(StreamEvent<Echo_EchoRequest>) -> Void>
543
}
544
545
extension Echo_EchoProvider {
546
31.5k
  public var serviceName: Substring {
547
31.5k
    return Echo_EchoServerMetadata.serviceDescriptor.fullName[...]
548
31.5k
  }
549
550
  /// Determines, calls and returns the appropriate request handler, depending on the request's method.
551
  /// Returns nil for methods not handled by this service.
552
  public func handle(
553
    method name: Substring,
554
    context: CallHandlerContext
555
176k
  ) -> GRPCServerHandlerProtocol? {
556
176k
    switch name {
557
176k
    case "Get":
558
52.9k
      return UnaryServerHandler(
559
52.9k
        context: context,
560
52.9k
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
561
52.9k
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
562
52.9k
        interceptors: self.interceptors?.makeGetInterceptors() ?? [],
563
75.3k
        userFunction: self.get(request:context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyAA0a1_A8ResponseVGAA0a1_A7RequestV_AG010StatusOnlykL0_ptcxcfu0_
Line
Count
Source
563
52.9k
        userFunction: self.get(request:context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyAA0a1_A8ResponseVGAA0a1_A7RequestV_AG010StatusOnlykL0_ptcxcfu0_AqS_AgT_ptcfu1_
Line
Count
Source
563
22.4k
        userFunction: self.get(request:context:)
564
52.9k
      )
565
176k
566
176k
    case "Expand":
567
20.5k
      return ServerStreamingServerHandler(
568
20.5k
        context: context,
569
20.5k
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
570
20.5k
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
571
20.5k
        interceptors: self.interceptors?.makeExpandInterceptors() ?? [],
572
36.0k
        userFunction: self.expand(request:context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyAG10GRPCStatusVGAA0a1_A7RequestV_AG017StreamingResponsekL0CyAA0a1_aT0VGtcxcfu3_
Line
Count
Source
572
20.5k
        userFunction: self.expand(request:context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyAG10GRPCStatusVGAA0a1_A7RequestV_AG017StreamingResponsekL0CyAA0a1_aT0VGtcxcfu3_AqS_AXtcfu4_
Line
Count
Source
572
15.4k
        userFunction: self.expand(request:context:)
573
20.5k
      )
574
176k
575
176k
    case "Collect":
576
53.5k
      return ClientStreamingServerHandler(
577
53.5k
        context: context,
578
53.5k
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
579
53.5k
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
580
53.5k
        interceptors: self.interceptors?.makeCollectInterceptors() ?? [],
581
107k
        observerFactory: self.collect(context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyyAG06StreamN0OyAA0a1_A7RequestVGcGAG013UnaryResponsekL0CyAA0a1_aT0VGcxcfu6_
Line
Count
Source
581
53.5k
        observerFactory: self.collect(context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyyAG06StreamN0OyAA0a1_A7RequestVGcGAG013UnaryResponsekL0CyAA0a1_aT0VGcxcfu6_AtYcfu7_
Line
Count
Source
581
53.5k
        observerFactory: self.collect(context:)
582
53.5k
      )
583
176k
584
176k
    case "Update":
585
46.8k
      return BidirectionalStreamingServerHandler(
586
46.8k
        context: context,
587
46.8k
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
588
46.8k
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
589
46.8k
        interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
590
93.7k
        observerFactory: self.update(context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyyAG06StreamN0OyAA0a1_A7RequestVGcGAG017StreamingResponsekL0CyAA0a1_aT0VGcxcfu9_
Line
Count
Source
590
46.8k
        observerFactory: self.update(context:)
$s9EchoModel0a1_A8ProviderPAAE6handle6method7context4GRPC25GRPCServerHandlerProtocol_pSgSs_AG04CallI7ContextVtF7NIOCore15EventLoopFutureCyyAG06StreamN0OyAA0a1_A7RequestVGcGAG017StreamingResponsekL0CyAA0a1_aT0VGcxcfu9_AtYcfu10_
Line
Count
Source
590
46.8k
        observerFactory: self.update(context:)
591
46.8k
      )
592
176k
593
176k
    default:
594
2.15k
      return nil
595
176k
    }
596
176k
  }
597
}
598
599
/// To implement a server, implement an object which conforms to this protocol.
600
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
601
public protocol Echo_EchoAsyncProvider: CallHandlerProvider, Sendable {
602
  static var serviceDescriptor: GRPCServiceDescriptor { get }
603
  var interceptors: Echo_EchoServerInterceptorFactoryProtocol? { get }
604
605
  /// Immediately returns an echo of a request.
606
  func get(
607
    request: Echo_EchoRequest,
608
    context: GRPCAsyncServerCallContext
609
  ) async throws -> Echo_EchoResponse
610
611
  /// Splits a request into words and returns each word in a stream of messages.
612
  func expand(
613
    request: Echo_EchoRequest,
614
    responseStream: GRPCAsyncResponseStreamWriter<Echo_EchoResponse>,
615
    context: GRPCAsyncServerCallContext
616
  ) async throws
617
618
  /// Collects a stream of messages and returns them concatenated when the caller closes.
619
  func collect(
620
    requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
621
    context: GRPCAsyncServerCallContext
622
  ) async throws -> Echo_EchoResponse
623
624
  /// Streams back messages as they are received in an input stream.
625
  func update(
626
    requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
627
    responseStream: GRPCAsyncResponseStreamWriter<Echo_EchoResponse>,
628
    context: GRPCAsyncServerCallContext
629
  ) async throws
630
}
631
632
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
633
extension Echo_EchoAsyncProvider {
634
0
  public static var serviceDescriptor: GRPCServiceDescriptor {
635
0
    return Echo_EchoServerMetadata.serviceDescriptor
636
0
  }
637
638
0
  public var serviceName: Substring {
639
0
    return Echo_EchoServerMetadata.serviceDescriptor.fullName[...]
640
0
  }
641
642
0
  public var interceptors: Echo_EchoServerInterceptorFactoryProtocol? {
643
0
    return nil
644
0
  }
645
646
  public func handle(
647
    method name: Substring,
648
    context: CallHandlerContext
649
0
  ) -> GRPCServerHandlerProtocol? {
650
0
    switch name {
651
0
    case "Get":
652
0
      return GRPCAsyncServerHandler(
653
0
        context: context,
654
0
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
655
0
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
656
0
        interceptors: self.interceptors?.makeGetInterceptors() ?? [],
657
0
        wrapping: { try await self.get(request: $0, context: $1) }
658
0
      )
659
0
660
0
    case "Expand":
661
0
      return GRPCAsyncServerHandler(
662
0
        context: context,
663
0
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
664
0
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
665
0
        interceptors: self.interceptors?.makeExpandInterceptors() ?? [],
666
0
        wrapping: { try await self.expand(request: $0, responseStream: $1, context: $2) }
667
0
      )
668
0
669
0
    case "Collect":
670
0
      return GRPCAsyncServerHandler(
671
0
        context: context,
672
0
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
673
0
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
674
0
        interceptors: self.interceptors?.makeCollectInterceptors() ?? [],
675
0
        wrapping: { try await self.collect(requestStream: $0, context: $1) }
676
0
      )
677
0
678
0
    case "Update":
679
0
      return GRPCAsyncServerHandler(
680
0
        context: context,
681
0
        requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
682
0
        responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
683
0
        interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
684
0
        wrapping: { try await self.update(requestStream: $0, responseStream: $1, context: $2) }
685
0
      )
686
0
687
0
    default:
688
0
      return nil
689
0
    }
690
0
  }
691
}
692
693
public protocol Echo_EchoServerInterceptorFactoryProtocol: Sendable {
694
695
  /// - Returns: Interceptors to use when handling 'get'.
696
  ///   Defaults to calling `self.makeInterceptors()`.
697
  func makeGetInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
698
699
  /// - Returns: Interceptors to use when handling 'expand'.
700
  ///   Defaults to calling `self.makeInterceptors()`.
701
  func makeExpandInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
702
703
  /// - Returns: Interceptors to use when handling 'collect'.
704
  ///   Defaults to calling `self.makeInterceptors()`.
705
  func makeCollectInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
706
707
  /// - Returns: Interceptors to use when handling 'update'.
708
  ///   Defaults to calling `self.makeInterceptors()`.
709
  func makeUpdateInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
710
}
711
712
public enum Echo_EchoServerMetadata {
713
  public static let serviceDescriptor = GRPCServiceDescriptor(
714
    name: "Echo",
715
    fullName: "echo.Echo",
716
    methods: [
717
      Echo_EchoServerMetadata.Methods.get,
718
      Echo_EchoServerMetadata.Methods.expand,
719
      Echo_EchoServerMetadata.Methods.collect,
720
      Echo_EchoServerMetadata.Methods.update,
721
    ]
722
  )
723
724
  public enum Methods {
725
    public static let get = GRPCMethodDescriptor(
726
      name: "Get",
727
      path: "/echo.Echo/Get",
728
      type: GRPCCallType.unary
729
    )
730
731
    public static let expand = GRPCMethodDescriptor(
732
      name: "Expand",
733
      path: "/echo.Echo/Expand",
734
      type: GRPCCallType.serverStreaming
735
    )
736
737
    public static let collect = GRPCMethodDescriptor(
738
      name: "Collect",
739
      path: "/echo.Echo/Collect",
740
      type: GRPCCallType.clientStreaming
741
    )
742
743
    public static let update = GRPCMethodDescriptor(
744
      name: "Update",
745
      path: "/echo.Echo/Update",
746
      type: GRPCCallType.bidirectionalStreaming
747
    )
748
  }
749
}