test.grpc.swift 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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. import SwiftProtobuf
  25. /// Usage: instantiate Grpc_Testing_TestServiceClient, then call methods of this protocol to make API calls.
  26. public protocol Grpc_Testing_TestServiceClientProtocol: GRPCClient {
  27. var interceptors: Grpc_Testing_TestServiceClientInterceptorFactoryProtocol? { get }
  28. func emptyCall(
  29. _ request: Grpc_Testing_Empty,
  30. callOptions: CallOptions?
  31. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  32. func unaryCall(
  33. _ request: Grpc_Testing_SimpleRequest,
  34. callOptions: CallOptions?
  35. ) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>
  36. func cacheableUnaryCall(
  37. _ request: Grpc_Testing_SimpleRequest,
  38. callOptions: CallOptions?
  39. ) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>
  40. func streamingOutputCall(
  41. _ request: Grpc_Testing_StreamingOutputCallRequest,
  42. callOptions: CallOptions?,
  43. handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
  44. ) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  45. func streamingInputCall(
  46. callOptions: CallOptions?
  47. ) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse>
  48. func fullDuplexCall(
  49. callOptions: CallOptions?,
  50. handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
  51. ) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  52. func halfDuplexCall(
  53. callOptions: CallOptions?,
  54. handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
  55. ) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  56. func unimplementedCall(
  57. _ request: Grpc_Testing_Empty,
  58. callOptions: CallOptions?
  59. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  60. }
  61. extension Grpc_Testing_TestServiceClientProtocol {
  62. /// One empty request followed by one empty response.
  63. ///
  64. /// - Parameters:
  65. /// - request: Request to send to EmptyCall.
  66. /// - callOptions: Call options.
  67. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  68. public func emptyCall(
  69. _ request: Grpc_Testing_Empty,
  70. callOptions: CallOptions? = nil
  71. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  72. return self.makeUnaryCall(
  73. path: "/grpc.testing.TestService/EmptyCall",
  74. request: request,
  75. callOptions: callOptions ?? self.defaultCallOptions,
  76. interceptors: self.interceptors?.makeEmptyCallInterceptors() ?? []
  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. interceptors: self.interceptors?.makeUnaryCallInterceptors() ?? []
  94. )
  95. }
  96. /// One request followed by one response. Response has cache control
  97. /// headers set such that a caching HTTP proxy (such as GFE) can
  98. /// satisfy subsequent requests.
  99. ///
  100. /// - Parameters:
  101. /// - request: Request to send to CacheableUnaryCall.
  102. /// - callOptions: Call options.
  103. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  104. public func cacheableUnaryCall(
  105. _ request: Grpc_Testing_SimpleRequest,
  106. callOptions: CallOptions? = nil
  107. ) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
  108. return self.makeUnaryCall(
  109. path: "/grpc.testing.TestService/CacheableUnaryCall",
  110. request: request,
  111. callOptions: callOptions ?? self.defaultCallOptions,
  112. interceptors: self.interceptors?.makeCacheableUnaryCallInterceptors() ?? []
  113. )
  114. }
  115. /// One request followed by a sequence of responses (streamed download).
  116. /// The server returns the payload with client desired type and sizes.
  117. ///
  118. /// - Parameters:
  119. /// - request: Request to send to StreamingOutputCall.
  120. /// - callOptions: Call options.
  121. /// - handler: A closure called when each response is received from the server.
  122. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
  123. public func streamingOutputCall(
  124. _ request: Grpc_Testing_StreamingOutputCallRequest,
  125. callOptions: CallOptions? = nil,
  126. handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
  127. ) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  128. return self.makeServerStreamingCall(
  129. path: "/grpc.testing.TestService/StreamingOutputCall",
  130. request: request,
  131. callOptions: callOptions ?? self.defaultCallOptions,
  132. interceptors: self.interceptors?.makeStreamingOutputCallInterceptors() ?? [],
  133. handler: handler
  134. )
  135. }
  136. /// A sequence of requests followed by one response (streamed upload).
  137. /// The server returns the aggregated size of client payload as the result.
  138. ///
  139. /// Callers should use the `send` method on the returned object to send messages
  140. /// to the server. The caller should send an `.end` after the final message has been sent.
  141. ///
  142. /// - Parameters:
  143. /// - callOptions: Call options.
  144. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
  145. public func streamingInputCall(
  146. callOptions: CallOptions? = nil
  147. ) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse> {
  148. return self.makeClientStreamingCall(
  149. path: "/grpc.testing.TestService/StreamingInputCall",
  150. callOptions: callOptions ?? self.defaultCallOptions,
  151. interceptors: self.interceptors?.makeStreamingInputCallInterceptors() ?? []
  152. )
  153. }
  154. /// A sequence of requests with each request served by the server immediately.
  155. /// As one request could lead to multiple responses, this interface
  156. /// demonstrates the idea of full duplexing.
  157. ///
  158. /// Callers should use the `send` method on the returned object to send messages
  159. /// to the server. The caller should send an `.end` after the final message has been sent.
  160. ///
  161. /// - Parameters:
  162. /// - callOptions: Call options.
  163. /// - handler: A closure called when each response is received from the server.
  164. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  165. public func fullDuplexCall(
  166. callOptions: CallOptions? = nil,
  167. handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
  168. ) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  169. return self.makeBidirectionalStreamingCall(
  170. path: "/grpc.testing.TestService/FullDuplexCall",
  171. callOptions: callOptions ?? self.defaultCallOptions,
  172. interceptors: self.interceptors?.makeFullDuplexCallInterceptors() ?? [],
  173. handler: handler
  174. )
  175. }
  176. /// A sequence of requests followed by a sequence of responses.
  177. /// The server buffers all the client requests and then serves them in order. A
  178. /// stream of responses are returned to the client when the server starts with
  179. /// first request.
  180. ///
  181. /// Callers should use the `send` method on the returned object to send messages
  182. /// to the server. The caller should send an `.end` after the final message has been sent.
  183. ///
  184. /// - Parameters:
  185. /// - callOptions: Call options.
  186. /// - handler: A closure called when each response is received from the server.
  187. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  188. public func halfDuplexCall(
  189. callOptions: CallOptions? = nil,
  190. handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void
  191. ) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  192. return self.makeBidirectionalStreamingCall(
  193. path: "/grpc.testing.TestService/HalfDuplexCall",
  194. callOptions: callOptions ?? self.defaultCallOptions,
  195. interceptors: self.interceptors?.makeHalfDuplexCallInterceptors() ?? [],
  196. handler: handler
  197. )
  198. }
  199. /// The test server will not implement this method. It will be used
  200. /// to test the behavior when clients call unimplemented methods.
  201. ///
  202. /// - Parameters:
  203. /// - request: Request to send to UnimplementedCall.
  204. /// - callOptions: Call options.
  205. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  206. public func unimplementedCall(
  207. _ request: Grpc_Testing_Empty,
  208. callOptions: CallOptions? = nil
  209. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  210. return self.makeUnaryCall(
  211. path: "/grpc.testing.TestService/UnimplementedCall",
  212. request: request,
  213. callOptions: callOptions ?? self.defaultCallOptions,
  214. interceptors: self.interceptors?.makeUnimplementedCallInterceptors() ?? []
  215. )
  216. }
  217. }
  218. public protocol Grpc_Testing_TestServiceClientInterceptorFactoryProtocol {
  219. /// Makes an array of generic interceptors. The per-method interceptor
  220. /// factories default to calling this function and it therefore provides a
  221. /// convenient way of setting interceptors for all methods on a client.
  222. /// - Returns: An array of interceptors generic over `Request` and `Response`.
  223. /// Defaults to an empty array.
  224. func makeInterceptors<Request: SwiftProtobuf.Message, Response: SwiftProtobuf.Message>() -> [ClientInterceptor<Request, Response>]
  225. /// - Returns: Interceptors to use when invoking 'emptyCall'.
  226. /// Defaults to calling `self.makeInterceptors()`.
  227. func makeEmptyCallInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_Empty>]
  228. /// - Returns: Interceptors to use when invoking 'unaryCall'.
  229. /// Defaults to calling `self.makeInterceptors()`.
  230. func makeUnaryCallInterceptors() -> [ClientInterceptor<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>]
  231. /// - Returns: Interceptors to use when invoking 'cacheableUnaryCall'.
  232. /// Defaults to calling `self.makeInterceptors()`.
  233. func makeCacheableUnaryCallInterceptors() -> [ClientInterceptor<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>]
  234. /// - Returns: Interceptors to use when invoking 'streamingOutputCall'.
  235. /// Defaults to calling `self.makeInterceptors()`.
  236. func makeStreamingOutputCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>]
  237. /// - Returns: Interceptors to use when invoking 'streamingInputCall'.
  238. /// Defaults to calling `self.makeInterceptors()`.
  239. func makeStreamingInputCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse>]
  240. /// - Returns: Interceptors to use when invoking 'fullDuplexCall'.
  241. /// Defaults to calling `self.makeInterceptors()`.
  242. func makeFullDuplexCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>]
  243. /// - Returns: Interceptors to use when invoking 'halfDuplexCall'.
  244. /// Defaults to calling `self.makeInterceptors()`.
  245. func makeHalfDuplexCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>]
  246. /// - Returns: Interceptors to use when invoking 'unimplementedCall'.
  247. /// Defaults to calling `self.makeInterceptors()`.
  248. func makeUnimplementedCallInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_Empty>]
  249. }
  250. extension Grpc_Testing_TestServiceClientInterceptorFactoryProtocol {
  251. public func makeInterceptors<Request: SwiftProtobuf.Message, Response: SwiftProtobuf.Message>() -> [ClientInterceptor<Request, Response>] {
  252. return []
  253. }
  254. public func makeEmptyCallInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_Empty>] {
  255. return self.makeInterceptors()
  256. }
  257. public func makeUnaryCallInterceptors() -> [ClientInterceptor<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>] {
  258. return self.makeInterceptors()
  259. }
  260. public func makeCacheableUnaryCallInterceptors() -> [ClientInterceptor<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>] {
  261. return self.makeInterceptors()
  262. }
  263. public func makeStreamingOutputCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>] {
  264. return self.makeInterceptors()
  265. }
  266. public func makeStreamingInputCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse>] {
  267. return self.makeInterceptors()
  268. }
  269. public func makeFullDuplexCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>] {
  270. return self.makeInterceptors()
  271. }
  272. public func makeHalfDuplexCallInterceptors() -> [ClientInterceptor<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>] {
  273. return self.makeInterceptors()
  274. }
  275. public func makeUnimplementedCallInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_Empty>] {
  276. return self.makeInterceptors()
  277. }
  278. }
  279. public final class Grpc_Testing_TestServiceClient: Grpc_Testing_TestServiceClientProtocol {
  280. public let channel: GRPCChannel
  281. public var defaultCallOptions: CallOptions
  282. public var interceptors: Grpc_Testing_TestServiceClientInterceptorFactoryProtocol?
  283. /// Creates a client for the grpc.testing.TestService service.
  284. ///
  285. /// - Parameters:
  286. /// - channel: `GRPCChannel` to the service host.
  287. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  288. /// - interceptors: A factory providing interceptors for each RPC.
  289. public init(
  290. channel: GRPCChannel,
  291. defaultCallOptions: CallOptions = CallOptions(),
  292. interceptors: Grpc_Testing_TestServiceClientInterceptorFactoryProtocol? = nil
  293. ) {
  294. self.channel = channel
  295. self.defaultCallOptions = defaultCallOptions
  296. self.interceptors = interceptors
  297. }
  298. }
  299. /// Usage: instantiate Grpc_Testing_UnimplementedServiceClient, then call methods of this protocol to make API calls.
  300. public protocol Grpc_Testing_UnimplementedServiceClientProtocol: GRPCClient {
  301. var interceptors: Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol? { get }
  302. func unimplementedCall(
  303. _ request: Grpc_Testing_Empty,
  304. callOptions: CallOptions?
  305. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  306. }
  307. extension Grpc_Testing_UnimplementedServiceClientProtocol {
  308. /// A call that no server should implement
  309. ///
  310. /// - Parameters:
  311. /// - request: Request to send to UnimplementedCall.
  312. /// - callOptions: Call options.
  313. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  314. public func unimplementedCall(
  315. _ request: Grpc_Testing_Empty,
  316. callOptions: CallOptions? = nil
  317. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  318. return self.makeUnaryCall(
  319. path: "/grpc.testing.UnimplementedService/UnimplementedCall",
  320. request: request,
  321. callOptions: callOptions ?? self.defaultCallOptions,
  322. interceptors: self.interceptors?.makeUnimplementedCallInterceptors() ?? []
  323. )
  324. }
  325. }
  326. public protocol Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol {
  327. /// Makes an array of generic interceptors. The per-method interceptor
  328. /// factories default to calling this function and it therefore provides a
  329. /// convenient way of setting interceptors for all methods on a client.
  330. /// - Returns: An array of interceptors generic over `Request` and `Response`.
  331. /// Defaults to an empty array.
  332. func makeInterceptors<Request: SwiftProtobuf.Message, Response: SwiftProtobuf.Message>() -> [ClientInterceptor<Request, Response>]
  333. /// - Returns: Interceptors to use when invoking 'unimplementedCall'.
  334. /// Defaults to calling `self.makeInterceptors()`.
  335. func makeUnimplementedCallInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_Empty>]
  336. }
  337. extension Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol {
  338. public func makeInterceptors<Request: SwiftProtobuf.Message, Response: SwiftProtobuf.Message>() -> [ClientInterceptor<Request, Response>] {
  339. return []
  340. }
  341. public func makeUnimplementedCallInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_Empty>] {
  342. return self.makeInterceptors()
  343. }
  344. }
  345. public final class Grpc_Testing_UnimplementedServiceClient: Grpc_Testing_UnimplementedServiceClientProtocol {
  346. public let channel: GRPCChannel
  347. public var defaultCallOptions: CallOptions
  348. public var interceptors: Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol?
  349. /// Creates a client for the grpc.testing.UnimplementedService service.
  350. ///
  351. /// - Parameters:
  352. /// - channel: `GRPCChannel` to the service host.
  353. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  354. /// - interceptors: A factory providing interceptors for each RPC.
  355. public init(
  356. channel: GRPCChannel,
  357. defaultCallOptions: CallOptions = CallOptions(),
  358. interceptors: Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol? = nil
  359. ) {
  360. self.channel = channel
  361. self.defaultCallOptions = defaultCallOptions
  362. self.interceptors = interceptors
  363. }
  364. }
  365. /// Usage: instantiate Grpc_Testing_ReconnectServiceClient, then call methods of this protocol to make API calls.
  366. public protocol Grpc_Testing_ReconnectServiceClientProtocol: GRPCClient {
  367. var interceptors: Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol? { get }
  368. func start(
  369. _ request: Grpc_Testing_ReconnectParams,
  370. callOptions: CallOptions?
  371. ) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty>
  372. func stop(
  373. _ request: Grpc_Testing_Empty,
  374. callOptions: CallOptions?
  375. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo>
  376. }
  377. extension Grpc_Testing_ReconnectServiceClientProtocol {
  378. /// Unary call to Start
  379. ///
  380. /// - Parameters:
  381. /// - request: Request to send to Start.
  382. /// - callOptions: Call options.
  383. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  384. public func start(
  385. _ request: Grpc_Testing_ReconnectParams,
  386. callOptions: CallOptions? = nil
  387. ) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty> {
  388. return self.makeUnaryCall(
  389. path: "/grpc.testing.ReconnectService/Start",
  390. request: request,
  391. callOptions: callOptions ?? self.defaultCallOptions,
  392. interceptors: self.interceptors?.makeStartInterceptors() ?? []
  393. )
  394. }
  395. /// Unary call to Stop
  396. ///
  397. /// - Parameters:
  398. /// - request: Request to send to Stop.
  399. /// - callOptions: Call options.
  400. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  401. public func stop(
  402. _ request: Grpc_Testing_Empty,
  403. callOptions: CallOptions? = nil
  404. ) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo> {
  405. return self.makeUnaryCall(
  406. path: "/grpc.testing.ReconnectService/Stop",
  407. request: request,
  408. callOptions: callOptions ?? self.defaultCallOptions,
  409. interceptors: self.interceptors?.makeStopInterceptors() ?? []
  410. )
  411. }
  412. }
  413. public protocol Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol {
  414. /// Makes an array of generic interceptors. The per-method interceptor
  415. /// factories default to calling this function and it therefore provides a
  416. /// convenient way of setting interceptors for all methods on a client.
  417. /// - Returns: An array of interceptors generic over `Request` and `Response`.
  418. /// Defaults to an empty array.
  419. func makeInterceptors<Request: SwiftProtobuf.Message, Response: SwiftProtobuf.Message>() -> [ClientInterceptor<Request, Response>]
  420. /// - Returns: Interceptors to use when invoking 'start'.
  421. /// Defaults to calling `self.makeInterceptors()`.
  422. func makeStartInterceptors() -> [ClientInterceptor<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty>]
  423. /// - Returns: Interceptors to use when invoking 'stop'.
  424. /// Defaults to calling `self.makeInterceptors()`.
  425. func makeStopInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo>]
  426. }
  427. extension Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol {
  428. public func makeInterceptors<Request: SwiftProtobuf.Message, Response: SwiftProtobuf.Message>() -> [ClientInterceptor<Request, Response>] {
  429. return []
  430. }
  431. public func makeStartInterceptors() -> [ClientInterceptor<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty>] {
  432. return self.makeInterceptors()
  433. }
  434. public func makeStopInterceptors() -> [ClientInterceptor<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo>] {
  435. return self.makeInterceptors()
  436. }
  437. }
  438. public final class Grpc_Testing_ReconnectServiceClient: Grpc_Testing_ReconnectServiceClientProtocol {
  439. public let channel: GRPCChannel
  440. public var defaultCallOptions: CallOptions
  441. public var interceptors: Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol?
  442. /// Creates a client for the grpc.testing.ReconnectService service.
  443. ///
  444. /// - Parameters:
  445. /// - channel: `GRPCChannel` to the service host.
  446. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  447. /// - interceptors: A factory providing interceptors for each RPC.
  448. public init(
  449. channel: GRPCChannel,
  450. defaultCallOptions: CallOptions = CallOptions(),
  451. interceptors: Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol? = nil
  452. ) {
  453. self.channel = channel
  454. self.defaultCallOptions = defaultCallOptions
  455. self.interceptors = interceptors
  456. }
  457. }
  458. /// To build a server, implement a class that conforms to this protocol.
  459. public protocol Grpc_Testing_TestServiceProvider: CallHandlerProvider {
  460. /// One empty request followed by one empty response.
  461. func emptyCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  462. /// One request followed by one response.
  463. func unaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  464. /// One request followed by one response. Response has cache control
  465. /// headers set such that a caching HTTP proxy (such as GFE) can
  466. /// satisfy subsequent requests.
  467. func cacheableUnaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  468. /// One request followed by a sequence of responses (streamed download).
  469. /// The server returns the payload with client desired type and sizes.
  470. func streamingOutputCall(request: Grpc_Testing_StreamingOutputCallRequest, context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<GRPCStatus>
  471. /// A sequence of requests followed by one response (streamed upload).
  472. /// The server returns the aggregated size of client payload as the result.
  473. func streamingInputCall(context: UnaryResponseCallContext<Grpc_Testing_StreamingInputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingInputCallRequest>) -> Void>
  474. /// A sequence of requests with each request served by the server immediately.
  475. /// As one request could lead to multiple responses, this interface
  476. /// demonstrates the idea of full duplexing.
  477. func fullDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  478. /// A sequence of requests followed by a sequence of responses.
  479. /// The server buffers all the client requests and then serves them in order. A
  480. /// stream of responses are returned to the client when the server starts with
  481. /// first request.
  482. func halfDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  483. }
  484. extension Grpc_Testing_TestServiceProvider {
  485. public var serviceName: Substring { return "grpc.testing.TestService" }
  486. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  487. /// Returns nil for methods not handled by this service.
  488. public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  489. switch methodName {
  490. case "EmptyCall":
  491. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  492. return { request in
  493. self.emptyCall(request: request, context: context)
  494. }
  495. }
  496. case "UnaryCall":
  497. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  498. return { request in
  499. self.unaryCall(request: request, context: context)
  500. }
  501. }
  502. case "CacheableUnaryCall":
  503. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  504. return { request in
  505. self.cacheableUnaryCall(request: request, context: context)
  506. }
  507. }
  508. case "StreamingOutputCall":
  509. return CallHandlerFactory.makeServerStreaming(callHandlerContext: callHandlerContext) { context in
  510. return { request in
  511. self.streamingOutputCall(request: request, context: context)
  512. }
  513. }
  514. case "StreamingInputCall":
  515. return CallHandlerFactory.makeClientStreaming(callHandlerContext: callHandlerContext) { context in
  516. return self.streamingInputCall(context: context)
  517. }
  518. case "FullDuplexCall":
  519. return CallHandlerFactory.makeBidirectionalStreaming(callHandlerContext: callHandlerContext) { context in
  520. return self.fullDuplexCall(context: context)
  521. }
  522. case "HalfDuplexCall":
  523. return CallHandlerFactory.makeBidirectionalStreaming(callHandlerContext: callHandlerContext) { context in
  524. return self.halfDuplexCall(context: context)
  525. }
  526. default: return nil
  527. }
  528. }
  529. }
  530. /// To build a server, implement a class that conforms to this protocol.
  531. public protocol Grpc_Testing_UnimplementedServiceProvider: CallHandlerProvider {
  532. /// A call that no server should implement
  533. func unimplementedCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  534. }
  535. extension Grpc_Testing_UnimplementedServiceProvider {
  536. public var serviceName: Substring { return "grpc.testing.UnimplementedService" }
  537. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  538. /// Returns nil for methods not handled by this service.
  539. public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  540. switch methodName {
  541. case "UnimplementedCall":
  542. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  543. return { request in
  544. self.unimplementedCall(request: request, context: context)
  545. }
  546. }
  547. default: return nil
  548. }
  549. }
  550. }
  551. /// To build a server, implement a class that conforms to this protocol.
  552. public protocol Grpc_Testing_ReconnectServiceProvider: CallHandlerProvider {
  553. func start(request: Grpc_Testing_ReconnectParams, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  554. func stop(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_ReconnectInfo>
  555. }
  556. extension Grpc_Testing_ReconnectServiceProvider {
  557. public var serviceName: Substring { return "grpc.testing.ReconnectService" }
  558. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  559. /// Returns nil for methods not handled by this service.
  560. public func handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? {
  561. switch methodName {
  562. case "Start":
  563. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  564. return { request in
  565. self.start(request: request, context: context)
  566. }
  567. }
  568. case "Stop":
  569. return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in
  570. return { request in
  571. self.stop(request: request, context: context)
  572. }
  573. }
  574. default: return nil
  575. }
  576. }
  577. }