b.grpc.swift 3.1 KB

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