grpc_testing_benchmark_service.grpc.swift 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  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 = GRPCCore.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 = GRPCCore.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 = GRPCCore.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 = GRPCCore.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 = GRPCCore.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 = GRPCCore.MethodDescriptor(
  65. service: Grpc_Testing_BenchmarkService.descriptor.fullyQualifiedService,
  66. method: "StreamingBothWays"
  67. )
  68. }
  69. internal static let descriptors: [GRPCCore.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 GRPCCore.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(
  97. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  98. context: GRPCCore.ServerContext
  99. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  100. /// Repeated sequence of one request followed by one response.
  101. /// Should be called streaming ping-pong
  102. /// The server returns the client payload as-is on each response
  103. func streamingCall(
  104. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  105. context: GRPCCore.ServerContext
  106. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  107. /// Single-sided unbounded streaming from client to server
  108. /// The server returns the client payload as-is once the client does WritesDone
  109. func streamingFromClient(
  110. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  111. context: GRPCCore.ServerContext
  112. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  113. /// Single-sided unbounded streaming from server to client
  114. /// The server repeatedly returns the client payload as-is
  115. func streamingFromServer(
  116. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  117. context: GRPCCore.ServerContext
  118. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  119. /// Two-sided unbounded streaming between server to client
  120. /// Both sides send the content of their own choice to the other
  121. func streamingBothWays(
  122. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  123. context: GRPCCore.ServerContext
  124. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  125. }
  126. /// Conformance to `GRPCCore.RegistrableRPCService`.
  127. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  128. extension Grpc_Testing_BenchmarkService.StreamingServiceProtocol {
  129. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  130. internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
  131. router.registerHandler(
  132. forMethod: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor,
  133. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  134. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  135. handler: { request, context in
  136. try await self.unaryCall(
  137. request: request,
  138. context: context
  139. )
  140. }
  141. )
  142. router.registerHandler(
  143. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor,
  144. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  145. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  146. handler: { request, context in
  147. try await self.streamingCall(
  148. request: request,
  149. context: context
  150. )
  151. }
  152. )
  153. router.registerHandler(
  154. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor,
  155. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  156. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  157. handler: { request, context in
  158. try await self.streamingFromClient(
  159. request: request,
  160. context: context
  161. )
  162. }
  163. )
  164. router.registerHandler(
  165. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor,
  166. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  167. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  168. handler: { request, context in
  169. try await self.streamingFromServer(
  170. request: request,
  171. context: context
  172. )
  173. }
  174. )
  175. router.registerHandler(
  176. forMethod: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor,
  177. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleRequest>(),
  178. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleResponse>(),
  179. handler: { request, context in
  180. try await self.streamingBothWays(
  181. request: request,
  182. context: context
  183. )
  184. }
  185. )
  186. }
  187. }
  188. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  189. internal protocol Grpc_Testing_BenchmarkServiceServiceProtocol: Grpc_Testing_BenchmarkService.StreamingServiceProtocol {
  190. /// One request followed by one response.
  191. /// The server returns the client payload as-is.
  192. func unaryCall(
  193. request: GRPCCore.ServerRequest.Single<Grpc_Testing_SimpleRequest>,
  194. context: GRPCCore.ServerContext
  195. ) async throws -> GRPCCore.ServerResponse.Single<Grpc_Testing_SimpleResponse>
  196. /// Repeated sequence of one request followed by one response.
  197. /// Should be called streaming ping-pong
  198. /// The server returns the client payload as-is on each response
  199. func streamingCall(
  200. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  201. context: GRPCCore.ServerContext
  202. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  203. /// Single-sided unbounded streaming from client to server
  204. /// The server returns the client payload as-is once the client does WritesDone
  205. func streamingFromClient(
  206. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  207. context: GRPCCore.ServerContext
  208. ) async throws -> GRPCCore.ServerResponse.Single<Grpc_Testing_SimpleResponse>
  209. /// Single-sided unbounded streaming from server to client
  210. /// The server repeatedly returns the client payload as-is
  211. func streamingFromServer(
  212. request: GRPCCore.ServerRequest.Single<Grpc_Testing_SimpleRequest>,
  213. context: GRPCCore.ServerContext
  214. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  215. /// Two-sided unbounded streaming between server to client
  216. /// Both sides send the content of their own choice to the other
  217. func streamingBothWays(
  218. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  219. context: GRPCCore.ServerContext
  220. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse>
  221. }
  222. /// Partial conformance to `Grpc_Testing_BenchmarkServiceStreamingServiceProtocol`.
  223. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  224. extension Grpc_Testing_BenchmarkService.ServiceProtocol {
  225. internal func unaryCall(
  226. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  227. context: GRPCCore.ServerContext
  228. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse> {
  229. let response = try await self.unaryCall(
  230. request: GRPCCore.ServerRequest.Single(stream: request),
  231. context: context
  232. )
  233. return GRPCCore.ServerResponse.Stream(single: response)
  234. }
  235. internal func streamingFromClient(
  236. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  237. context: GRPCCore.ServerContext
  238. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse> {
  239. let response = try await self.streamingFromClient(
  240. request: request,
  241. context: context
  242. )
  243. return GRPCCore.ServerResponse.Stream(single: response)
  244. }
  245. internal func streamingFromServer(
  246. request: GRPCCore.ServerRequest.Stream<Grpc_Testing_SimpleRequest>,
  247. context: GRPCCore.ServerContext
  248. ) async throws -> GRPCCore.ServerResponse.Stream<Grpc_Testing_SimpleResponse> {
  249. let response = try await self.streamingFromServer(
  250. request: GRPCCore.ServerRequest.Single(stream: request),
  251. context: context
  252. )
  253. return response
  254. }
  255. }
  256. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  257. internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable {
  258. /// One request followed by one response.
  259. /// The server returns the client payload as-is.
  260. func unaryCall<R>(
  261. request: GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  262. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  263. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  264. options: GRPCCore.CallOptions,
  265. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  266. ) async throws -> R where R: Sendable
  267. /// Repeated sequence of one request followed by one response.
  268. /// Should be called streaming ping-pong
  269. /// The server returns the client payload as-is on each response
  270. func streamingCall<R>(
  271. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  272. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  273. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  274. options: GRPCCore.CallOptions,
  275. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  276. ) async throws -> R where R: Sendable
  277. /// Single-sided unbounded streaming from client to server
  278. /// The server returns the client payload as-is once the client does WritesDone
  279. func streamingFromClient<R>(
  280. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  281. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  282. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  283. options: GRPCCore.CallOptions,
  284. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R
  285. ) async throws -> R where R: Sendable
  286. /// Single-sided unbounded streaming from server to client
  287. /// The server repeatedly returns the client payload as-is
  288. func streamingFromServer<R>(
  289. request: GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  290. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  291. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  292. options: GRPCCore.CallOptions,
  293. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  294. ) async throws -> R where R: Sendable
  295. /// Two-sided unbounded streaming between server to client
  296. /// Both sides send the content of their own choice to the other
  297. func streamingBothWays<R>(
  298. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  299. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  300. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  301. options: GRPCCore.CallOptions,
  302. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  303. ) async throws -> R where R: Sendable
  304. }
  305. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  306. extension Grpc_Testing_BenchmarkService.ClientProtocol {
  307. internal func unaryCall<R>(
  308. request: GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  309. options: GRPCCore.CallOptions = .defaults,
  310. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  311. try $0.message
  312. }
  313. ) async throws -> R where R: Sendable {
  314. try await self.unaryCall(
  315. request: request,
  316. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  317. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  318. options: options,
  319. body
  320. )
  321. }
  322. internal func streamingCall<R>(
  323. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  324. options: GRPCCore.CallOptions = .defaults,
  325. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  326. ) async throws -> R where R: Sendable {
  327. try await self.streamingCall(
  328. request: request,
  329. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  330. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  331. options: options,
  332. body
  333. )
  334. }
  335. internal func streamingFromClient<R>(
  336. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  337. options: GRPCCore.CallOptions = .defaults,
  338. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  339. try $0.message
  340. }
  341. ) async throws -> R where R: Sendable {
  342. try await self.streamingFromClient(
  343. request: request,
  344. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  345. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  346. options: options,
  347. body
  348. )
  349. }
  350. internal func streamingFromServer<R>(
  351. request: GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  352. options: GRPCCore.CallOptions = .defaults,
  353. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  354. ) async throws -> R where R: Sendable {
  355. try await self.streamingFromServer(
  356. request: request,
  357. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  358. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  359. options: options,
  360. body
  361. )
  362. }
  363. internal func streamingBothWays<R>(
  364. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  365. options: GRPCCore.CallOptions = .defaults,
  366. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  367. ) async throws -> R where R: Sendable {
  368. try await self.streamingBothWays(
  369. request: request,
  370. serializer: GRPCProtobuf.ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  371. deserializer: GRPCProtobuf.ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  372. options: options,
  373. body
  374. )
  375. }
  376. }
  377. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  378. extension Grpc_Testing_BenchmarkService.ClientProtocol {
  379. /// One request followed by one response.
  380. /// The server returns the client payload as-is.
  381. internal func unaryCall<Result>(
  382. _ message: Grpc_Testing_SimpleRequest,
  383. metadata: GRPCCore.Metadata = [:],
  384. options: GRPCCore.CallOptions = .defaults,
  385. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> Result = {
  386. try $0.message
  387. }
  388. ) async throws -> Result where Result: Sendable {
  389. let request = GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>(
  390. message: message,
  391. metadata: metadata
  392. )
  393. return try await self.unaryCall(
  394. request: request,
  395. options: options,
  396. handleResponse
  397. )
  398. }
  399. /// Repeated sequence of one request followed by one response.
  400. /// Should be called streaming ping-pong
  401. /// The server returns the client payload as-is on each response
  402. internal func streamingCall<Result>(
  403. metadata: GRPCCore.Metadata = [:],
  404. options: GRPCCore.CallOptions = .defaults,
  405. requestProducer: @Sendable @escaping (GRPCCore.RPCWriter<Grpc_Testing_SimpleRequest>) async throws -> Void,
  406. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> Result
  407. ) async throws -> Result where Result: Sendable {
  408. let request = GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>(
  409. metadata: metadata,
  410. producer: requestProducer
  411. )
  412. return try await self.streamingCall(
  413. request: request,
  414. options: options,
  415. handleResponse
  416. )
  417. }
  418. /// Single-sided unbounded streaming from client to server
  419. /// The server returns the client payload as-is once the client does WritesDone
  420. internal func streamingFromClient<Result>(
  421. metadata: GRPCCore.Metadata = [:],
  422. options: GRPCCore.CallOptions = .defaults,
  423. requestProducer: @Sendable @escaping (GRPCCore.RPCWriter<Grpc_Testing_SimpleRequest>) async throws -> Void,
  424. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> Result = {
  425. try $0.message
  426. }
  427. ) async throws -> Result where Result: Sendable {
  428. let request = GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>(
  429. metadata: metadata,
  430. producer: requestProducer
  431. )
  432. return try await self.streamingFromClient(
  433. request: request,
  434. options: options,
  435. handleResponse
  436. )
  437. }
  438. /// Single-sided unbounded streaming from server to client
  439. /// The server repeatedly returns the client payload as-is
  440. internal func streamingFromServer<Result>(
  441. _ message: Grpc_Testing_SimpleRequest,
  442. metadata: GRPCCore.Metadata = [:],
  443. options: GRPCCore.CallOptions = .defaults,
  444. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> Result
  445. ) async throws -> Result where Result: Sendable {
  446. let request = GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>(
  447. message: message,
  448. metadata: metadata
  449. )
  450. return try await self.streamingFromServer(
  451. request: request,
  452. options: options,
  453. handleResponse
  454. )
  455. }
  456. /// Two-sided unbounded streaming between server to client
  457. /// Both sides send the content of their own choice to the other
  458. internal func streamingBothWays<Result>(
  459. metadata: GRPCCore.Metadata = [:],
  460. options: GRPCCore.CallOptions = .defaults,
  461. requestProducer: @Sendable @escaping (GRPCCore.RPCWriter<Grpc_Testing_SimpleRequest>) async throws -> Void,
  462. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> Result
  463. ) async throws -> Result where Result: Sendable {
  464. let request = GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>(
  465. metadata: metadata,
  466. producer: requestProducer
  467. )
  468. return try await self.streamingBothWays(
  469. request: request,
  470. options: options,
  471. handleResponse
  472. )
  473. }
  474. }
  475. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  476. internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkService.ClientProtocol {
  477. private let client: GRPCCore.GRPCClient
  478. internal init(wrapping client: GRPCCore.GRPCClient) {
  479. self.client = client
  480. }
  481. /// One request followed by one response.
  482. /// The server returns the client payload as-is.
  483. internal func unaryCall<R>(
  484. request: GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  485. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  486. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  487. options: GRPCCore.CallOptions = .defaults,
  488. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  489. try $0.message
  490. }
  491. ) async throws -> R where R: Sendable {
  492. try await self.client.unary(
  493. request: request,
  494. descriptor: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor,
  495. serializer: serializer,
  496. deserializer: deserializer,
  497. options: options,
  498. handler: body
  499. )
  500. }
  501. /// Repeated sequence of one request followed by one response.
  502. /// Should be called streaming ping-pong
  503. /// The server returns the client payload as-is on each response
  504. internal func streamingCall<R>(
  505. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  506. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  507. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  508. options: GRPCCore.CallOptions = .defaults,
  509. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  510. ) async throws -> R where R: Sendable {
  511. try await self.client.bidirectionalStreaming(
  512. request: request,
  513. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor,
  514. serializer: serializer,
  515. deserializer: deserializer,
  516. options: options,
  517. handler: body
  518. )
  519. }
  520. /// Single-sided unbounded streaming from client to server
  521. /// The server returns the client payload as-is once the client does WritesDone
  522. internal func streamingFromClient<R>(
  523. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  524. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  525. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  526. options: GRPCCore.CallOptions = .defaults,
  527. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  528. try $0.message
  529. }
  530. ) async throws -> R where R: Sendable {
  531. try await self.client.clientStreaming(
  532. request: request,
  533. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor,
  534. serializer: serializer,
  535. deserializer: deserializer,
  536. options: options,
  537. handler: body
  538. )
  539. }
  540. /// Single-sided unbounded streaming from server to client
  541. /// The server repeatedly returns the client payload as-is
  542. internal func streamingFromServer<R>(
  543. request: GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  544. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  545. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  546. options: GRPCCore.CallOptions = .defaults,
  547. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  548. ) async throws -> R where R: Sendable {
  549. try await self.client.serverStreaming(
  550. request: request,
  551. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor,
  552. serializer: serializer,
  553. deserializer: deserializer,
  554. options: options,
  555. handler: body
  556. )
  557. }
  558. /// Two-sided unbounded streaming between server to client
  559. /// Both sides send the content of their own choice to the other
  560. internal func streamingBothWays<R>(
  561. request: GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  562. serializer: some GRPCCore.MessageSerializer<Grpc_Testing_SimpleRequest>,
  563. deserializer: some GRPCCore.MessageDeserializer<Grpc_Testing_SimpleResponse>,
  564. options: GRPCCore.CallOptions = .defaults,
  565. _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  566. ) async throws -> R where R: Sendable {
  567. try await self.client.bidirectionalStreaming(
  568. request: request,
  569. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor,
  570. serializer: serializer,
  571. deserializer: deserializer,
  572. options: options,
  573. handler: body
  574. )
  575. }
  576. }