From d8331947439866792a8fe8daa355c572b3e53729 Mon Sep 17 00:00:00 2001 From: George Barnett Date: Tue, 1 Oct 2024 12:50:25 +0100 Subject: [PATCH] Update generateed code and tests (#7) Motivation: Some names chagned in https://github.com/grpc/grpc-swift/pull/2076 so our generated code isn't up-to-date. Modifications: - Update names - Regenerate code Result: Tests and generated code are up-to-date --- .../Sources/BenchmarkClient.swift | 10 +- .../Sources/BenchmarkService.swift | 30 ++-- .../grpc_testing_benchmark_service.grpc.swift | 158 +++++++++--------- .../grpc_testing_worker_service.grpc.swift | 58 +++---- .../Sources/WorkerService.swift | 24 +-- .../ControlClient.swift | 16 +- .../ControlService.swift | 8 +- .../HTTP2TransportTests.swift | 78 ++++----- 8 files changed, 191 insertions(+), 191 deletions(-) diff --git a/IntegrationTests/grpc-performance-tests/Sources/BenchmarkClient.swift b/IntegrationTests/grpc-performance-tests/Sources/BenchmarkClient.swift index c625d68..f5f4c45 100644 --- a/IntegrationTests/grpc-performance-tests/Sources/BenchmarkClient.swift +++ b/IntegrationTests/grpc-performance-tests/Sources/BenchmarkClient.swift @@ -92,7 +92,7 @@ final class BenchmarkClient: Sendable { } internal func run() async throws { - let benchmarkClient = Grpc_Testing_BenchmarkServiceClient(wrapping: self.client) + let benchmarkClient = Grpc_Testing_BenchmarkService_Client(wrapping: self.client) return try await withThrowingTaskGroup(of: Void.self) { clientGroup in // Start the client. clientGroup.addTask { @@ -148,10 +148,10 @@ final class BenchmarkClient: Sendable { return (result, nanoseconds: Double(endTime - startTime)) } - private func unary(benchmark: Grpc_Testing_BenchmarkServiceClient) async { + private func unary(benchmark: Grpc_Testing_BenchmarkService_Client) async { let (errorCode, nanoseconds): (RPCError.Code?, Double) = await self.timeIt { do { - try await benchmark.unaryCall(request: ClientRequest.Single(message: self.message)) { + try await benchmark.unaryCall(request: ClientRequest(message: self.message)) { _ = try $0.message } return nil @@ -165,7 +165,7 @@ final class BenchmarkClient: Sendable { self.record(latencyNanos: nanoseconds, errorCode: errorCode) } - private func streaming(benchmark: Grpc_Testing_BenchmarkServiceClient) async { + private func streaming(benchmark: Grpc_Testing_BenchmarkService_Client) async { // Streaming RPCs ping-pong messages back and forth. To achieve this the response message // stream is sent to the request closure, and the request closure indicates the outcome back // to the response handler to keep the RPC alive for the appropriate amount of time. @@ -174,7 +174,7 @@ final class BenchmarkClient: Sendable { of: RPCAsyncSequence.self ) - let request = ClientRequest.Stream(of: Grpc_Testing_SimpleRequest.self) { writer in + let request = StreamingClientRequest(of: Grpc_Testing_SimpleRequest.self) { writer in defer { status.continuation.finish() } // The time at which the last message was sent. diff --git a/IntegrationTests/grpc-performance-tests/Sources/BenchmarkService.swift b/IntegrationTests/grpc-performance-tests/Sources/BenchmarkService.swift index 4041971..c99be79 100644 --- a/IntegrationTests/grpc-performance-tests/Sources/BenchmarkService.swift +++ b/IntegrationTests/grpc-performance-tests/Sources/BenchmarkService.swift @@ -26,16 +26,16 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { /// One request followed by one response. /// The server returns a client payload with the size requested by the client. func unaryCall( - request: ServerRequest.Single, + request: ServerRequest, context: ServerContext - ) async throws -> ServerResponse.Single { + ) async throws -> ServerResponse { // Throw an error if the status is not `ok`. Otherwise, an `ok` status is automatically sent // if the request is successful. if request.message.responseStatus.isInitialized { try self.checkOkStatus(request.message.responseStatus) } - return ServerResponse.Single( + return ServerResponse( message: .with { $0.payload = Grpc_Testing_Payload.with { $0.body = Data(count: Int(request.message.responseSize)) @@ -47,10 +47,10 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { /// Repeated sequence of one request followed by one response. /// The server returns a payload with the size requested by the client for each received message. func streamingCall( - request: ServerRequest.Stream, + request: StreamingServerRequest, context: ServerContext - ) async throws -> ServerResponse.Stream { - return ServerResponse.Stream { writer in + ) async throws -> StreamingServerResponse { + return StreamingServerResponse { writer in for try await message in request.messages { if message.responseStatus.isInitialized { try self.checkOkStatus(message.responseStatus) @@ -72,9 +72,9 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { /// Single-sided unbounded streaming from client to server. /// The server returns a payload with the size requested by the client once the client does WritesDone. func streamingFromClient( - request: ServerRequest.Stream, + request: StreamingServerRequest, context: ServerContext - ) async throws -> ServerResponse.Single { + ) async throws -> ServerResponse { var responseSize = 0 for try await message in request.messages { if message.responseStatus.isInitialized { @@ -83,7 +83,7 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { responseSize = Int(message.responseSize) } - return ServerResponse.Single( + return ServerResponse( message: .with { $0.payload = .with { $0.body = Data(count: responseSize) @@ -95,9 +95,9 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { /// Single-sided unbounded streaming from server to client. /// The server repeatedly returns a payload with the size requested by the client. func streamingFromServer( - request: ServerRequest.Single, + request: ServerRequest, context: ServerContext - ) async throws -> ServerResponse.Stream { + ) async throws -> StreamingServerResponse { if request.message.responseStatus.isInitialized { try self.checkOkStatus(request.message.responseStatus) } @@ -108,7 +108,7 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { } } - return ServerResponse.Stream { writer in + return StreamingServerResponse { writer in while self.working.load(ordering: .relaxed) { try await writer.write(response) } @@ -119,9 +119,9 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { /// Two-sided unbounded streaming between server to client. /// Both sides send the content of their own choice to the other. func streamingBothWays( - request: ServerRequest.Stream, + request: StreamingServerRequest, context: ServerContext - ) async throws -> ServerResponse.Stream { + ) async throws -> StreamingServerResponse { // The 100 size is used by the other implementations as well. // We are using the same canned response size for all responses // as it is allowed by the spec. @@ -150,7 +150,7 @@ final class BenchmarkService: Grpc_Testing_BenchmarkService.ServiceProtocol { // Marks if the inbound streaming is ongoing or finished. let inbound = InboundStreamingSignal() - return ServerResponse.Stream { writer in + return StreamingServerResponse { writer in try await withThrowingTaskGroup(of: Void.self) { group in group.addTask { for try await message in request.messages { diff --git a/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_benchmark_service.grpc.swift b/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_benchmark_service.grpc.swift index d8b4cdc..933d1ec 100644 --- a/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_benchmark_service.grpc.swift +++ b/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_benchmark_service.grpc.swift @@ -79,13 +79,13 @@ internal enum Grpc_Testing_BenchmarkService { ] } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - internal typealias StreamingServiceProtocol = Grpc_Testing_BenchmarkServiceStreamingServiceProtocol + internal typealias StreamingServiceProtocol = Grpc_Testing_BenchmarkService_StreamingServiceProtocol @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - internal typealias ServiceProtocol = Grpc_Testing_BenchmarkServiceServiceProtocol + internal typealias ServiceProtocol = Grpc_Testing_BenchmarkService_ServiceProtocol @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - internal typealias ClientProtocol = Grpc_Testing_BenchmarkServiceClientProtocol + internal typealias ClientProtocol = Grpc_Testing_BenchmarkService_ClientProtocol @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - internal typealias Client = Grpc_Testing_BenchmarkServiceClient + internal typealias Client = Grpc_Testing_BenchmarkService_Client } extension GRPCCore.ServiceDescriptor { @@ -96,42 +96,42 @@ extension GRPCCore.ServiceDescriptor { } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -internal protocol Grpc_Testing_BenchmarkServiceStreamingServiceProtocol: GRPCCore.RegistrableRPCService { +internal protocol Grpc_Testing_BenchmarkService_StreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse } /// Conformance to `GRPCCore.RegistrableRPCService`. @@ -198,75 +198,75 @@ extension Grpc_Testing_BenchmarkService.StreamingServiceProtocol { } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -internal protocol Grpc_Testing_BenchmarkServiceServiceProtocol: Grpc_Testing_BenchmarkService.StreamingServiceProtocol { +internal protocol Grpc_Testing_BenchmarkService_ServiceProtocol: Grpc_Testing_BenchmarkService.StreamingServiceProtocol { /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall( - request: GRPCCore.ServerRequest.Single, + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Single + ) async throws -> GRPCCore.ServerResponse /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Single + ) async throws -> GRPCCore.ServerResponse /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer( - request: GRPCCore.ServerRequest.Single, + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse } -/// Partial conformance to `Grpc_Testing_BenchmarkServiceStreamingServiceProtocol`. +/// Partial conformance to `Grpc_Testing_BenchmarkService_StreamingServiceProtocol`. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension Grpc_Testing_BenchmarkService.ServiceProtocol { internal func unaryCall( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream { + ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.unaryCall( - request: GRPCCore.ServerRequest.Single(stream: request), + request: GRPCCore.ServerRequest(stream: request), context: context ) - return GRPCCore.ServerResponse.Stream(single: response) + return GRPCCore.StreamingServerResponse(single: response) } internal func streamingFromClient( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream { + ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.streamingFromClient( request: request, context: context ) - return GRPCCore.ServerResponse.Stream(single: response) + return GRPCCore.StreamingServerResponse(single: response) } internal func streamingFromServer( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream { + ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.streamingFromServer( - request: GRPCCore.ServerRequest.Single(stream: request), + request: GRPCCore.ServerRequest(stream: request), context: context ) return response @@ -274,65 +274,65 @@ extension Grpc_Testing_BenchmarkService.ServiceProtocol { } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -internal protocol Grpc_Testing_BenchmarkServiceClientProtocol: Sendable { +internal protocol Grpc_Testing_BenchmarkService_ClientProtocol: Sendable { /// One request followed by one response. /// The server returns the client payload as-is. func unaryCall( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R ) async throws -> R where R: Sendable /// Repeated sequence of one request followed by one response. /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response func streamingCall( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone func streamingFromClient( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R ) async throws -> R where R: Sendable /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is func streamingFromServer( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other func streamingBothWays( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension Grpc_Testing_BenchmarkService.ClientProtocol { internal func unaryCall( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R = { + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { try $0.message } ) async throws -> R where R: Sendable { @@ -346,9 +346,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { } internal func streamingCall( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingCall( request: request, @@ -360,9 +360,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { } internal func streamingFromClient( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R = { + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { try $0.message } ) async throws -> R where R: Sendable { @@ -376,9 +376,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { } internal func streamingFromServer( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingFromServer( request: request, @@ -390,9 +390,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { } internal func streamingBothWays( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.streamingBothWays( request: request, @@ -412,11 +412,11 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { _ message: Grpc_Testing_SimpleRequest, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> Result = { + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { try $0.message } ) async throws -> Result where Result: Sendable { - let request = GRPCCore.ClientRequest.Single( + let request = GRPCCore.ClientRequest( message: message, metadata: metadata ) @@ -434,9 +434,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, requestProducer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> Result + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { - let request = GRPCCore.ClientRequest.Stream( + let request = GRPCCore.StreamingClientRequest( metadata: metadata, producer: requestProducer ) @@ -453,11 +453,11 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, requestProducer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> Result = { + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { try $0.message } ) async throws -> Result where Result: Sendable { - let request = GRPCCore.ClientRequest.Stream( + let request = GRPCCore.StreamingClientRequest( metadata: metadata, producer: requestProducer ) @@ -474,9 +474,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { _ message: Grpc_Testing_SimpleRequest, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> Result + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { - let request = GRPCCore.ClientRequest.Single( + let request = GRPCCore.ClientRequest( message: message, metadata: metadata ) @@ -493,9 +493,9 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, requestProducer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> Result + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { - let request = GRPCCore.ClientRequest.Stream( + let request = GRPCCore.StreamingClientRequest( metadata: metadata, producer: requestProducer ) @@ -508,7 +508,7 @@ extension Grpc_Testing_BenchmarkService.ClientProtocol { } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkService.ClientProtocol { +internal struct Grpc_Testing_BenchmarkService_Client: Grpc_Testing_BenchmarkService.ClientProtocol { private let client: GRPCCore.GRPCClient internal init(wrapping client: GRPCCore.GRPCClient) { @@ -518,11 +518,11 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi /// One request followed by one response. /// The server returns the client payload as-is. internal func unaryCall( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R = { + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { try $0.message } ) async throws -> R where R: Sendable { @@ -540,11 +540,11 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi /// Should be called streaming ping-pong /// The server returns the client payload as-is on each response internal func streamingCall( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.client.bidirectionalStreaming( request: request, @@ -559,11 +559,11 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi /// Single-sided unbounded streaming from client to server /// The server returns the client payload as-is once the client does WritesDone internal func streamingFromClient( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R = { + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { try $0.message } ) async throws -> R where R: Sendable { @@ -580,11 +580,11 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi /// Single-sided unbounded streaming from server to client /// The server repeatedly returns the client payload as-is internal func streamingFromServer( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.client.serverStreaming( request: request, @@ -599,11 +599,11 @@ internal struct Grpc_Testing_BenchmarkServiceClient: Grpc_Testing_BenchmarkServi /// Two-sided unbounded streaming between server to client /// Both sides send the content of their own choice to the other internal func streamingBothWays( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, serializer: some GRPCCore.MessageSerializer, deserializer: some GRPCCore.MessageDeserializer, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.client.bidirectionalStreaming( request: request, diff --git a/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_worker_service.grpc.swift b/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_worker_service.grpc.swift index 58bad0a..a3df96f 100644 --- a/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_worker_service.grpc.swift +++ b/IntegrationTests/grpc-performance-tests/Sources/Generated/grpc_testing_worker_service.grpc.swift @@ -70,9 +70,9 @@ internal enum Grpc_Testing_WorkerService { ] } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - internal typealias StreamingServiceProtocol = Grpc_Testing_WorkerServiceStreamingServiceProtocol + internal typealias StreamingServiceProtocol = Grpc_Testing_WorkerService_StreamingServiceProtocol @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - internal typealias ServiceProtocol = Grpc_Testing_WorkerServiceServiceProtocol + internal typealias ServiceProtocol = Grpc_Testing_WorkerService_ServiceProtocol } extension GRPCCore.ServiceDescriptor { @@ -83,7 +83,7 @@ extension GRPCCore.ServiceDescriptor { } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -internal protocol Grpc_Testing_WorkerServiceStreamingServiceProtocol: GRPCCore.RegistrableRPCService { +internal protocol Grpc_Testing_WorkerService_StreamingServiceProtocol: GRPCCore.RegistrableRPCService { /// Start server with specified workload. /// First request sent specifies the ServerConfig followed by ServerStatus /// response. After that, a "Mark" can be sent anytime to request the latest @@ -91,9 +91,9 @@ internal protocol Grpc_Testing_WorkerServiceStreamingServiceProtocol: GRPCCore.R /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runServer( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Start client with specified workload. /// First request sent specifies the ClientConfig followed by ClientStatus @@ -102,21 +102,21 @@ internal protocol Grpc_Testing_WorkerServiceStreamingServiceProtocol: GRPCCore.R /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runClient( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Just return the core count - unary call func coreCount( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Quit this worker func quitWorker( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse } /// Conformance to `GRPCCore.RegistrableRPCService`. @@ -172,7 +172,7 @@ extension Grpc_Testing_WorkerService.StreamingServiceProtocol { } @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -internal protocol Grpc_Testing_WorkerServiceServiceProtocol: Grpc_Testing_WorkerService.StreamingServiceProtocol { +internal protocol Grpc_Testing_WorkerService_ServiceProtocol: Grpc_Testing_WorkerService.StreamingServiceProtocol { /// Start server with specified workload. /// First request sent specifies the ServerConfig followed by ServerStatus /// response. After that, a "Mark" can be sent anytime to request the latest @@ -180,9 +180,9 @@ internal protocol Grpc_Testing_WorkerServiceServiceProtocol: Grpc_Testing_Worker /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runServer( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Start client with specified workload. /// First request sent specifies the ClientConfig followed by ClientStatus @@ -191,45 +191,45 @@ internal protocol Grpc_Testing_WorkerServiceServiceProtocol: Grpc_Testing_Worker /// and once the shutdown has finished, the OK status is sent to terminate /// this RPC. func runClient( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream + ) async throws -> GRPCCore.StreamingServerResponse /// Just return the core count - unary call func coreCount( - request: GRPCCore.ServerRequest.Single, + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Single + ) async throws -> GRPCCore.ServerResponse /// Quit this worker func quitWorker( - request: GRPCCore.ServerRequest.Single, + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Single + ) async throws -> GRPCCore.ServerResponse } -/// Partial conformance to `Grpc_Testing_WorkerServiceStreamingServiceProtocol`. +/// Partial conformance to `Grpc_Testing_WorkerService_StreamingServiceProtocol`. @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension Grpc_Testing_WorkerService.ServiceProtocol { internal func coreCount( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream { + ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.coreCount( - request: GRPCCore.ServerRequest.Single(stream: request), + request: GRPCCore.ServerRequest(stream: request), context: context ) - return GRPCCore.ServerResponse.Stream(single: response) + return GRPCCore.StreamingServerResponse(single: response) } internal func quitWorker( - request: GRPCCore.ServerRequest.Stream, + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse.Stream { + ) async throws -> GRPCCore.StreamingServerResponse { let response = try await self.quitWorker( - request: GRPCCore.ServerRequest.Single(stream: request), + request: GRPCCore.ServerRequest(stream: request), context: context ) - return GRPCCore.ServerResponse.Stream(single: response) + return GRPCCore.StreamingServerResponse(single: response) } } \ No newline at end of file diff --git a/IntegrationTests/grpc-performance-tests/Sources/WorkerService.swift b/IntegrationTests/grpc-performance-tests/Sources/WorkerService.swift index 1f0b71b..dc0bed9 100644 --- a/IntegrationTests/grpc-performance-tests/Sources/WorkerService.swift +++ b/IntegrationTests/grpc-performance-tests/Sources/WorkerService.swift @@ -222,9 +222,9 @@ final class WorkerService: Sendable { extension WorkerService: Grpc_Testing_WorkerService.ServiceProtocol { func quitWorker( - request: ServerRequest.Single, + request: ServerRequest, context: ServerContext - ) async throws -> ServerResponse.Single { + ) async throws -> ServerResponse { let onQuit = self.state.withLockedValue { $0.quit() } switch onQuit { @@ -240,15 +240,15 @@ extension WorkerService: Grpc_Testing_WorkerService.ServiceProtocol { server.beginGracefulShutdown() } - return ServerResponse.Single(message: Grpc_Testing_Void()) + return ServerResponse(message: Grpc_Testing_Void()) } func coreCount( - request: ServerRequest.Single, + request: ServerRequest, context: ServerContext - ) async throws -> ServerResponse.Single { + ) async throws -> ServerResponse { let coreCount = System.coreCount - return ServerResponse.Single( + return ServerResponse( message: Grpc_Testing_WorkerService.Method.CoreCount.Output.with { $0.cores = Int32(coreCount) } @@ -256,10 +256,10 @@ extension WorkerService: Grpc_Testing_WorkerService.ServiceProtocol { } func runServer( - request: ServerRequest.Stream, + request: StreamingServerRequest, context: ServerContext - ) async throws -> ServerResponse.Stream { - return ServerResponse.Stream { writer in + ) async throws -> StreamingServerResponse { + return StreamingServerResponse { writer in try await withThrowingTaskGroup(of: Void.self) { group in for try await message in request.messages { switch message.argtype { @@ -328,10 +328,10 @@ extension WorkerService: Grpc_Testing_WorkerService.ServiceProtocol { } func runClient( - request: ServerRequest.Stream, + request: StreamingServerRequest, context: ServerContext - ) async throws -> ServerResponse.Stream { - return ServerResponse.Stream { writer in + ) async throws -> StreamingServerResponse { + return StreamingServerResponse { writer in try await withThrowingTaskGroup(of: Void.self) { group in for try await message in request.messages { switch message.argtype { diff --git a/Tests/GRPCNIOTransportHTTP2Tests/ControlClient.swift b/Tests/GRPCNIOTransportHTTP2Tests/ControlClient.swift index 0ec9deb..e11da9b 100644 --- a/Tests/GRPCNIOTransportHTTP2Tests/ControlClient.swift +++ b/Tests/GRPCNIOTransportHTTP2Tests/ControlClient.swift @@ -25,9 +25,9 @@ internal struct ControlClient { } internal func unary( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R = + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { try $0.message } @@ -43,9 +43,9 @@ internal struct ControlClient { } internal func serverStream( - request: GRPCCore.ClientRequest.Single, + request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.client.serverStreaming( request: request, @@ -58,9 +58,9 @@ internal struct ControlClient { } internal func clientStream( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Single) async throws -> R = + _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { try $0.message } @@ -76,9 +76,9 @@ internal struct ControlClient { } internal func bidiStream( - request: GRPCCore.ClientRequest.Stream, + request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse.Stream) async throws -> R + _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R ) async throws -> R where R: Sendable { try await self.client.bidirectionalStreaming( request: request, diff --git a/Tests/GRPCNIOTransportHTTP2Tests/ControlService.swift b/Tests/GRPCNIOTransportHTTP2Tests/ControlService.swift index fa9ebf9..72c4325 100644 --- a/Tests/GRPCNIOTransportHTTP2Tests/ControlService.swift +++ b/Tests/GRPCNIOTransportHTTP2Tests/ControlService.swift @@ -58,13 +58,13 @@ struct ControlService: RegistrableRPCService { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension ControlService { private func handle( - request: ServerRequest.Stream - ) async throws -> ServerResponse.Stream { + request: StreamingServerRequest + ) async throws -> StreamingServerResponse { var iterator = request.messages.makeAsyncIterator() guard let message = try await iterator.next() else { // Empty input stream, empty output stream. - return ServerResponse.Stream { _ in [:] } + return StreamingServerResponse { _ in [:] } } // Check if the request is for a trailers-only response. @@ -90,7 +90,7 @@ extension ControlService { // iterator again from the current concurrency domain. let transfer = UnsafeTransfer(iterator) - return ServerResponse.Stream(metadata: metadata) { writer in + return StreamingServerResponse(metadata: metadata) { writer in // Finish dealing with the first message. switch try await self.processMessage(message, metadata: request.metadata, writer: writer) { case .return(let metadata): diff --git a/Tests/GRPCNIOTransportHTTP2Tests/HTTP2TransportTests.swift b/Tests/GRPCNIOTransportHTTP2Tests/HTTP2TransportTests.swift index a2e9977..34fd46a 100644 --- a/Tests/GRPCNIOTransportHTTP2Tests/HTTP2TransportTests.swift +++ b/Tests/GRPCNIOTransportHTTP2Tests/HTTP2TransportTests.swift @@ -240,7 +240,7 @@ final class HTTP2TransportTests: XCTestCase { } let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Single(message: input, metadata: metadata) + let request = ClientRequest(message: input, metadata: metadata) try await control.unary(request: request) { response in let message = try response.message @@ -273,7 +273,7 @@ final class HTTP2TransportTests: XCTestCase { } let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Single(message: input, metadata: metadata) + let request = ClientRequest(message: input, metadata: metadata) try await control.unary(request: request) { response in XCTAssertThrowsError(ofType: RPCError.self, try response.message) { error in @@ -294,7 +294,7 @@ final class HTTP2TransportTests: XCTestCase { // Client sends one message, server sends non-ok status with trailing metadata. try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Single( + let request = ClientRequest( message: .trailersOnly(code: .aborted, message: "\(#function)", echoMetadata: true), metadata: metadata ) @@ -320,7 +320,7 @@ final class HTTP2TransportTests: XCTestCase { func testClientStreamingOK() async throws { try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: metadata ) { writer in @@ -351,7 +351,7 @@ final class HTTP2TransportTests: XCTestCase { func testClientStreamingNotOK() async throws { try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: metadata ) { writer in @@ -388,7 +388,7 @@ final class HTTP2TransportTests: XCTestCase { // Client sends one message, server sends non-ok status with trailing metadata. try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: metadata ) { writer in @@ -432,7 +432,7 @@ final class HTTP2TransportTests: XCTestCase { } } - let request = ClientRequest.Single(message: input, metadata: metadata) + let request = ClientRequest(message: input, metadata: metadata) try await control.serverStream(request: request) { response in switch response.accepted { case .success(let contents): @@ -467,7 +467,7 @@ final class HTTP2TransportTests: XCTestCase { $0.echoMetadataInTrailers = true } - let request = ClientRequest.Single(message: input, metadata: metadata) + let request = ClientRequest(message: input, metadata: metadata) try await control.serverStream(request: request) { response in switch response.accepted { case .success(let contents): @@ -506,7 +506,7 @@ final class HTTP2TransportTests: XCTestCase { } } - let request = ClientRequest.Single(message: input, metadata: metadata) + let request = ClientRequest(message: input, metadata: metadata) try await control.serverStream(request: request) { response in switch response.accepted { case .success(let contents): @@ -551,7 +551,7 @@ final class HTTP2TransportTests: XCTestCase { } } - let request = ClientRequest.Single(message: input, metadata: metadata) + let request = ClientRequest(message: input, metadata: metadata) try await control.serverStream(request: request) { response in switch response.accepted { case .success(let contents): @@ -578,7 +578,7 @@ final class HTTP2TransportTests: XCTestCase { func testServerStreamingRejected() async throws { try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Single( + let request = ClientRequest( message: .trailersOnly(code: .aborted, message: "\(#function)", echoMetadata: true), metadata: metadata ) @@ -599,7 +599,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingOK() async throws { try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: metadata ) { writer in @@ -638,7 +638,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingEmptyOK() async throws { try await self.forEachTransportPair { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { _ in } + let request = StreamingClientRequest(of: ControlInput.self) { _ in } try await control.bidiStream(request: request) { response in switch response.accepted { case .success(let contents): @@ -662,7 +662,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingNotOK() async throws { try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: metadata ) { writer in @@ -710,7 +710,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingRejected() async throws { try await self.forEachTransportPair { control, pair in let metadata: Metadata = ["test-key": "test-value"] - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: metadata ) { writer in @@ -740,7 +740,7 @@ final class HTTP2TransportTests: XCTestCase { func testUnaryNotImplemented() async throws { try await self.forEachTransportPair(enableControlService: false) { control, pair in - let request = ClientRequest.Single(message: ControlInput()) + let request = ClientRequest(message: ControlInput()) try await control.unary(request: request) { response in XCTAssertThrowsError(ofType: RPCError.self, try response.message) { error in XCTAssertEqual(error.code, .unimplemented) @@ -751,7 +751,7 @@ final class HTTP2TransportTests: XCTestCase { func testClientStreamingNotImplemented() async throws { try await self.forEachTransportPair(enableControlService: false) { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { _ in } + let request = StreamingClientRequest(of: ControlInput.self) { _ in } try await control.clientStream(request: request) { response in XCTAssertThrowsError(ofType: RPCError.self, try response.message) { error in XCTAssertEqual(error.code, .unimplemented) @@ -762,7 +762,7 @@ final class HTTP2TransportTests: XCTestCase { func testServerStreamingNotImplemented() async throws { try await self.forEachTransportPair(enableControlService: false) { control, pair in - let request = ClientRequest.Single(message: ControlInput()) + let request = ClientRequest(message: ControlInput()) try await control.serverStream(request: request) { response in XCTAssertThrowsError(ofType: RPCError.self, try response.accepted.get()) { error in XCTAssertEqual(error.code, .unimplemented) @@ -773,7 +773,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingNotImplemented() async throws { try await self.forEachTransportPair(enableControlService: false) { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { _ in } + let request = StreamingClientRequest(of: ControlInput.self) { _ in } try await control.bidiStream(request: request) { response in XCTAssertThrowsError(ofType: RPCError.self, try response.accepted.get()) { error in XCTAssertEqual(error.code, .unimplemented) @@ -803,7 +803,7 @@ final class HTTP2TransportTests: XCTestCase { options.compression = client try await control.unary( - request: ClientRequest.Single(message: message), + request: ClientRequest(message: message), options: options ) { response in // Check the client algorithm. @@ -840,7 +840,7 @@ final class HTTP2TransportTests: XCTestCase { control: ControlClient, pair: Transport ) async throws { - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in try await writer.write(.echoMetadata) try await writer.write(.noOp) try await writer.write(.noOp) @@ -898,7 +898,7 @@ final class HTTP2TransportTests: XCTestCase { options.compression = client try await control.serverStream( - request: ClientRequest.Single(message: message), + request: ClientRequest(message: message), options: options ) { response in // Check the client algorithm. @@ -936,7 +936,7 @@ final class HTTP2TransportTests: XCTestCase { control: ControlClient, pair: Transport ) async throws { - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in try await writer.write(.echoMetadata) try await writer.write(.messages(1, repeating: 42, count: 1024)) try await writer.write(.messages(1, repeating: 42, count: 1024)) @@ -1108,7 +1108,7 @@ final class HTTP2TransportTests: XCTestCase { $0.size = 1024 } } - let request = ClientRequest.Single(message: message) + let request = ClientRequest(message: message) var options = CallOptions.defaults options.compression = .deflate @@ -1131,7 +1131,7 @@ final class HTTP2TransportTests: XCTestCase { clientEnabledCompression: .all, serverCompression: .gzip ) { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in try await writer.write(.noOp) } @@ -1163,7 +1163,7 @@ final class HTTP2TransportTests: XCTestCase { $0.size = 1024 } } - let request = ClientRequest.Single(message: message) + let request = ClientRequest(message: message) var options = CallOptions.defaults options.compression = .deflate @@ -1186,7 +1186,7 @@ final class HTTP2TransportTests: XCTestCase { clientEnabledCompression: .all, serverCompression: .gzip ) { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in try await writer.write(.noOp) } @@ -1213,7 +1213,7 @@ final class HTTP2TransportTests: XCTestCase { $0.numberOfMessages = 1 } - let request = ClientRequest.Single(message: message) + let request = ClientRequest(message: message) var options = CallOptions.defaults options.timeout = .seconds(10) try await control.unary(request: request, options: options) { response in @@ -1225,7 +1225,7 @@ final class HTTP2TransportTests: XCTestCase { func testClientStreamingTimeoutPropagatedToServer() async throws { try await self.forEachTransportPair { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in let message = ControlInput.with { $0.echoMetadataInHeaders = true $0.numberOfMessages = 1 @@ -1249,7 +1249,7 @@ final class HTTP2TransportTests: XCTestCase { $0.numberOfMessages = 1 } - let request = ClientRequest.Single(message: message) + let request = ClientRequest(message: message) var options = CallOptions.defaults options.timeout = .seconds(10) try await control.serverStream(request: request, options: options) { response in @@ -1261,7 +1261,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingTimeoutPropagatedToServer() async throws { try await self.forEachTransportPair { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in try await writer.write(.echoMetadata) } @@ -1295,7 +1295,7 @@ final class HTTP2TransportTests: XCTestCase { let metadata: Metadata = ["response-status": "\(httpCode)"] try await control.unary( - request: ClientRequest.Single(message: .noOp, metadata: metadata) + request: ClientRequest(message: .noOp, metadata: metadata) ) { response in switch response.accepted { case .success: @@ -1312,7 +1312,7 @@ final class HTTP2TransportTests: XCTestCase { try await self.forEachClientAndHTTPStatusCodeServer { control, kind in for (httpCode, expectedStatus) in Self.httpToStatusCodePairs { // Tell the server what to respond with. - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: ["response-status": "\(httpCode)"] ) { _ in @@ -1337,7 +1337,7 @@ final class HTTP2TransportTests: XCTestCase { let metadata: Metadata = ["response-status": "\(httpCode)"] try await control.serverStream( - request: ClientRequest.Single(message: .noOp, metadata: metadata) + request: ClientRequest(message: .noOp, metadata: metadata) ) { response in switch response.accepted { case .success: @@ -1354,7 +1354,7 @@ final class HTTP2TransportTests: XCTestCase { try await self.forEachClientAndHTTPStatusCodeServer { control, kind in for (httpCode, expectedStatus) in Self.httpToStatusCodePairs { // Tell the server what to respond with. - let request = ClientRequest.Stream( + let request = StreamingClientRequest( of: ControlInput.self, metadata: ["response-status": "\(httpCode)"] ) { _ in @@ -1378,7 +1378,7 @@ final class HTTP2TransportTests: XCTestCase { $0.echoMetadataInHeaders = true $0.numberOfMessages = 1 } - let request = ClientRequest.Single(message: input) + let request = ClientRequest(message: input) try await control.unary(request: request) { response in XCTAssertEqual(Array(response.metadata["echo-scheme"]), ["http"]) } @@ -1391,7 +1391,7 @@ final class HTTP2TransportTests: XCTestCase { $0.echoMetadataInHeaders = true $0.numberOfMessages = 1 } - let request = ClientRequest.Single(message: input) + let request = ClientRequest(message: input) try await control.serverStream(request: request) { response in XCTAssertEqual(Array(response.metadata["echo-scheme"]), ["http"]) } @@ -1400,7 +1400,7 @@ final class HTTP2TransportTests: XCTestCase { func testClientStreamingScheme() async throws { try await self.forEachTransportPair { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in let input = ControlInput.with { $0.echoMetadataInHeaders = true $0.numberOfMessages = 1 @@ -1415,7 +1415,7 @@ final class HTTP2TransportTests: XCTestCase { func testBidiStreamingScheme() async throws { try await self.forEachTransportPair { control, pair in - let request = ClientRequest.Stream(of: ControlInput.self) { writer in + let request = StreamingClientRequest(of: ControlInput.self) { writer in let input = ControlInput.with { $0.echoMetadataInHeaders = true $0.numberOfMessages = 1