test.grpc.swift 20 KB

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