test.grpc.swift 29 KB

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