test.grpc.swift 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // DO NOT EDIT.
  3. // swift-format-ignore-file
  4. //
  5. // Generated by the protocol buffer compiler.
  6. // Source: test.proto
  7. //
  8. import GRPC
  9. import NIO
  10. import SwiftProtobuf
  11. internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {
  12. private let fakeChannel: FakeChannel
  13. internal var defaultCallOptions: CallOptions
  14. internal var interceptors: Codegentest_FooClientInterceptorFactoryProtocol?
  15. internal var channel: GRPCChannel {
  16. return self.fakeChannel
  17. }
  18. internal init(
  19. fakeChannel: FakeChannel = FakeChannel(),
  20. defaultCallOptions callOptions: CallOptions = CallOptions(),
  21. interceptors: Codegentest_FooClientInterceptorFactoryProtocol? = nil
  22. ) {
  23. self.fakeChannel = fakeChannel
  24. self.defaultCallOptions = callOptions
  25. self.interceptors = interceptors
  26. }
  27. /// Make a unary response for the Bar RPC. This must be called
  28. /// before calling 'bar'. See also 'FakeUnaryResponse'.
  29. ///
  30. /// - Parameter requestHandler: a handler for request parts sent by the RPC.
  31. internal func makeBarResponseStream(
  32. _ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
  33. ) -> FakeUnaryResponse<Codegentest_BarRequest, Codegentest_BarResponse> {
  34. return self.fakeChannel.makeFakeUnaryResponse(path: "/codegentest.Foo/Bar", requestHandler: requestHandler)
  35. }
  36. internal func enqueueBarResponse(
  37. _ response: Codegentest_BarResponse,
  38. _ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
  39. ) {
  40. let stream = self.makeBarResponseStream(requestHandler)
  41. // This is the only operation on the stream; try! is fine.
  42. try! stream.sendMessage(response)
  43. }
  44. /// Returns true if there are response streams enqueued for 'Bar'
  45. internal var hasBarResponsesRemaining: Bool {
  46. return self.fakeChannel.hasFakeResponseEnqueued(forPath: "/codegentest.Foo/Bar")
  47. }
  48. }