test.grpc.swift 20 KB

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