test.grpc.swift 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // DO NOT EDIT.
  3. //
  4. // Generated by the protocol buffer compiler.
  5. // Source: test.proto
  6. //
  7. //
  8. // Copyright 2018, gRPC Authors All rights reserved.
  9. //
  10. // Licensed under the Apache License, Version 2.0 (the "License");
  11. // you may not use this file except in compliance with the License.
  12. // You may obtain a copy of the License at
  13. //
  14. // http://www.apache.org/licenses/LICENSE-2.0
  15. //
  16. // Unless required by applicable law or agreed to in writing, software
  17. // distributed under the License is distributed on an "AS IS" BASIS,
  18. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  19. // See the License for the specific language governing permissions and
  20. // limitations under the License.
  21. //
  22. import GRPC
  23. import NIO
  24. internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {
  25. private let fakeChannel: FakeChannel
  26. internal var defaultCallOptions: CallOptions
  27. internal var channel: GRPCChannel {
  28. return self.fakeChannel
  29. }
  30. internal init(
  31. fakeChannel: FakeChannel = FakeChannel(),
  32. defaultCallOptions callOptions: CallOptions = CallOptions()
  33. ) {
  34. self.fakeChannel = fakeChannel
  35. self.defaultCallOptions = callOptions
  36. }
  37. /// Make a unary response for the Bar RPC. This must be called
  38. /// before calling 'bar'. See also 'FakeUnaryResponse'.
  39. ///
  40. /// - Parameter requestHandler: a handler for request parts sent by the RPC.
  41. internal func makeBarResponseStream(
  42. _ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
  43. ) -> FakeUnaryResponse<Codegentest_BarRequest, Codegentest_BarResponse> {
  44. return self.fakeChannel.makeFakeUnaryResponse(path: "/codegentest.Foo/Bar", requestHandler: requestHandler)
  45. }
  46. internal func enqueueBarResponse(
  47. _ response: Codegentest_BarResponse,
  48. _ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
  49. ) {
  50. let stream = self.makeBarResponseStream(requestHandler)
  51. // This is the only operation on the stream; try! is fine.
  52. try! stream.sendMessage(response)
  53. }
  54. /// Returns true if there are response streams enqueued for 'Bar'
  55. internal var hasBarResponsesRemaining: Bool {
  56. return self.fakeChannel.hasFakeResponseEnqueued(forPath: "/codegentest.Foo/Bar")
  57. }
  58. }