grpc_testing_benchmark_service.grpc.swift 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. // Copyright 2015 gRPC authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. /// An integration test service that covers all the method signature permutations
  15. /// of unary/streaming requests/responses.
  16. // DO NOT EDIT.
  17. // swift-format-ignore-file
  18. //
  19. // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
  20. // Source: grpc/testing/benchmark_service.proto
  21. //
  22. // For information on using the generated types, please see the documentation:
  23. // https://github.com/grpc/grpc-swift
  24. import GRPCCore
  25. import GRPCProtobuf
  26. internal enum Grpc_Testing_BenchmarkService {
  27. internal static let descriptor = ServiceDescriptor.grpc_testing_BenchmarkService
  28. internal enum Method {
  29. internal enum UnaryCall {
  30. internal typealias Input = Grpc_Testing_SimpleRequest
  31. internal typealias Output = Grpc_Testing_SimpleResponse
  32. internal static let descriptor = MethodDescriptor(
  33. service: Grpc_Testing_BenchmarkService.descriptor.fullyQualifiedService,
  34. method: "UnaryCall"
  35. )
  36. }
  37. internal enum StreamingCall {
  38. internal typealias Input = Grpc_Testing_SimpleRequest
  39. internal typealias Output = Grpc_Testing_SimpleResponse
  40. internal static let descriptor = MethodDescriptor(
  41. service: Grpc_Testing_BenchmarkService.descriptor.fullyQualifiedService,
  42. method: "StreamingCall"
  43. )
  44. }
  45. internal enum StreamingFromClient {
  46. internal typealias Input = Grpc_Testing_SimpleRequest
  47. internal typealias Output = Grpc_Testing_SimpleResponse
  48. internal static let descriptor = MethodDescriptor(
  49. service: Grpc_Testing_BenchmarkService.descriptor.fullyQualifiedService,
  50. method: "StreamingFromClient"
  51. )
  52. }
  53. internal enum StreamingFromServer {
  54. internal typealias Input = Grpc_Testing_SimpleRequest
  55. internal typealias Output = Grpc_Testing_SimpleResponse
  56. internal static let descriptor = MethodDescriptor(
  57. service: Grpc_Testing_BenchmarkService.descriptor.fullyQualifiedService,
  58. method: "StreamingFromServer"
  59. )
  60. }
  61. internal enum StreamingBothWays {
  62. internal typealias Input = Grpc_Testing_SimpleRequest
  63. internal typealias Output = Grpc_Testing_SimpleResponse
  64. internal static let descriptor = MethodDescriptor(
  65. service: Grpc_Testing_BenchmarkService.descriptor.fullyQualifiedService,
  66. method: "StreamingBothWays"
  67. )
  68. }
  69. internal static let descriptors: [MethodDescriptor] = [
  70. UnaryCall.descriptor,
  71. StreamingCall.descriptor,
  72. StreamingFromClient.descriptor,
  73. StreamingFromServer.descriptor,
  74. StreamingBothWays.descriptor
  75. ]
  76. }
  77. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  78. internal typealias StreamingServiceProtocol = Grpc_Testing_BenchmarkServiceStreamingServiceProtocol
  79. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  80. internal typealias ServiceProtocol = Grpc_Testing_BenchmarkServiceServiceProtocol
  81. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  82. internal typealias ClientProtocol = Grpc_Testing_BenchmarkServiceClientProtocol
  83. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  84. internal typealias Client = Grpc_Testing_BenchmarkServiceClient
  85. }
  86. extension ServiceDescriptor {
  87. internal static let grpc_testing_BenchmarkService = Self(
  88. package: "grpc.testing",
  89. service: "BenchmarkService"
  90. )
  91. }
  92. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  93. internal protocol Grpc_Testing_BenchmarkServiceStreamingServiceProtocol: GRPCCore.RegistrableRPCService {
  94. /// One request followed by one response.
  95. /// The server returns the client payload as-is.
  96. func unaryCall(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  97. /// Repeated sequence of one request followed by one response.
  98. /// Should be called streaming ping-pong
  99. /// The server returns the client payload as-is on each response
  100. func streamingCall(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  101. /// Single-sided unbounded streaming from client to server
  102. /// The server returns the client payload as-is once the client does WritesDone
  103. func streamingFromClient(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  104. /// Single-sided unbounded streaming from server to client
  105. /// The server repeatedly returns the client payload as-is
  106. func streamingFromServer(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  107. /// Two-sided unbounded streaming between server to client
  108. /// Both sides send the content of their own choice to the other
  109. func streamingBothWays(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  110. }
  111. /// Conformance to `GRPCCore.RegistrableRPCService`.
  112. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  113. extension Grpc_Testing_BenchmarkService.StreamingServiceProtocol {
  114. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  115. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  116. router.registerHandler(
  117. forMethod: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor,
  118. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  119. serializer: ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  120. handler: { request in
  121. try await self.unaryCall(request: request)
  122. }
  123. )
  124. router.registerHandler(
  125. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor,
  126. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  127. serializer: ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  128. handler: { request in
  129. try await self.streamingCall(request: request)
  130. }
  131. )
  132. router.registerHandler(
  133. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor,
  134. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  135. serializer: ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  136. handler: { request in
  137. try await self.streamingFromClient(request: request)
  138. }
  139. )
  140. router.registerHandler(
  141. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor,
  142. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  143. serializer: ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  144. handler: { request in
  145. try await self.streamingFromServer(request: request)
  146. }
  147. )
  148. router.registerHandler(
  149. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor,
  150. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  151. serializer: ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  152. handler: { request in
  153. try await self.streamingBothWays(request: request)
  154. }
  155. )
  156. }
  157. }
  158. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  159. internal protocol Grpc_Testing_BenchmarkServiceServiceProtocol: Grpc_Testing_BenchmarkService.StreamingServiceProtocol {
  160. /// One request followed by one response.
  161. /// The server returns the client payload as-is.
  162. func unaryCall(request: ServerRequest.Single<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Single<Grpc_Testing_SimpleResponse>
  163. /// Repeated sequence of one request followed by one response.
  164. /// Should be called streaming ping-pong
  165. /// The server returns the client payload as-is on each response
  166. func streamingCall(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  167. /// Single-sided unbounded streaming from client to server
  168. /// The server returns the client payload as-is once the client does WritesDone
  169. func streamingFromClient(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Single<Grpc_Testing_SimpleResponse>
  170. /// Single-sided unbounded streaming from server to client
  171. /// The server repeatedly returns the client payload as-is
  172. func streamingFromServer(request: ServerRequest.Single<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  173. /// Two-sided unbounded streaming between server to client
  174. /// Both sides send the content of their own choice to the other
  175. func streamingBothWays(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  176. }
  177. /// Partial conformance to `Grpc_Testing_BenchmarkServiceStreamingServiceProtocol`.
  178. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  179. extension Grpc_Testing_BenchmarkService.ServiceProtocol {
  180. internal func unaryCall(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse> {
  181. let response = try await self.unaryCall(request: ServerRequest.Single(stream: request))
  182. return ServerResponse.Stream(single: response)
  183. }
  184. internal func streamingFromClient(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse> {
  185. let response = try await self.streamingFromClient(request: request)
  186. return ServerResponse.Stream(single: response)
  187. }
  188. internal func streamingFromServer(request: ServerRequest.Stream<Grpc_Testing_SimpleRequest>) async throws -> ServerResponse.Stream<Grpc_Testing_SimpleResponse> {
  189. let response = try await self.streamingFromServer(request: ServerRequest.Single(stream: request))
  190. return response
  191. }
  192. }
  193. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  194. internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable {
  195. /// One request followed by one response.
  196. /// The server returns the client payload as-is.
  197. func unaryCall<R>(
  198. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  199. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  200. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  201. options: CallOptions,
  202. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  203. ) async throws -> R where R: Sendable
  204. /// Repeated sequence of one request followed by one response.
  205. /// Should be called streaming ping-pong
  206. /// The server returns the client payload as-is on each response
  207. func streamingCall<R>(
  208. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  209. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  210. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  211. options: CallOptions,
  212. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  213. ) async throws -> R where R: Sendable
  214. /// Single-sided unbounded streaming from client to server
  215. /// The server returns the client payload as-is once the client does WritesDone
  216. func streamingFromClient<R>(
  217. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  218. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  219. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  220. options: CallOptions,
  221. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  222. ) async throws -> R where R: Sendable
  223. /// Single-sided unbounded streaming from server to client
  224. /// The server repeatedly returns the client payload as-is
  225. func streamingFromServer<R>(
  226. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  227. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  228. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  229. options: CallOptions,
  230. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  231. ) async throws -> R where R: Sendable
  232. /// Two-sided unbounded streaming between server to client
  233. /// Both sides send the content of their own choice to the other
  234. func streamingBothWays<R>(
  235. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  236. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  237. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  238. options: CallOptions,
  239. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  240. ) async throws -> R where R: Sendable
  241. }
  242. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  243. extension Grpc_Testing_BenchmarkService.ClientProtocol {
  244. internal func unaryCall<R>(
  245. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  246. options: CallOptions = .defaults,
  247. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  248. ) async throws -> R where R: Sendable {
  249. try await self.unaryCall(
  250. request: request,
  251. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  252. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  253. options: options,
  254. body
  255. )
  256. }
  257. internal func streamingCall<R>(
  258. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  259. options: CallOptions = .defaults,
  260. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  261. ) async throws -> R where R: Sendable {
  262. try await self.streamingCall(
  263. request: request,
  264. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  265. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  266. options: options,
  267. body
  268. )
  269. }
  270. internal func streamingFromClient<R>(
  271. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  272. options: CallOptions = .defaults,
  273. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  274. ) async throws -> R where R: Sendable {
  275. try await self.streamingFromClient(
  276. request: request,
  277. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  278. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  279. options: options,
  280. body
  281. )
  282. }
  283. internal func streamingFromServer<R>(
  284. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  285. options: CallOptions = .defaults,
  286. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  287. ) async throws -> R where R: Sendable {
  288. try await self.streamingFromServer(
  289. request: request,
  290. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  291. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  292. options: options,
  293. body
  294. )
  295. }
  296. internal func streamingBothWays<R>(
  297. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  298. options: CallOptions = .defaults,
  299. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  300. ) async throws -> R where R: Sendable {
  301. try await self.streamingBothWays(
  302. request: request,
  303. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  304. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  305. options: options,
  306. body
  307. )
  308. }
  309. }
  310. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  311. internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkService.ClientProtocol {
  312. private let client: GRPCCore.GRPCClient
  313. internal init(wrapping client: GRPCCore.GRPCClient) {
  314. self.client = client
  315. }
  316. /// One request followed by one response.
  317. /// The server returns the client payload as-is.
  318. internal func unaryCall<R>(
  319. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  320. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  321. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  322. options: CallOptions = .defaults,
  323. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  324. ) async throws -> R where R: Sendable {
  325. try await self.client.unary(
  326. request: request,
  327. descriptor: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor,
  328. serializer: serializer,
  329. deserializer: deserializer,
  330. options: options,
  331. handler: body
  332. )
  333. }
  334. /// Repeated sequence of one request followed by one response.
  335. /// Should be called streaming ping-pong
  336. /// The server returns the client payload as-is on each response
  337. internal func streamingCall<R>(
  338. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  339. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  340. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  341. options: CallOptions = .defaults,
  342. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  343. ) async throws -> R where R: Sendable {
  344. try await self.client.bidirectionalStreaming(
  345. request: request,
  346. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor,
  347. serializer: serializer,
  348. deserializer: deserializer,
  349. options: options,
  350. handler: body
  351. )
  352. }
  353. /// Single-sided unbounded streaming from client to server
  354. /// The server returns the client payload as-is once the client does WritesDone
  355. internal func streamingFromClient<R>(
  356. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  357. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  358. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  359. options: CallOptions = .defaults,
  360. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  361. ) async throws -> R where R: Sendable {
  362. try await self.client.clientStreaming(
  363. request: request,
  364. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor,
  365. serializer: serializer,
  366. deserializer: deserializer,
  367. options: options,
  368. handler: body
  369. )
  370. }
  371. /// Single-sided unbounded streaming from server to client
  372. /// The server repeatedly returns the client payload as-is
  373. internal func streamingFromServer<R>(
  374. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  375. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  376. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  377. options: CallOptions = .defaults,
  378. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  379. ) async throws -> R where R: Sendable {
  380. try await self.client.serverStreaming(
  381. request: request,
  382. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor,
  383. serializer: serializer,
  384. deserializer: deserializer,
  385. options: options,
  386. handler: body
  387. )
  388. }
  389. /// Two-sided unbounded streaming between server to client
  390. /// Both sides send the content of their own choice to the other
  391. internal func streamingBothWays<R>(
  392. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  393. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  394. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  395. options: CallOptions = .defaults,
  396. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  397. ) async throws -> R where R: Sendable {
  398. try await self.client.bidirectionalStreaming(
  399. request: request,
  400. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor,
  401. serializer: serializer,
  402. deserializer: deserializer,
  403. options: options,
  404. handler: body
  405. )
  406. }
  407. }