a.grpc.swift 3.3 KB

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