test.grpc.swift 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404
  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_TestServiceClient, then call methods of this protocol to make API calls.
  28. public protocol Grpc_Testing_TestServiceClientProtocol {
  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_TestServiceClient: GRPCClient, Grpc_Testing_TestServiceClientProtocol {
  39. public let channel: GRPCChannel
  40. public var defaultCallOptions: CallOptions
  41. /// Creates a client for the grpc.testing.TestService service.
  42. ///
  43. /// - Parameters:
  44. /// - channel: `GRPCChannel` to the service host.
  45. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  46. public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) {
  47. self.channel = channel
  48. self.defaultCallOptions = defaultCallOptions
  49. }
  50. /// One empty request followed by one empty response.
  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. /// One request followed by one response.
  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. /// One request followed by one response. Response has cache control
  73. /// headers set such that a caching HTTP proxy (such as GFE) can
  74. /// satisfy subsequent requests.
  75. ///
  76. /// - Parameters:
  77. /// - request: Request to send to CacheableUnaryCall.
  78. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  79. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  80. public func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
  81. return self.makeUnaryCall(path: "/grpc.testing.TestService/CacheableUnaryCall",
  82. request: request,
  83. callOptions: callOptions ?? self.defaultCallOptions)
  84. }
  85. /// One request followed by a sequence of responses (streamed download).
  86. /// The server returns the payload with client desired type and sizes.
  87. ///
  88. /// - Parameters:
  89. /// - request: Request to send to StreamingOutputCall.
  90. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  91. /// - handler: A closure called when each response is received from the server.
  92. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
  93. public func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  94. return self.makeServerStreamingCall(path: "/grpc.testing.TestService/StreamingOutputCall",
  95. request: request,
  96. callOptions: callOptions ?? self.defaultCallOptions,
  97. handler: handler)
  98. }
  99. /// A sequence of requests followed by one response (streamed upload).
  100. /// The server returns the aggregated size of client payload as the result.
  101. ///
  102. /// Callers should use the `send` method on the returned object to send messages
  103. /// to the server. The caller should send an `.end` after the final message has been sent.
  104. ///
  105. /// - Parameters:
  106. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  107. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
  108. public func streamingInputCall(callOptions: CallOptions? = nil) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse> {
  109. return self.makeClientStreamingCall(path: "/grpc.testing.TestService/StreamingInputCall",
  110. callOptions: callOptions ?? self.defaultCallOptions)
  111. }
  112. /// A sequence of requests with each request served by the server immediately.
  113. /// As one request could lead to multiple responses, this interface
  114. /// demonstrates the idea of full duplexing.
  115. ///
  116. /// Callers should use the `send` method on the returned object to send messages
  117. /// to the server. The caller should send an `.end` after the final message has been sent.
  118. ///
  119. /// - Parameters:
  120. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  121. /// - handler: A closure called when each response is received from the server.
  122. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  123. public func fullDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  124. return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/FullDuplexCall",
  125. callOptions: callOptions ?? self.defaultCallOptions,
  126. handler: handler)
  127. }
  128. /// A sequence of requests followed by a sequence of responses.
  129. /// The server buffers all the client requests and then serves them in order. A
  130. /// stream of responses are returned to the client when the server starts with
  131. /// first request.
  132. ///
  133. /// Callers should use the `send` method on the returned object to send messages
  134. /// to the server. The caller should send an `.end` after the final message has been sent.
  135. ///
  136. /// - Parameters:
  137. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  138. /// - handler: A closure called when each response is received from the server.
  139. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  140. public func halfDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  141. return self.makeBidirectionalStreamingCall(path: "/grpc.testing.TestService/HalfDuplexCall",
  142. callOptions: callOptions ?? self.defaultCallOptions,
  143. handler: handler)
  144. }
  145. /// The test server will not implement this method. It will be used
  146. /// to test the behavior when clients call unimplemented methods.
  147. ///
  148. /// - Parameters:
  149. /// - request: Request to send to UnimplementedCall.
  150. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  151. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  152. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  153. return self.makeUnaryCall(path: "/grpc.testing.TestService/UnimplementedCall",
  154. request: request,
  155. callOptions: callOptions ?? self.defaultCallOptions)
  156. }
  157. }
  158. /// Usage: instantiate Grpc_Testing_UnimplementedServiceClient, then call methods of this protocol to make API calls.
  159. public protocol Grpc_Testing_UnimplementedServiceClientProtocol {
  160. func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  161. }
  162. public final class Grpc_Testing_UnimplementedServiceClient: GRPCClient, Grpc_Testing_UnimplementedServiceClientProtocol {
  163. public let channel: GRPCChannel
  164. public var defaultCallOptions: CallOptions
  165. /// Creates a client for the grpc.testing.UnimplementedService service.
  166. ///
  167. /// - Parameters:
  168. /// - channel: `GRPCChannel` to the service host.
  169. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  170. public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) {
  171. self.channel = channel
  172. self.defaultCallOptions = defaultCallOptions
  173. }
  174. /// A call that no server should implement
  175. ///
  176. /// - Parameters:
  177. /// - request: Request to send to UnimplementedCall.
  178. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  179. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  180. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  181. return self.makeUnaryCall(path: "/grpc.testing.UnimplementedService/UnimplementedCall",
  182. request: request,
  183. callOptions: callOptions ?? self.defaultCallOptions)
  184. }
  185. }
  186. /// Usage: instantiate Grpc_Testing_ReconnectServiceClient, then call methods of this protocol to make API calls.
  187. public protocol Grpc_Testing_ReconnectServiceClientProtocol {
  188. func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty>
  189. func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo>
  190. }
  191. public final class Grpc_Testing_ReconnectServiceClient: GRPCClient, Grpc_Testing_ReconnectServiceClientProtocol {
  192. public let channel: GRPCChannel
  193. public var defaultCallOptions: CallOptions
  194. /// Creates a client for the grpc.testing.ReconnectService service.
  195. ///
  196. /// - Parameters:
  197. /// - channel: `GRPCChannel` to the service host.
  198. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  199. public init(channel: GRPCChannel, defaultCallOptions: CallOptions = CallOptions()) {
  200. self.channel = channel
  201. self.defaultCallOptions = defaultCallOptions
  202. }
  203. /// Unary call to Start
  204. ///
  205. /// - Parameters:
  206. /// - request: Request to send to Start.
  207. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  208. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  209. public func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty> {
  210. return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Start",
  211. request: request,
  212. callOptions: callOptions ?? self.defaultCallOptions)
  213. }
  214. /// Unary call to Stop
  215. ///
  216. /// - Parameters:
  217. /// - request: Request to send to Stop.
  218. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  219. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  220. public func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo> {
  221. return self.makeUnaryCall(path: "/grpc.testing.ReconnectService/Stop",
  222. request: request,
  223. callOptions: callOptions ?? self.defaultCallOptions)
  224. }
  225. }
  226. /// To build a server, implement a class that conforms to this protocol.
  227. public protocol Grpc_Testing_TestServiceProvider: CallHandlerProvider {
  228. /// One empty request followed by one empty response.
  229. func emptyCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  230. /// One request followed by one response.
  231. func unaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  232. /// One request followed by one response. Response has cache control
  233. /// headers set such that a caching HTTP proxy (such as GFE) can
  234. /// satisfy subsequent requests.
  235. func cacheableUnaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  236. /// One request followed by a sequence of responses (streamed download).
  237. /// The server returns the payload with client desired type and sizes.
  238. func streamingOutputCall(request: Grpc_Testing_StreamingOutputCallRequest, context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<GRPCStatus>
  239. /// A sequence of requests followed by one response (streamed upload).
  240. /// The server returns the aggregated size of client payload as the result.
  241. func streamingInputCall(context: UnaryResponseCallContext<Grpc_Testing_StreamingInputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingInputCallRequest>) -> Void>
  242. /// A sequence of requests with each request served by the server immediately.
  243. /// As one request could lead to multiple responses, this interface
  244. /// demonstrates the idea of full duplexing.
  245. func fullDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  246. /// A sequence of requests followed by a sequence of responses.
  247. /// The server buffers all the client requests and then serves them in order. A
  248. /// stream of responses are returned to the client when the server starts with
  249. /// first request.
  250. func halfDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  251. }
  252. extension Grpc_Testing_TestServiceProvider {
  253. public var serviceName: String { return "grpc.testing.TestService" }
  254. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  255. /// Returns nil for methods not handled by this service.
  256. public func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  257. switch methodName {
  258. case "EmptyCall":
  259. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  260. return { request in
  261. self.emptyCall(request: request, context: context)
  262. }
  263. }
  264. case "UnaryCall":
  265. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  266. return { request in
  267. self.unaryCall(request: request, context: context)
  268. }
  269. }
  270. case "CacheableUnaryCall":
  271. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  272. return { request in
  273. self.cacheableUnaryCall(request: request, context: context)
  274. }
  275. }
  276. case "StreamingOutputCall":
  277. return ServerStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  278. return { request in
  279. self.streamingOutputCall(request: request, context: context)
  280. }
  281. }
  282. case "StreamingInputCall":
  283. return ClientStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  284. return self.streamingInputCall(context: context)
  285. }
  286. case "FullDuplexCall":
  287. return BidirectionalStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  288. return self.fullDuplexCall(context: context)
  289. }
  290. case "HalfDuplexCall":
  291. return BidirectionalStreamingCallHandler(callHandlerContext: callHandlerContext) { context in
  292. return self.halfDuplexCall(context: context)
  293. }
  294. default: return nil
  295. }
  296. }
  297. }
  298. /// To build a server, implement a class that conforms to this protocol.
  299. public protocol Grpc_Testing_UnimplementedServiceProvider: CallHandlerProvider {
  300. /// A call that no server should implement
  301. func unimplementedCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  302. }
  303. extension Grpc_Testing_UnimplementedServiceProvider {
  304. public var serviceName: String { return "grpc.testing.UnimplementedService" }
  305. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  306. /// Returns nil for methods not handled by this service.
  307. public func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  308. switch methodName {
  309. case "UnimplementedCall":
  310. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  311. return { request in
  312. self.unimplementedCall(request: request, context: context)
  313. }
  314. }
  315. default: return nil
  316. }
  317. }
  318. }
  319. /// To build a server, implement a class that conforms to this protocol.
  320. public protocol Grpc_Testing_ReconnectServiceProvider: CallHandlerProvider {
  321. func start(request: Grpc_Testing_ReconnectParams, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  322. func stop(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_ReconnectInfo>
  323. }
  324. extension Grpc_Testing_ReconnectServiceProvider {
  325. public var serviceName: String { return "grpc.testing.ReconnectService" }
  326. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  327. /// Returns nil for methods not handled by this service.
  328. public func handleMethod(_ methodName: String, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  329. switch methodName {
  330. case "Start":
  331. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  332. return { request in
  333. self.start(request: request, context: context)
  334. }
  335. }
  336. case "Stop":
  337. return UnaryCallHandler(callHandlerContext: callHandlerContext) { context in
  338. return { request in
  339. self.stop(request: request, context: context)
  340. }
  341. }
  342. default: return nil
  343. }
  344. }
  345. }
  346. // Provides conformance to `GRPCPayload` for request and response messages
  347. extension Grpc_Testing_Empty: GRPCProtobufPayload {}
  348. extension Grpc_Testing_SimpleRequest: GRPCProtobufPayload {}
  349. extension Grpc_Testing_SimpleResponse: GRPCProtobufPayload {}
  350. extension Grpc_Testing_StreamingOutputCallRequest: GRPCProtobufPayload {}
  351. extension Grpc_Testing_StreamingOutputCallResponse: GRPCProtobufPayload {}
  352. extension Grpc_Testing_StreamingInputCallRequest: GRPCProtobufPayload {}
  353. extension Grpc_Testing_StreamingInputCallResponse: GRPCProtobufPayload {}
  354. extension Grpc_Testing_ReconnectParams: GRPCProtobufPayload {}
  355. extension Grpc_Testing_ReconnectInfo: GRPCProtobufPayload {}