grpc_testing_benchmark_service.grpc.swift 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  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. internal import GRPCCore
  25. internal 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. try $0.message
  249. }
  250. ) async throws -> R where R: Sendable {
  251. try await self.unaryCall(
  252. request: request,
  253. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  254. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  255. options: options,
  256. body
  257. )
  258. }
  259. internal func streamingCall<R>(
  260. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  261. options: CallOptions = .defaults,
  262. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  263. ) async throws -> R where R: Sendable {
  264. try await self.streamingCall(
  265. request: request,
  266. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  267. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  268. options: options,
  269. body
  270. )
  271. }
  272. internal func streamingFromClient<R>(
  273. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  274. options: CallOptions = .defaults,
  275. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  276. try $0.message
  277. }
  278. ) async throws -> R where R: Sendable {
  279. try await self.streamingFromClient(
  280. request: request,
  281. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  282. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  283. options: options,
  284. body
  285. )
  286. }
  287. internal func streamingFromServer<R>(
  288. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  289. options: CallOptions = .defaults,
  290. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  291. ) async throws -> R where R: Sendable {
  292. try await self.streamingFromServer(
  293. request: request,
  294. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  295. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  296. options: options,
  297. body
  298. )
  299. }
  300. internal func streamingBothWays<R>(
  301. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  302. options: CallOptions = .defaults,
  303. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  304. ) async throws -> R where R: Sendable {
  305. try await self.streamingBothWays(
  306. request: request,
  307. serializer: ProtobufSerializer<Grpc_Testing_SimpleRequest>(),
  308. deserializer: ProtobufDeserializer<Grpc_Testing_SimpleResponse>(),
  309. options: options,
  310. body
  311. )
  312. }
  313. }
  314. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  315. extension Grpc_Testing_BenchmarkService.ClientProtocol {
  316. /// One request followed by one response.
  317. /// The server returns the client payload as-is.
  318. internal func unaryCall<Result>(
  319. _ message: Grpc_Testing_SimpleRequest,
  320. metadata: GRPCCore.Metadata = [:],
  321. options: GRPCCore.CallOptions = .defaults,
  322. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> Result = {
  323. try $0.message
  324. }
  325. ) async throws -> Result where Result: Sendable {
  326. let request = GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>(
  327. message: message,
  328. metadata: metadata
  329. )
  330. return try await self.unaryCall(
  331. request: request,
  332. options: options,
  333. handleResponse
  334. )
  335. }
  336. /// Repeated sequence of one request followed by one response.
  337. /// Should be called streaming ping-pong
  338. /// The server returns the client payload as-is on each response
  339. internal func streamingCall<Result>(
  340. metadata: GRPCCore.Metadata = [:],
  341. options: GRPCCore.CallOptions = .defaults,
  342. requestProducer: @Sendable @escaping (GRPCCore.RPCWriter<Grpc_Testing_SimpleRequest>) async throws -> Void,
  343. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> Result
  344. ) async throws -> Result where Result: Sendable {
  345. let request = GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>(
  346. metadata: metadata,
  347. producer: requestProducer
  348. )
  349. return try await self.streamingCall(
  350. request: request,
  351. options: options,
  352. handleResponse
  353. )
  354. }
  355. /// Single-sided unbounded streaming from client to server
  356. /// The server returns the client payload as-is once the client does WritesDone
  357. internal func streamingFromClient<Result>(
  358. metadata: GRPCCore.Metadata = [:],
  359. options: GRPCCore.CallOptions = .defaults,
  360. requestProducer: @Sendable @escaping (GRPCCore.RPCWriter<Grpc_Testing_SimpleRequest>) async throws -> Void,
  361. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> Result = {
  362. try $0.message
  363. }
  364. ) async throws -> Result where Result: Sendable {
  365. let request = GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>(
  366. metadata: metadata,
  367. producer: requestProducer
  368. )
  369. return try await self.streamingFromClient(
  370. request: request,
  371. options: options,
  372. handleResponse
  373. )
  374. }
  375. /// Single-sided unbounded streaming from server to client
  376. /// The server repeatedly returns the client payload as-is
  377. internal func streamingFromServer<Result>(
  378. _ message: Grpc_Testing_SimpleRequest,
  379. metadata: GRPCCore.Metadata = [:],
  380. options: GRPCCore.CallOptions = .defaults,
  381. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> Result
  382. ) async throws -> Result where Result: Sendable {
  383. let request = GRPCCore.ClientRequest.Single<Grpc_Testing_SimpleRequest>(
  384. message: message,
  385. metadata: metadata
  386. )
  387. return try await self.streamingFromServer(
  388. request: request,
  389. options: options,
  390. handleResponse
  391. )
  392. }
  393. /// Two-sided unbounded streaming between server to client
  394. /// Both sides send the content of their own choice to the other
  395. internal func streamingBothWays<Result>(
  396. metadata: GRPCCore.Metadata = [:],
  397. options: GRPCCore.CallOptions = .defaults,
  398. requestProducer: @Sendable @escaping (GRPCCore.RPCWriter<Grpc_Testing_SimpleRequest>) async throws -> Void,
  399. onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> Result
  400. ) async throws -> Result where Result: Sendable {
  401. let request = GRPCCore.ClientRequest.Stream<Grpc_Testing_SimpleRequest>(
  402. metadata: metadata,
  403. producer: requestProducer
  404. )
  405. return try await self.streamingBothWays(
  406. request: request,
  407. options: options,
  408. handleResponse
  409. )
  410. }
  411. }
  412. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *)
  413. internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkService.ClientProtocol {
  414. private let client: GRPCCore.GRPCClient
  415. internal init(wrapping client: GRPCCore.GRPCClient) {
  416. self.client = client
  417. }
  418. /// One request followed by one response.
  419. /// The server returns the client payload as-is.
  420. internal func unaryCall<R>(
  421. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  422. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  423. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  424. options: CallOptions = .defaults,
  425. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  426. try $0.message
  427. }
  428. ) async throws -> R where R: Sendable {
  429. try await self.client.unary(
  430. request: request,
  431. descriptor: Grpc_Testing_BenchmarkService.Method.UnaryCall.descriptor,
  432. serializer: serializer,
  433. deserializer: deserializer,
  434. options: options,
  435. handler: body
  436. )
  437. }
  438. /// Repeated sequence of one request followed by one response.
  439. /// Should be called streaming ping-pong
  440. /// The server returns the client payload as-is on each response
  441. internal func streamingCall<R>(
  442. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  443. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  444. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  445. options: CallOptions = .defaults,
  446. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  447. ) async throws -> R where R: Sendable {
  448. try await self.client.bidirectionalStreaming(
  449. request: request,
  450. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingCall.descriptor,
  451. serializer: serializer,
  452. deserializer: deserializer,
  453. options: options,
  454. handler: body
  455. )
  456. }
  457. /// Single-sided unbounded streaming from client to server
  458. /// The server returns the client payload as-is once the client does WritesDone
  459. internal func streamingFromClient<R>(
  460. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  461. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  462. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  463. options: CallOptions = .defaults,
  464. _ body: @Sendable @escaping (ClientResponse.Single<Grpc_Testing_SimpleResponse>) async throws -> R = {
  465. try $0.message
  466. }
  467. ) async throws -> R where R: Sendable {
  468. try await self.client.clientStreaming(
  469. request: request,
  470. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingFromClient.descriptor,
  471. serializer: serializer,
  472. deserializer: deserializer,
  473. options: options,
  474. handler: body
  475. )
  476. }
  477. /// Single-sided unbounded streaming from server to client
  478. /// The server repeatedly returns the client payload as-is
  479. internal func streamingFromServer<R>(
  480. request: ClientRequest.Single<Grpc_Testing_SimpleRequest>,
  481. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  482. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  483. options: CallOptions = .defaults,
  484. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  485. ) async throws -> R where R: Sendable {
  486. try await self.client.serverStreaming(
  487. request: request,
  488. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingFromServer.descriptor,
  489. serializer: serializer,
  490. deserializer: deserializer,
  491. options: options,
  492. handler: body
  493. )
  494. }
  495. /// Two-sided unbounded streaming between server to client
  496. /// Both sides send the content of their own choice to the other
  497. internal func streamingBothWays<R>(
  498. request: ClientRequest.Stream<Grpc_Testing_SimpleRequest>,
  499. serializer: some MessageSerializer<Grpc_Testing_SimpleRequest>,
  500. deserializer: some MessageDeserializer<Grpc_Testing_SimpleResponse>,
  501. options: CallOptions = .defaults,
  502. _ body: @Sendable @escaping (ClientResponse.Stream<Grpc_Testing_SimpleResponse>) async throws -> R
  503. ) async throws -> R where R: Sendable {
  504. try await self.client.bidirectionalStreaming(
  505. request: request,
  506. descriptor: Grpc_Testing_BenchmarkService.Method.StreamingBothWays.descriptor,
  507. serializer: serializer,
  508. deserializer: deserializer,
  509. options: options,
  510. handler: body
  511. )
  512. }
  513. }