test.grpc.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. import SwiftProtobuf
  25. internal final class Codegentest_FooTestClient: Codegentest_FooClientProtocol {
  26. private let fakeChannel: FakeChannel
  27. internal var defaultCallOptions: CallOptions
  28. internal var interceptors: Codegentest_FooClientInterceptorFactoryProtocol?
  29. internal var channel: GRPCChannel {
  30. return self.fakeChannel
  31. }
  32. internal init(
  33. fakeChannel: FakeChannel = FakeChannel(),
  34. defaultCallOptions callOptions: CallOptions = CallOptions(),
  35. interceptors: Codegentest_FooClientInterceptorFactoryProtocol? = nil
  36. ) {
  37. self.fakeChannel = fakeChannel
  38. self.defaultCallOptions = callOptions
  39. self.interceptors = interceptors
  40. }
  41. /// Make a unary response for the Bar RPC. This must be called
  42. /// before calling 'bar'. See also 'FakeUnaryResponse'.
  43. ///
  44. /// - Parameter requestHandler: a handler for request parts sent by the RPC.
  45. internal func makeBarResponseStream(
  46. _ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
  47. ) -> FakeUnaryResponse<Codegentest_BarRequest, Codegentest_BarResponse> {
  48. return self.fakeChannel.makeFakeUnaryResponse(path: "/codegentest.Foo/Bar", requestHandler: requestHandler)
  49. }
  50. internal func enqueueBarResponse(
  51. _ response: Codegentest_BarResponse,
  52. _ requestHandler: @escaping (FakeRequestPart<Codegentest_BarRequest>) -> () = { _ in }
  53. ) {
  54. let stream = self.makeBarResponseStream(requestHandler)
  55. // This is the only operation on the stream; try! is fine.
  56. try! stream.sendMessage(response)
  57. }
  58. /// Returns true if there are response streams enqueued for 'Bar'
  59. internal var hasBarResponsesRemaining: Bool {
  60. return self.fakeChannel.hasFakeResponseEnqueued(forPath: "/codegentest.Foo/Bar")
  61. }
  62. }