test.grpc.swift 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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 NIO
  24. import NIOHTTP1
  25. import GRPC
  26. import SwiftProtobuf
  27. /// Usage: instantiate Grpc_Testing_TestServiceServiceClient, then call methods of this protocol to make API calls.
  28. public protocol Grpc_Testing_TestServiceService {
  29. func emptyCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  30. func unaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>
  31. func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse>
  32. func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  33. func streamingInputCall(callOptions: CallOptions?) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse>
  34. func fullDuplexCall(callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  35. func halfDuplexCall(callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse>
  36. func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  37. }
  38. public final class Grpc_Testing_TestServiceServiceClient: GRPCServiceClient, Grpc_Testing_TestServiceService {
  39. public let connection: ClientConnection
  40. public var serviceName: String { return "grpc.testing.TestService" }
  41. public var defaultCallOptions: CallOptions
  42. /// Creates a client for the grpc.testing.TestService service.
  43. ///
  44. /// - Parameters:
  45. /// - connection: `ClientConnection` to the service host.
  46. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  47. public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  48. self.connection = connection
  49. self.defaultCallOptions = defaultCallOptions
  50. }
  51. /// Asynchronous unary call to EmptyCall.
  52. ///
  53. /// - Parameters:
  54. /// - request: Request to send to EmptyCall.
  55. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  56. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  57. public func emptyCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  58. return self.makeUnaryCall(path: self.path(forMethod: "EmptyCall"),
  59. request: request,
  60. callOptions: callOptions ?? self.defaultCallOptions)
  61. }
  62. /// Asynchronous unary call to UnaryCall.
  63. ///
  64. /// - Parameters:
  65. /// - request: Request to send to UnaryCall.
  66. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  67. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  68. public func unaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
  69. return self.makeUnaryCall(path: self.path(forMethod: "UnaryCall"),
  70. request: request,
  71. callOptions: callOptions ?? self.defaultCallOptions)
  72. }
  73. /// Asynchronous unary call to CacheableUnaryCall.
  74. ///
  75. /// - Parameters:
  76. /// - request: Request to send to CacheableUnaryCall.
  77. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  78. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  79. public func cacheableUnaryCall(_ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_SimpleRequest, Grpc_Testing_SimpleResponse> {
  80. return self.makeUnaryCall(path: self.path(forMethod: "CacheableUnaryCall"),
  81. request: request,
  82. callOptions: callOptions ?? self.defaultCallOptions)
  83. }
  84. /// Asynchronous server-streaming call to StreamingOutputCall.
  85. ///
  86. /// - Parameters:
  87. /// - request: Request to send to StreamingOutputCall.
  88. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  89. /// - handler: A closure called when each response is received from the server.
  90. /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
  91. public func streamingOutputCall(_ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> ServerStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  92. return self.makeServerStreamingCall(path: self.path(forMethod: "StreamingOutputCall"),
  93. request: request,
  94. callOptions: callOptions ?? self.defaultCallOptions,
  95. handler: handler)
  96. }
  97. /// Asynchronous client-streaming call to StreamingInputCall.
  98. ///
  99. /// Callers should use the `send` method on the returned object to send messages
  100. /// to the server. The caller should send an `.end` after the final message has been sent.
  101. ///
  102. /// - Parameters:
  103. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  104. /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
  105. public func streamingInputCall(callOptions: CallOptions? = nil) -> ClientStreamingCall<Grpc_Testing_StreamingInputCallRequest, Grpc_Testing_StreamingInputCallResponse> {
  106. return self.makeClientStreamingCall(path: self.path(forMethod: "StreamingInputCall"),
  107. callOptions: callOptions ?? self.defaultCallOptions)
  108. }
  109. /// Asynchronous bidirectional-streaming call to FullDuplexCall.
  110. ///
  111. /// Callers should use the `send` method on the returned object to send messages
  112. /// to the server. The caller should send an `.end` after the final message has been sent.
  113. ///
  114. /// - Parameters:
  115. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  116. /// - handler: A closure called when each response is received from the server.
  117. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  118. public func fullDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  119. return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "FullDuplexCall"),
  120. callOptions: callOptions ?? self.defaultCallOptions,
  121. handler: handler)
  122. }
  123. /// Asynchronous bidirectional-streaming call to HalfDuplexCall.
  124. ///
  125. /// Callers should use the `send` method on the returned object to send messages
  126. /// to the server. The caller should send an `.end` after the final message has been sent.
  127. ///
  128. /// - Parameters:
  129. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  130. /// - handler: A closure called when each response is received from the server.
  131. /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
  132. public func halfDuplexCall(callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void) -> BidirectionalStreamingCall<Grpc_Testing_StreamingOutputCallRequest, Grpc_Testing_StreamingOutputCallResponse> {
  133. return self.makeBidirectionalStreamingCall(path: self.path(forMethod: "HalfDuplexCall"),
  134. callOptions: callOptions ?? self.defaultCallOptions,
  135. handler: handler)
  136. }
  137. /// Asynchronous unary call to UnimplementedCall.
  138. ///
  139. /// - Parameters:
  140. /// - request: Request to send to UnimplementedCall.
  141. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  142. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  143. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  144. return self.makeUnaryCall(path: self.path(forMethod: "UnimplementedCall"),
  145. request: request,
  146. callOptions: callOptions ?? self.defaultCallOptions)
  147. }
  148. }
  149. /// Usage: instantiate Grpc_Testing_UnimplementedServiceServiceClient, then call methods of this protocol to make API calls.
  150. public protocol Grpc_Testing_UnimplementedServiceService {
  151. func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty>
  152. }
  153. public final class Grpc_Testing_UnimplementedServiceServiceClient: GRPCServiceClient, Grpc_Testing_UnimplementedServiceService {
  154. public let connection: ClientConnection
  155. public var serviceName: String { return "grpc.testing.UnimplementedService" }
  156. public var defaultCallOptions: CallOptions
  157. /// Creates a client for the grpc.testing.UnimplementedService service.
  158. ///
  159. /// - Parameters:
  160. /// - connection: `ClientConnection` to the service host.
  161. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  162. public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  163. self.connection = connection
  164. self.defaultCallOptions = defaultCallOptions
  165. }
  166. /// Asynchronous unary call to UnimplementedCall.
  167. ///
  168. /// - Parameters:
  169. /// - request: Request to send to UnimplementedCall.
  170. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  171. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  172. public func unimplementedCall(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_Empty> {
  173. return self.makeUnaryCall(path: self.path(forMethod: "UnimplementedCall"),
  174. request: request,
  175. callOptions: callOptions ?? self.defaultCallOptions)
  176. }
  177. }
  178. /// Usage: instantiate Grpc_Testing_ReconnectServiceServiceClient, then call methods of this protocol to make API calls.
  179. public protocol Grpc_Testing_ReconnectServiceService {
  180. func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty>
  181. func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions?) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo>
  182. }
  183. public final class Grpc_Testing_ReconnectServiceServiceClient: GRPCServiceClient, Grpc_Testing_ReconnectServiceService {
  184. public let connection: ClientConnection
  185. public var serviceName: String { return "grpc.testing.ReconnectService" }
  186. public var defaultCallOptions: CallOptions
  187. /// Creates a client for the grpc.testing.ReconnectService service.
  188. ///
  189. /// - Parameters:
  190. /// - connection: `ClientConnection` to the service host.
  191. /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
  192. public init(connection: ClientConnection, defaultCallOptions: CallOptions = CallOptions()) {
  193. self.connection = connection
  194. self.defaultCallOptions = defaultCallOptions
  195. }
  196. /// Asynchronous unary call to Start.
  197. ///
  198. /// - Parameters:
  199. /// - request: Request to send to Start.
  200. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  201. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  202. public func start(_ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_ReconnectParams, Grpc_Testing_Empty> {
  203. return self.makeUnaryCall(path: self.path(forMethod: "Start"),
  204. request: request,
  205. callOptions: callOptions ?? self.defaultCallOptions)
  206. }
  207. /// Asynchronous unary call to Stop.
  208. ///
  209. /// - Parameters:
  210. /// - request: Request to send to Stop.
  211. /// - callOptions: Call options; `self.defaultCallOptions` is used if `nil`.
  212. /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
  213. public func stop(_ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil) -> UnaryCall<Grpc_Testing_Empty, Grpc_Testing_ReconnectInfo> {
  214. return self.makeUnaryCall(path: self.path(forMethod: "Stop"),
  215. request: request,
  216. callOptions: callOptions ?? self.defaultCallOptions)
  217. }
  218. }
  219. /// To build a server, implement a class that conforms to this protocol.
  220. public protocol Grpc_Testing_TestServiceProvider: CallHandlerProvider {
  221. func emptyCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  222. func unaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  223. func cacheableUnaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_SimpleResponse>
  224. func streamingOutputCall(request: Grpc_Testing_StreamingOutputCallRequest, context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<GRPCStatus>
  225. func streamingInputCall(context: UnaryResponseCallContext<Grpc_Testing_StreamingInputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingInputCallRequest>) -> Void>
  226. func fullDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  227. func halfDuplexCall(context: StreamingResponseCallContext<Grpc_Testing_StreamingOutputCallResponse>) -> EventLoopFuture<(StreamEvent<Grpc_Testing_StreamingOutputCallRequest>) -> Void>
  228. }
  229. extension Grpc_Testing_TestServiceProvider {
  230. public var serviceName: String { return "grpc.testing.TestService" }
  231. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  232. /// Returns nil for methods not handled by this service.
  233. public func handleMethod(_ methodName: String, request: HTTPRequestHead, channel: Channel, errorDelegate: ServerErrorDelegate?) -> GRPCCallHandler? {
  234. switch methodName {
  235. case "EmptyCall":
  236. return UnaryCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  237. return { request in
  238. self.emptyCall(request: request, context: context)
  239. }
  240. }
  241. case "UnaryCall":
  242. return UnaryCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  243. return { request in
  244. self.unaryCall(request: request, context: context)
  245. }
  246. }
  247. case "CacheableUnaryCall":
  248. return UnaryCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  249. return { request in
  250. self.cacheableUnaryCall(request: request, context: context)
  251. }
  252. }
  253. case "StreamingOutputCall":
  254. return ServerStreamingCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  255. return { request in
  256. self.streamingOutputCall(request: request, context: context)
  257. }
  258. }
  259. case "StreamingInputCall":
  260. return ClientStreamingCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  261. return self.streamingInputCall(context: context)
  262. }
  263. case "FullDuplexCall":
  264. return BidirectionalStreamingCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  265. return self.fullDuplexCall(context: context)
  266. }
  267. case "HalfDuplexCall":
  268. return BidirectionalStreamingCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  269. return self.halfDuplexCall(context: context)
  270. }
  271. default: return nil
  272. }
  273. }
  274. }
  275. /// To build a server, implement a class that conforms to this protocol.
  276. public protocol Grpc_Testing_UnimplementedServiceProvider: CallHandlerProvider {
  277. func unimplementedCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  278. }
  279. extension Grpc_Testing_UnimplementedServiceProvider {
  280. public var serviceName: String { return "grpc.testing.UnimplementedService" }
  281. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  282. /// Returns nil for methods not handled by this service.
  283. public func handleMethod(_ methodName: String, request: HTTPRequestHead, channel: Channel, errorDelegate: ServerErrorDelegate?) -> GRPCCallHandler? {
  284. switch methodName {
  285. case "UnimplementedCall":
  286. return UnaryCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  287. return { request in
  288. self.unimplementedCall(request: request, context: context)
  289. }
  290. }
  291. default: return nil
  292. }
  293. }
  294. }
  295. /// To build a server, implement a class that conforms to this protocol.
  296. public protocol Grpc_Testing_ReconnectServiceProvider: CallHandlerProvider {
  297. func start(request: Grpc_Testing_ReconnectParams, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_Empty>
  298. func stop(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture<Grpc_Testing_ReconnectInfo>
  299. }
  300. extension Grpc_Testing_ReconnectServiceProvider {
  301. public var serviceName: String { return "grpc.testing.ReconnectService" }
  302. /// Determines, calls and returns the appropriate request handler, depending on the request's method.
  303. /// Returns nil for methods not handled by this service.
  304. public func handleMethod(_ methodName: String, request: HTTPRequestHead, channel: Channel, errorDelegate: ServerErrorDelegate?) -> GRPCCallHandler? {
  305. switch methodName {
  306. case "Start":
  307. return UnaryCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  308. return { request in
  309. self.start(request: request, context: context)
  310. }
  311. }
  312. case "Stop":
  313. return UnaryCallHandler(channel: channel, request: request, errorDelegate: errorDelegate) { context in
  314. return { request in
  315. self.stop(request: request, context: context)
  316. }
  317. }
  318. default: return nil
  319. }
  320. }
  321. }