b.grpc.swift 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // DO NOT EDIT.
  3. //
  4. // Generated by the protocol buffer compiler.
  5. // Source: b.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. /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls.
  25. internal protocol B_ServiceBClientProtocol: GRPCClient {
  26. func callServiceB(
  27. _ request: B_MessageB,
  28. callOptions: CallOptions?
  29. ) -> UnaryCall<B_MessageB, SwiftProtobuf.Google_Protobuf_Empty>
  30. }
  31. extension B_ServiceBClientProtocol {
  32. /// Unary call to CallServiceB
  33. ///
  34. /// - Parameters:
  35. /// - request: Request to send to CallServiceB.
  36. /// - callOptions: Call options.
  37. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  38. internal func callServiceB(
  39. _ request: B_MessageB,
  40. callOptions: CallOptions? = nil
  41. ) -> UnaryCall<B_MessageB, SwiftProtobuf.Google_Protobuf_Empty> {
  42. return self.makeUnaryCall(
  43. path: "/b.ServiceB/CallServiceB",
  44. request: request,
  45. callOptions: callOptions ?? self.defaultCallOptions
  46. )
  47. }
  48. }
  49. internal final class B_ServiceBClient: B_ServiceBClientProtocol {
  50. internal let channel: GRPCChannel
  51. internal var defaultCallOptions: CallOptions
  52. /// Creates a client for the b.ServiceB service.
  53. ///
  54. /// - Parameters:
  55. /// - channel: `GRPCChannel` to the service host.
  56. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  57. internal init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) {
  58. self.channel = channel
  59. self.defaultCallOptions = defaultCallOptions
  60. }
  61. }
  62. /// To build a server, implement a class that conforms to this protocol.
  63. internal protocol B_ServiceBProvider: CallHandlerProvider {
  64. func callServiceB(request: B_MessageB, context: StatusOnlyCallContext) -> EventLoopFuture<SwiftProtobuf.Google_Protobuf_Empty>
  65. }
  66. extension B_ServiceBProvider {
  67. internal var serviceName: Substring { return "b.ServiceB" }
  68. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  69. /// Returns nil for methods not handled by this service.
  70. internal func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  71. switch methodName {
  72. case "CallServiceB":
  73. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  74. return { request in
  75. self.callServiceB(request: request, context: context)
  76. }
  77. }
  78. default: return nil
  79. }
  80. }
  81. }