test.grpc.swift 2.2 KB

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