test.grpc.swift 2.3 KB

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