test.grpc.swift 20 KB

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