test.grpc.swift 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. //
  2. // DO NOT EDIT.
  3. //
  4. // Generated by the protocol buffer compiler.
  5. // Source: src/proto/grpc/testing/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. /// Usage: instantiate Grpc_Testing_TestServiceServiceClient, then call methods of this protocol to make API calls.
  28. public protocol Grpc_Testing_TestServiceService {
  29. func emptyCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  30. func unaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>
  31. func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>
  32. func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  33. func streamingInputCall(callOptions: CallOptions?) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse>
  34. func fullDuplexCall(callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  35. func halfDuplexCall(callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  36. func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  37. }
  38. public final class Grpc_Testing_TestServiceServiceClient: GRPCClient, Grpc_Testing_TestServiceService {
  39. public let connection: ClientConnection
  40. public var defaultCallOptions: CallOptions
  41. /// Creates a client for the grpc.testing.TestService service.
  42. ///
  43. /// - Parameters:
  44. /// - connection: `ClientConnection` to the service host.
  45. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  46. public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  47. self.connection = connection
  48. self.defaultCallOptions = defaultCallOptions
  49. }
  50. /// Asynchronous unary call to EmptyCall.
  51. ///
  52. /// - Parameters:
  53. /// - request: Request to send to EmptyCall.
  54. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  55. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  56. public func emptyCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  57. return self.makeUnaryCall(path: "/grpc.testing.TestService/EmptyCall",
  58. request: request,
  59. callOptions: callOptions ?? self.defaultCallOptions)
  60. }
  61. /// Asynchronous unary call to UnaryCall.
  62. ///
  63. /// - Parameters:
  64. /// - request: Request to send to UnaryCall.
  65. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  66. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  67. public func unaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
  68. return self.makeUnaryCall(path: "/grpc.testing.TestService/UnaryCall",
  69. request: request,
  70. callOptions: callOptions ?? self.defaultCallOptions)
  71. }
  72. /// Asynchronous unary call to CacheableUnaryCall.
  73. ///
  74. /// - Parameters:
  75. /// - request: Request to send to CacheableUnaryCall.
  76. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  77. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  78. public func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
  79. return self.makeUnaryCall(path: "/grpc.testing.TestService/CacheableUnaryCall",
  80. request: request,
  81. callOptions: callOptions ?? self.defaultCallOptions)
  82. }
  83. /// Asynchronous server-streaming call to StreamingOutputCall.
  84. ///
  85. /// - Parameters:
  86. /// - request: Request to send to StreamingOutputCall.
  87. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  88. /// - handler: A closure called when each response is received from the server.
  89. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
  90. public func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  91. return self.makeServerStreamingCall(path: "/grpc.testing.TestService/StreamingOutputCall",
  92. request: request,
  93. callOptions: callOptions ?? self.defaultCallOptions,
  94. handler: handler)
  95. }
  96. /// Asynchronous client-streaming call to StreamingInputCall.
  97. ///
  98. /// Callers should use the `send` method on the returned object to send messages
  99. /// to the server. The caller should send an `.end` after the final message has been sent.
  100. ///
  101. /// - Parameters:
  102. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  103. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
  104. public func streamingInputCall(callOptions: CallOptions? = nil) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse> {
  105. return self.makeClientStreamingCall(path: "/grpc.testing.TestService/StreamingInputCall",
  106. callOptions: callOptions ?? self.defaultCallOptions)
  107. }
  108. /// Asynchronous bidirectional-streaming call to FullDuplexCall.
  109. ///
  110. /// Callers should use the `send` method on the returned object to send messages
  111. /// to the server. The caller should send an `.end` after the final message has been sent.
  112. ///
  113. /// - Parameters:
  114. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  115. /// - handler: A closure called when each response is received from the server.
  116. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  117. public func fullDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  118. return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/FullDuplexCall",
  119. callOptions: callOptions ?? self.defaultCallOptions,
  120. handler: handler)
  121. }
  122. /// Asynchronous bidirectional-streaming call to HalfDuplexCall.
  123. ///
  124. /// Callers should use the `send` method on the returned object to send messages
  125. /// to the server. The caller should send an `.end` after the final message has been sent.
  126. ///
  127. /// - Parameters:
  128. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  129. /// - handler: A closure called when each response is received from the server.
  130. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  131. public func halfDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  132. return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/HalfDuplexCall",
  133. callOptions: callOptions ?? self.defaultCallOptions,
  134. handler: handler)
  135. }
  136. /// Asynchronous unary call to UnimplementedCall.
  137. ///
  138. /// - Parameters:
  139. /// - request: Request to send to UnimplementedCall.
  140. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  141. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  142. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  143. return self.makeUnaryCall(path: "/grpc.testing.TestService/UnimplementedCall",
  144. request: request,
  145. callOptions: callOptions ?? self.defaultCallOptions)
  146. }
  147. }
  148. /// Usage: instantiate Grpc_Testing_UnimplementedServiceServiceClient, then call methods of this protocol to make API calls.
  149. public protocol Grpc_Testing_UnimplementedServiceService {
  150. func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  151. }
  152. public final class Grpc_Testing_UnimplementedServiceServiceClient: GRPCClient, Grpc_Testing_UnimplementedServiceService {
  153. public let connection: ClientConnection
  154. public var defaultCallOptions: CallOptions
  155. /// Creates a client for the grpc.testing.UnimplementedService service.
  156. ///
  157. /// - Parameters:
  158. /// - connection: `ClientConnection` to the service host.
  159. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  160. public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  161. self.connection = connection
  162. self.defaultCallOptions = defaultCallOptions
  163. }
  164. /// Asynchronous unary call to UnimplementedCall.
  165. ///
  166. /// - Parameters:
  167. /// - request: Request to send to UnimplementedCall.
  168. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  169. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  170. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  171. return self.makeUnaryCall(path: "/grpc.testing.UnimplementedService/UnimplementedCall",
  172. request: request,
  173. callOptions: callOptions ?? self.defaultCallOptions)
  174. }
  175. }
  176. /// Usage: instantiate Grpc_Testing_ReconnectServiceServiceClient, then call methods of this protocol to make API calls.
  177. public protocol Grpc_Testing_ReconnectServiceService {
  178. func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty>
  179. func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo>
  180. }
  181. public final class Grpc_Testing_ReconnectServiceServiceClient: GRPCClient, Grpc_Testing_ReconnectServiceService {
  182. public let connection: ClientConnection
  183. public var defaultCallOptions: CallOptions
  184. /// Creates a client for the grpc.testing.ReconnectService service.
  185. ///
  186. /// - Parameters:
  187. /// - connection: `ClientConnection` to the service host.
  188. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  189. public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  190. self.connection = connection
  191. self.defaultCallOptions = defaultCallOptions
  192. }
  193. /// Asynchronous unary call to Start.
  194. ///
  195. /// - Parameters:
  196. /// - request: Request to send to Start.
  197. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  198. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  199. public func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty> {
  200. return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Start",
  201. request: request,
  202. callOptions: callOptions ?? self.defaultCallOptions)
  203. }
  204. /// Asynchronous unary call to Stop.
  205. ///
  206. /// - Parameters:
  207. /// - request: Request to send to Stop.
  208. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  209. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  210. public func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo> {
  211. return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Stop",
  212. request: request,
  213. callOptions: callOptions ?? self.defaultCallOptions)
  214. }
  215. }
  216. /// To build a server, implement a class that conforms to this protocol.
  217. public protocol Grpc_Testing_TestServiceProvider: CallHandlerProvider {
  218. func emptyCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  219. func unaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  220. func cacheableUnaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  221. func streamingOutputCall(request: Grpc_Testing_StreamingOutputCallRequest, context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<GRPCStatus>
  222. func streamingInputCall(context: UnaryResponseCallContext<Grpc_Testing_StreamingInputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingInputCallRequest>) -> Void>
  223. func fullDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  224. func halfDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  225. }
  226. extension Grpc_Testing_TestServiceProvider {
  227. public var serviceName: String { return "grpc.testing.TestService" }
  228. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  229. /// Returns nil for methods not handled by this service.
  230. public func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  231. switch methodName {
  232. case "EmptyCall":
  233. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  234. return { request in
  235. self.emptyCall(request: request, context: context)
  236. }
  237. }
  238. case "UnaryCall":
  239. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  240. return { request in
  241. self.unaryCall(request: request, context: context)
  242. }
  243. }
  244. case "CacheableUnaryCall":
  245. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  246. return { request in
  247. self.cacheableUnaryCall(request: request, context: context)
  248. }
  249. }
  250. case "StreamingOutputCall":
  251. return ServerStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  252. return { request in
  253. self.streamingOutputCall(request: request, context: context)
  254. }
  255. }
  256. case "StreamingInputCall":
  257. return ClientStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  258. return self.streamingInputCall(context: context)
  259. }
  260. case "FullDuplexCall":
  261. return BidirectionalStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  262. return self.fullDuplexCall(context: context)
  263. }
  264. case "HalfDuplexCall":
  265. return BidirectionalStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  266. return self.halfDuplexCall(context: context)
  267. }
  268. default: return nil
  269. }
  270. }
  271. }
  272. /// To build a server, implement a class that conforms to this protocol.
  273. public protocol Grpc_Testing_UnimplementedServiceProvider: CallHandlerProvider {
  274. func unimplementedCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  275. }
  276. extension Grpc_Testing_UnimplementedServiceProvider {
  277. public var serviceName: String { return "grpc.testing.UnimplementedService" }
  278. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  279. /// Returns nil for methods not handled by this service.
  280. public func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  281. switch methodName {
  282. case "UnimplementedCall":
  283. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  284. return { request in
  285. self.unimplementedCall(request: request, context: context)
  286. }
  287. }
  288. default: return nil
  289. }
  290. }
  291. }
  292. /// To build a server, implement a class that conforms to this protocol.
  293. public protocol Grpc_Testing_ReconnectServiceProvider: CallHandlerProvider {
  294. func start(request: Grpc_Testing_ReconnectParams, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  295. func stop(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_ReconnectInfo>
  296. }
  297. extension Grpc_Testing_ReconnectServiceProvider {
  298. public var serviceName: String { return "grpc.testing.ReconnectService" }
  299. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  300. /// Returns nil for methods not handled by this service.
  301. public func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  302. switch methodName {
  303. case "Start":
  304. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  305. return { request in
  306. self.start(request: request, context: context)
  307. }
  308. }
  309. case "Stop":
  310. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  311. return { request in
  312. self.stop(request: request, context: context)
  313. }
  314. }
  315. default: return nil
  316. }
  317. }
  318. }