test.grpc.swift 2.4 KB

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