diff --git a/Sources/GRPCHealthService/Generated/health.grpc.swift b/Sources/GRPCHealthService/Generated/health.grpc.swift index 696532a..4856ae5 100644 --- a/Sources/GRPCHealthService/Generated/health.grpc.swift +++ b/Sources/GRPCHealthService/Generated/health.grpc.swift @@ -26,92 +26,280 @@ package import GRPCCore internal import GRPCProtobuf +package import SwiftProtobuf +// MARK: - grpc.health.v1.Health + +/// Namespace containing generated types for the "grpc.health.v1.Health" service. package enum Grpc_Health_V1_Health { - package static let descriptor = GRPCCore.ServiceDescriptor.grpc_health_v1_Health + /// Service descriptor for the "grpc.health.v1.Health" service. + package static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.health.v1.Health") + /// Namespace for method metadata. package enum Method { + /// Namespace for "Check" metadata. package enum Check { + /// Request type for "Check". package typealias Input = Grpc_Health_V1_HealthCheckRequest + /// Response type for "Check". package typealias Output = Grpc_Health_V1_HealthCheckResponse + /// Descriptor for "Check". package static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Health_V1_Health.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.health.v1.Health"), method: "Check" ) } + /// Namespace for "Watch" metadata. package enum Watch { + /// Request type for "Watch". package typealias Input = Grpc_Health_V1_HealthCheckRequest + /// Response type for "Watch". package typealias Output = Grpc_Health_V1_HealthCheckResponse + /// Descriptor for "Watch". package static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Health_V1_Health.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.health.v1.Health"), method: "Watch" ) } + /// Descriptors for all methods in the "grpc.health.v1.Health" service. package static let descriptors: [GRPCCore.MethodDescriptor] = [ Check.descriptor, Watch.descriptor ] } - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - package typealias StreamingServiceProtocol = Grpc_Health_V1_Health_StreamingServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - package typealias ServiceProtocol = Grpc_Health_V1_Health_ServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - package typealias ClientProtocol = Grpc_Health_V1_Health_ClientProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - package typealias Client = Grpc_Health_V1_Health_Client } extension GRPCCore.ServiceDescriptor { - package static let grpc_health_v1_Health = Self( - package: "grpc.health.v1", - service: "Health" - ) + /// Service descriptor for the "grpc.health.v1.Health" service. + package static let grpc_health_v1_Health = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.health.v1.Health") } -/// Health is gRPC's mechanism for checking whether a server is able to handle -/// RPCs. Its semantics are documented in -/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -package protocol Grpc_Health_V1_Health_StreamingServiceProtocol: GRPCCore.RegistrableRPCService { - /// Check gets the health of the specified service. If the requested service - /// is unknown, the call will fail with status NOT_FOUND. If the caller does - /// not specify a service name, the server should respond with its overall - /// health status. +// MARK: grpc.health.v1.Health (server) + +extension Grpc_Health_V1_Health { + /// Streaming variant of the service protocol for the "grpc.health.v1.Health" service. /// - /// Clients should set a deadline when calling Check, and can declare the - /// server unhealthy if they do not receive a timely response. + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. /// - /// Check implementations should be idempotent and side effect free. - func check( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > Health is gRPC's mechanism for checking whether a server is able to handle + /// > RPCs. Its semantics are documented in + /// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md. + package protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Check" method. + /// + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Health_V1_HealthCheckRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Health_V1_HealthCheckResponse` messages. + func check( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Watch" method. + /// + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Health_V1_HealthCheckRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Health_V1_HealthCheckResponse` messages. + func watch( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "grpc.health.v1.Health" service. /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. - func watch( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse + /// > Source IDL Documentation: + /// > + /// > Health is gRPC's mechanism for checking whether a server is able to handle + /// > RPCs. Its semantics are documented in + /// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md. + package protocol ServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol { + /// Handle the "Check" method. + /// + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Health_V1_HealthCheckResponse` message. + func check( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Watch" method. + /// + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Health_V1_HealthCheckResponse` messages. + func watch( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Simple service protocol for the "grpc.health.v1.Health" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > Health is gRPC's mechanism for checking whether a server is able to handle + /// > RPCs. Its semantics are documented in + /// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md. + package protocol SimpleServiceProtocol: Grpc_Health_V1_Health.ServiceProtocol { + /// Handle the "Check" method. + /// + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. + /// + /// - Parameters: + /// - request: A `Grpc_Health_V1_HealthCheckRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Health_V1_HealthCheckResponse` to respond with. + func check( + request: Grpc_Health_V1_HealthCheckRequest, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Health_V1_HealthCheckResponse + + /// Handle the "Watch" method. + /// + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. + /// + /// - Parameters: + /// - request: A `Grpc_Health_V1_HealthCheckRequest` message. + /// - response: A response stream of `Grpc_Health_V1_HealthCheckResponse` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + func watch( + request: Grpc_Health_V1_HealthCheckRequest, + response: GRPCCore.RPCWriter, + context: GRPCCore.ServerContext + ) async throws + } } -/// Conformance to `GRPCCore.RegistrableRPCService`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Default implementation of 'registerMethods(with:)'. extension Grpc_Health_V1_Health.StreamingServiceProtocol { - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) package func registerMethods(with router: inout GRPCCore.RPCRouter) { router.registerHandler( forMethod: Grpc_Health_V1_Health.Method.Check.descriptor, @@ -138,48 +326,7 @@ extension Grpc_Health_V1_Health.StreamingServiceProtocol { } } -/// Health is gRPC's mechanism for checking whether a server is able to handle -/// RPCs. Its semantics are documented in -/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -package protocol Grpc_Health_V1_Health_ServiceProtocol: Grpc_Health_V1_Health.StreamingServiceProtocol { - /// Check gets the health of the specified service. If the requested service - /// is unknown, the call will fail with status NOT_FOUND. If the caller does - /// not specify a service name, the server should respond with its overall - /// health status. - /// - /// Clients should set a deadline when calling Check, and can declare the - /// server unhealthy if they do not receive a timely response. - /// - /// Check implementations should be idempotent and side effect free. - func check( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse - - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. - /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. - /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. - func watch( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse -} - -/// Partial conformance to `Grpc_Health_V1_Health_StreamingServiceProtocol`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Default implementation of streaming methods from 'StreamingServiceProtocol'. extension Grpc_Health_V1_Health.ServiceProtocol { package func check( request: GRPCCore.StreamingServerRequest, @@ -191,7 +338,7 @@ extension Grpc_Health_V1_Health.ServiceProtocol { ) return GRPCCore.StreamingServerResponse(single: response) } - + package func watch( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext @@ -204,102 +351,345 @@ extension Grpc_Health_V1_Health.ServiceProtocol { } } -/// Health is gRPC's mechanism for checking whether a server is able to handle -/// RPCs. Its semantics are documented in -/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -package protocol Grpc_Health_V1_Health_ClientProtocol: Sendable { - /// Check gets the health of the specified service. If the requested service - /// is unknown, the call will fail with status NOT_FOUND. If the caller does - /// not specify a service name, the server should respond with its overall - /// health status. +// Default implementation of methods from 'ServiceProtocol'. +extension Grpc_Health_V1_Health.SimpleServiceProtocol { + package func check( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.check( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + package func watch( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + return GRPCCore.StreamingServerResponse( + metadata: [:], + producer: { writer in + try await self.watch( + request: request.message, + response: writer, + context: context + ) + return [:] + } + ) + } +} + +// MARK: grpc.health.v1.Health (client) + +extension Grpc_Health_V1_Health { + /// Generated client protocol for the "grpc.health.v1.Health" service. /// - /// Clients should set a deadline when calling Check, and can declare the - /// server unhealthy if they do not receive a timely response. + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. /// - /// Check implementations should be idempotent and side effect free. - func check( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. + /// > Source IDL Documentation: + /// > + /// > Health is gRPC's mechanism for checking whether a server is able to handle + /// > RPCs. Its semantics are documented in + /// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md. + package protocol ClientProtocol: Sendable { + /// Call the "Check" method. + /// + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - serializer: A serializer for `Grpc_Health_V1_HealthCheckRequest` messages. + /// - deserializer: A deserializer for `Grpc_Health_V1_HealthCheckResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func check( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Watch" method. + /// + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - serializer: A serializer for `Grpc_Health_V1_HealthCheckRequest` messages. + /// - deserializer: A deserializer for `Grpc_Health_V1_HealthCheckResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func watch( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "grpc.health.v1.Health" service. /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. - func watch( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable + /// > Source IDL Documentation: + /// > + /// > Health is gRPC's mechanism for checking whether a server is able to handle + /// > RPCs. Its semantics are documented in + /// > https://github.com/grpc/grpc/blob/master/doc/health-checking.md. + package struct Client: ClientProtocol { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + package init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Check" method. + /// + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - serializer: A serializer for `Grpc_Health_V1_HealthCheckRequest` messages. + /// - deserializer: A deserializer for `Grpc_Health_V1_HealthCheckResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + package func check( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Health_V1_Health.Method.Check.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Watch" method. + /// + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - serializer: A serializer for `Grpc_Health_V1_HealthCheckRequest` messages. + /// - deserializer: A deserializer for `Grpc_Health_V1_HealthCheckResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + package func watch( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.client.serverStreaming( + request: request, + descriptor: Grpc_Health_V1_Health.Method.Watch.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing default arguments to 'ClientProtocol' methods. extension Grpc_Health_V1_Health.ClientProtocol { - package func check( + /// Call the "Check" method. + /// + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + package func check( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } - ) async throws -> R where R: Sendable { + ) async throws -> Result where Result: Sendable { try await self.check( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } - - package func watch( + + /// Call the "Watch" method. + /// + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Health_V1_HealthCheckRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + package func watch( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { try await self.watch( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing sugared APIs for 'ClientProtocol' methods. extension Grpc_Health_V1_Health.ClientProtocol { - /// Check gets the health of the specified service. If the requested service - /// is unknown, the call will fail with status NOT_FOUND. If the caller does - /// not specify a service name, the server should respond with its overall - /// health status. + /// Call the "Check" method. /// - /// Clients should set a deadline when calling Check, and can declare the - /// server unhealthy if they do not receive a timely response. + /// > Source IDL Documentation: + /// > + /// > Check gets the health of the specified service. If the requested service + /// > is unknown, the call will fail with status NOT_FOUND. If the caller does + /// > not specify a service name, the server should respond with its overall + /// > health status. + /// > + /// > Clients should set a deadline when calling Check, and can declare the + /// > server unhealthy if they do not receive a timely response. + /// > + /// > Check implementations should be idempotent and side effect free. /// - /// Check implementations should be idempotent and side effect free. + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. package func check( _ message: Grpc_Health_V1_HealthCheckRequest, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -309,25 +699,38 @@ extension Grpc_Health_V1_Health.ClientProtocol { return try await self.check( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. + + /// Call the "Watch" method. /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. + /// > Source IDL Documentation: + /// > + /// > Performs a watch for the serving status of the requested service. + /// > The server will immediately send back a message indicating the current + /// > serving status. It will then subsequently send a new message whenever + /// > the service's serving status changes. + /// > + /// > If the requested service is unknown when the call is received, the + /// > server will send a message setting the serving status to + /// > SERVICE_UNKNOWN but will *not* terminate the call. If at some + /// > future point, the serving status of the service becomes known, the + /// > server will send a new message with the service's serving status. + /// > + /// > If the call terminates with status UNIMPLEMENTED, then clients + /// > should assume this method is not supported and should not retry the + /// > call. If the call terminates with any other status (including OK), + /// > clients should retry the call with appropriate exponential backoff. /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. package func watch( _ message: Grpc_Health_V1_HealthCheckRequest, metadata: GRPCCore.Metadata = [:], @@ -341,79 +744,7 @@ extension Grpc_Health_V1_Health.ClientProtocol { return try await self.watch( request: request, options: options, - handleResponse - ) - } -} - -/// Health is gRPC's mechanism for checking whether a server is able to handle -/// RPCs. Its semantics are documented in -/// https://github.com/grpc/grpc/blob/master/doc/health-checking.md. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -package struct Grpc_Health_V1_Health_Client: Grpc_Health_V1_Health.ClientProtocol { - private let client: GRPCCore.GRPCClient - - package init(wrapping client: GRPCCore.GRPCClient) { - self.client = client - } - - /// Check gets the health of the specified service. If the requested service - /// is unknown, the call will fail with status NOT_FOUND. If the caller does - /// not specify a service name, the server should respond with its overall - /// health status. - /// - /// Clients should set a deadline when calling Check, and can declare the - /// server unhealthy if they do not receive a timely response. - /// - /// Check implementations should be idempotent and side effect free. - package func check( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Health_V1_Health.Method.Check.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) - } - - /// Performs a watch for the serving status of the requested service. - /// The server will immediately send back a message indicating the current - /// serving status. It will then subsequently send a new message whenever - /// the service's serving status changes. - /// - /// If the requested service is unknown when the call is received, the - /// server will send a message setting the serving status to - /// SERVICE_UNKNOWN but will *not* terminate the call. If at some - /// future point, the serving status of the service becomes known, the - /// server will send a new message with the service's serving status. - /// - /// If the call terminates with status UNIMPLEMENTED, then clients - /// should assume this method is not supported and should not retry the - /// call. If the call terminates with any other status (including OK), - /// clients should retry the call with appropriate exponential backoff. - package func watch( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { - try await self.client.serverStreaming( - request: request, - descriptor: Grpc_Health_V1_Health.Method.Watch.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body + onResponse: handleResponse ) } } \ No newline at end of file diff --git a/Sources/GRPCHealthService/HealthService.swift b/Sources/GRPCHealthService/HealthService.swift index c9111c6..f548840 100644 --- a/Sources/GRPCHealthService/HealthService.swift +++ b/Sources/GRPCHealthService/HealthService.swift @@ -17,7 +17,7 @@ internal import GRPCCore private import Synchronization -internal struct HealthService: Grpc_Health_V1_Health_ServiceProtocol { +internal struct HealthService: Grpc_Health_V1_Health.ServiceProtocol { private let state = HealthService.State() func check( diff --git a/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift b/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift index 89133fa..36b43a0 100644 --- a/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift +++ b/Sources/GRPCInteropTests/Generated/empty_service.grpc.swift @@ -23,71 +23,127 @@ public import GRPCCore internal import GRPCProtobuf +public import SwiftProtobuf +// MARK: - grpc.testing.EmptyService + +/// Namespace containing generated types for the "grpc.testing.EmptyService" service. public enum Grpc_Testing_EmptyService { - public static let descriptor = GRPCCore.ServiceDescriptor.grpc_testing_EmptyService + /// Service descriptor for the "grpc.testing.EmptyService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.EmptyService") + /// Namespace for method metadata. public enum Method { + /// Descriptors for all methods in the "grpc.testing.EmptyService" service. public static let descriptors: [GRPCCore.MethodDescriptor] = [] } - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias StreamingServiceProtocol = Grpc_Testing_EmptyService_StreamingServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ServiceProtocol = Grpc_Testing_EmptyService_ServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ClientProtocol = Grpc_Testing_EmptyService_ClientProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias Client = Grpc_Testing_EmptyService_Client } extension GRPCCore.ServiceDescriptor { - public static let grpc_testing_EmptyService = Self( - package: "grpc.testing", - service: "EmptyService" - ) + /// Service descriptor for the "grpc.testing.EmptyService" service. + public static let grpc_testing_EmptyService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.EmptyService") } -/// A service that has zero methods. -/// See https://github.com/grpc/grpc/issues/15574 -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_EmptyService_StreamingServiceProtocol: GRPCCore.RegistrableRPCService {} +// MARK: grpc.testing.EmptyService (server) + +extension Grpc_Testing_EmptyService { + /// Streaming variant of the service protocol for the "grpc.testing.EmptyService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A service that has zero methods. + /// > See https://github.com/grpc/grpc/issues/15574 + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {} -/// Conformance to `GRPCCore.RegistrableRPCService`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) + /// Service protocol for the "grpc.testing.EmptyService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + /// + /// > Source IDL Documentation: + /// > + /// > A service that has zero methods. + /// > See https://github.com/grpc/grpc/issues/15574 + public protocol ServiceProtocol: Grpc_Testing_EmptyService.StreamingServiceProtocol {} + + /// Simple service protocol for the "grpc.testing.EmptyService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A service that has zero methods. + /// > See https://github.com/grpc/grpc/issues/15574 + public protocol SimpleServiceProtocol: Grpc_Testing_EmptyService.ServiceProtocol {} +} + +// Default implementation of 'registerMethods(with:)'. extension Grpc_Testing_EmptyService.StreamingServiceProtocol { - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public func registerMethods(with router: inout GRPCCore.RPCRouter) {} } -/// A service that has zero methods. -/// See https://github.com/grpc/grpc/issues/15574 -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_EmptyService_ServiceProtocol: Grpc_Testing_EmptyService.StreamingServiceProtocol {} - -/// Partial conformance to `Grpc_Testing_EmptyService_StreamingServiceProtocol`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Default implementation of streaming methods from 'StreamingServiceProtocol'. extension Grpc_Testing_EmptyService.ServiceProtocol { } -/// A service that has zero methods. -/// See https://github.com/grpc/grpc/issues/15574 -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_EmptyService_ClientProtocol: Sendable {} +// Default implementation of methods from 'ServiceProtocol'. +extension Grpc_Testing_EmptyService.SimpleServiceProtocol { +} + +// MARK: grpc.testing.EmptyService (client) -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -extension Grpc_Testing_EmptyService.ClientProtocol { +extension Grpc_Testing_EmptyService { + /// Generated client protocol for the "grpc.testing.EmptyService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > A service that has zero methods. + /// > See https://github.com/grpc/grpc/issues/15574 + public protocol ClientProtocol: Sendable {} + + /// Generated client for the "grpc.testing.EmptyService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > A service that has zero methods. + /// > See https://github.com/grpc/grpc/issues/15574 + public struct Client: ClientProtocol { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing default arguments to 'ClientProtocol' methods. extension Grpc_Testing_EmptyService.ClientProtocol { } -/// A service that has zero methods. -/// See https://github.com/grpc/grpc/issues/15574 -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public struct Grpc_Testing_EmptyService_Client: Grpc_Testing_EmptyService.ClientProtocol { - private let client: GRPCCore.GRPCClient - - public init(wrapping client: GRPCCore.GRPCClient) { - self.client = client - } +// Helpers providing sugared APIs for 'ClientProtocol' methods. +extension Grpc_Testing_EmptyService.ClientProtocol { } \ No newline at end of file diff --git a/Sources/GRPCInteropTests/Generated/test.grpc.swift b/Sources/GRPCInteropTests/Generated/test.grpc.swift index 177b6be..b3d883f 100644 --- a/Sources/GRPCInteropTests/Generated/test.grpc.swift +++ b/Sources/GRPCInteropTests/Generated/test.grpc.swift @@ -26,115 +26,113 @@ public import GRPCCore internal import GRPCProtobuf +public import SwiftProtobuf -public enum Grpc_Testing_ReconnectService { - public static let descriptor = GRPCCore.ServiceDescriptor.grpc_testing_ReconnectService - public enum Method { - public enum Start { - public typealias Input = Grpc_Testing_ReconnectParams - public typealias Output = Grpc_Testing_Empty - public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_ReconnectService.descriptor.fullyQualifiedService, - method: "Start" - ) - } - public enum Stop { - public typealias Input = Grpc_Testing_Empty - public typealias Output = Grpc_Testing_ReconnectInfo - public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_ReconnectService.descriptor.fullyQualifiedService, - method: "Stop" - ) - } - public static let descriptors: [GRPCCore.MethodDescriptor] = [ - Start.descriptor, - Stop.descriptor - ] - } - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias StreamingServiceProtocol = Grpc_Testing_ReconnectService_StreamingServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ServiceProtocol = Grpc_Testing_ReconnectService_ServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ClientProtocol = Grpc_Testing_ReconnectService_ClientProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias Client = Grpc_Testing_ReconnectService_Client -} - -extension GRPCCore.ServiceDescriptor { - public static let grpc_testing_ReconnectService = Self( - package: "grpc.testing", - service: "ReconnectService" - ) -} +// MARK: - grpc.testing.TestService +/// Namespace containing generated types for the "grpc.testing.TestService" service. public enum Grpc_Testing_TestService { - public static let descriptor = GRPCCore.ServiceDescriptor.grpc_testing_TestService + /// Service descriptor for the "grpc.testing.TestService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService") + /// Namespace for method metadata. public enum Method { + /// Namespace for "EmptyCall" metadata. public enum EmptyCall { + /// Request type for "EmptyCall". public typealias Input = Grpc_Testing_Empty + /// Response type for "EmptyCall". public typealias Output = Grpc_Testing_Empty + /// Descriptor for "EmptyCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "EmptyCall" ) } + /// Namespace for "UnaryCall" metadata. public enum UnaryCall { + /// Request type for "UnaryCall". public typealias Input = Grpc_Testing_SimpleRequest + /// Response type for "UnaryCall". public typealias Output = Grpc_Testing_SimpleResponse + /// Descriptor for "UnaryCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "UnaryCall" ) } + /// Namespace for "CacheableUnaryCall" metadata. public enum CacheableUnaryCall { + /// Request type for "CacheableUnaryCall". public typealias Input = Grpc_Testing_SimpleRequest + /// Response type for "CacheableUnaryCall". public typealias Output = Grpc_Testing_SimpleResponse + /// Descriptor for "CacheableUnaryCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "CacheableUnaryCall" ) } + /// Namespace for "StreamingOutputCall" metadata. public enum StreamingOutputCall { + /// Request type for "StreamingOutputCall". public typealias Input = Grpc_Testing_StreamingOutputCallRequest + /// Response type for "StreamingOutputCall". public typealias Output = Grpc_Testing_StreamingOutputCallResponse + /// Descriptor for "StreamingOutputCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "StreamingOutputCall" ) } + /// Namespace for "StreamingInputCall" metadata. public enum StreamingInputCall { + /// Request type for "StreamingInputCall". public typealias Input = Grpc_Testing_StreamingInputCallRequest + /// Response type for "StreamingInputCall". public typealias Output = Grpc_Testing_StreamingInputCallResponse + /// Descriptor for "StreamingInputCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "StreamingInputCall" ) } + /// Namespace for "FullDuplexCall" metadata. public enum FullDuplexCall { + /// Request type for "FullDuplexCall". public typealias Input = Grpc_Testing_StreamingOutputCallRequest + /// Response type for "FullDuplexCall". public typealias Output = Grpc_Testing_StreamingOutputCallResponse + /// Descriptor for "FullDuplexCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "FullDuplexCall" ) } + /// Namespace for "HalfDuplexCall" metadata. public enum HalfDuplexCall { + /// Request type for "HalfDuplexCall". public typealias Input = Grpc_Testing_StreamingOutputCallRequest + /// Response type for "HalfDuplexCall". public typealias Output = Grpc_Testing_StreamingOutputCallResponse + /// Descriptor for "HalfDuplexCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "HalfDuplexCall" ) } + /// Namespace for "UnimplementedCall" metadata. public enum UnimplementedCall { + /// Request type for "UnimplementedCall". public typealias Input = Grpc_Testing_Empty + /// Response type for "UnimplementedCall". public typealias Output = Grpc_Testing_Empty + /// Descriptor for "UnimplementedCall". public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_TestService.descriptor.fullyQualifiedService, + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService"), method: "UnimplementedCall" ) } + /// Descriptors for all methods in the "grpc.testing.TestService" service. public static let descriptors: [GRPCCore.MethodDescriptor] = [ EmptyCall.descriptor, UnaryCall.descriptor, @@ -146,122 +144,527 @@ public enum Grpc_Testing_TestService { UnimplementedCall.descriptor ] } - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias StreamingServiceProtocol = Grpc_Testing_TestService_StreamingServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ServiceProtocol = Grpc_Testing_TestService_ServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ClientProtocol = Grpc_Testing_TestService_ClientProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias Client = Grpc_Testing_TestService_Client } extension GRPCCore.ServiceDescriptor { - public static let grpc_testing_TestService = Self( - package: "grpc.testing", - service: "TestService" - ) + /// Service descriptor for the "grpc.testing.TestService" service. + public static let grpc_testing_TestService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.TestService") } -public enum Grpc_Testing_UnimplementedService { - public static let descriptor = GRPCCore.ServiceDescriptor.grpc_testing_UnimplementedService - public enum Method { - public enum UnimplementedCall { - public typealias Input = Grpc_Testing_Empty - public typealias Output = Grpc_Testing_Empty - public static let descriptor = GRPCCore.MethodDescriptor( - service: Grpc_Testing_UnimplementedService.descriptor.fullyQualifiedService, - method: "UnimplementedCall" - ) - } - public static let descriptors: [GRPCCore.MethodDescriptor] = [ - UnimplementedCall.descriptor - ] +// MARK: grpc.testing.TestService (server) + +extension Grpc_Testing_TestService { + /// Streaming variant of the service protocol for the "grpc.testing.TestService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service to test the various types of RPCs and experiment with + /// > performance with various types of payload. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_Empty` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_Empty` messages. + func emptyCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_SimpleRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_SimpleResponse` messages. + func unaryCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_SimpleRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_SimpleResponse` messages. + func cacheableUnaryCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingOutputCallResponse` messages. + func streamingOutputCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingInputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingInputCallResponse` messages. + func streamingInputCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingOutputCallResponse` messages. + func fullDuplexCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingOutputCallResponse` messages. + func halfDuplexCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_Empty` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_Empty` messages. + func unimplementedCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse } - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias StreamingServiceProtocol = Grpc_Testing_UnimplementedService_StreamingServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ServiceProtocol = Grpc_Testing_UnimplementedService_ServiceProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias ClientProtocol = Grpc_Testing_UnimplementedService_ClientProtocol - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public typealias Client = Grpc_Testing_UnimplementedService_Client -} -extension GRPCCore.ServiceDescriptor { - public static let grpc_testing_UnimplementedService = Self( - package: "grpc.testing", - service: "UnimplementedService" - ) -} + /// Service protocol for the "grpc.testing.TestService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service to test the various types of RPCs and experiment with + /// > performance with various types of payload. + public protocol ServiceProtocol: Grpc_Testing_TestService.StreamingServiceProtocol { + /// Handle the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_Empty` message. + func emptyCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse -/// A simple service to test the various types of RPCs and experiment with -/// performance with various types of payload. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_TestService_StreamingServiceProtocol: GRPCCore.RegistrableRPCService { - /// One empty request followed by one empty response. - func emptyCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// One request followed by one response. - func unaryCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// One request followed by one response. Response has cache control - /// headers set such that a caching HTTP proxy (such as GFE) can - /// satisfy subsequent requests. - func cacheableUnaryCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// One request followed by a sequence of responses (streamed download). - /// The server returns the payload with client desired type and sizes. - func streamingOutputCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// A sequence of requests followed by one response (streamed upload). - /// The server returns the aggregated size of client payload as the result. - func streamingInputCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// A sequence of requests with each request served by the server immediately. - /// As one request could lead to multiple responses, this interface - /// demonstrates the idea of full duplexing. - func fullDuplexCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// A sequence of requests followed by a sequence of responses. - /// The server buffers all the client requests and then serves them in order. A - /// stream of responses are returned to the client when the server starts with - /// first request. - func halfDuplexCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// The test server will not implement this method. It will be used - /// to test the behavior when clients call unimplemented methods. - func unimplementedCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse + /// Handle the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_SimpleResponse` message. + func unaryCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_SimpleResponse` message. + func cacheableUnaryCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_StreamingOutputCallRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingOutputCallResponse` messages. + func streamingOutputCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingInputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_StreamingInputCallResponse` message. + func streamingInputCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingOutputCallResponse` messages. + func fullDuplexCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_StreamingOutputCallResponse` messages. + func halfDuplexCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_Empty` message. + func unimplementedCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "grpc.testing.TestService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service to test the various types of RPCs and experiment with + /// > performance with various types of payload. + public protocol SimpleServiceProtocol: Grpc_Testing_TestService.ServiceProtocol { + /// Handle the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_Empty` to respond with. + func emptyCall( + request: Grpc_Testing_Empty, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_Empty + + /// Handle the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_SimpleRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_SimpleResponse` to respond with. + func unaryCall( + request: Grpc_Testing_SimpleRequest, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_SimpleResponse + + /// Handle the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_SimpleRequest` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_SimpleResponse` to respond with. + func cacheableUnaryCall( + request: Grpc_Testing_SimpleRequest, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_SimpleResponse + + /// Handle the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_StreamingOutputCallRequest` message. + /// - response: A response stream of `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + func streamingOutputCall( + request: Grpc_Testing_StreamingOutputCallRequest, + response: GRPCCore.RPCWriter, + context: GRPCCore.ServerContext + ) async throws + + /// Handle the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - request: A stream of `Grpc_Testing_StreamingInputCallRequest` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_StreamingInputCallResponse` to respond with. + func streamingInputCall( + request: GRPCCore.RPCAsyncSequence, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_StreamingInputCallResponse + + /// Handle the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - request: A stream of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - response: A response stream of `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + func fullDuplexCall( + request: GRPCCore.RPCAsyncSequence, + response: GRPCCore.RPCWriter, + context: GRPCCore.ServerContext + ) async throws + + /// Handle the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - request: A stream of `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - response: A response stream of `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + func halfDuplexCall( + request: GRPCCore.RPCAsyncSequence, + response: GRPCCore.RPCWriter, + context: GRPCCore.ServerContext + ) async throws + + /// Handle the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_Empty` to respond with. + func unimplementedCall( + request: Grpc_Testing_Empty, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_Empty + } } -/// Conformance to `GRPCCore.RegistrableRPCService`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Default implementation of 'registerMethods(with:)'. extension Grpc_Testing_TestService.StreamingServiceProtocol { - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) public func registerMethods(with router: inout GRPCCore.RPCRouter) { router.registerHandler( forMethod: Grpc_Testing_TestService.Method.EmptyCall.descriptor, @@ -354,71 +757,7 @@ extension Grpc_Testing_TestService.StreamingServiceProtocol { } } -/// A simple service to test the various types of RPCs and experiment with -/// performance with various types of payload. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_TestService_ServiceProtocol: Grpc_Testing_TestService.StreamingServiceProtocol { - /// One empty request followed by one empty response. - func emptyCall( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse - - /// One request followed by one response. - func unaryCall( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse - - /// One request followed by one response. Response has cache control - /// headers set such that a caching HTTP proxy (such as GFE) can - /// satisfy subsequent requests. - func cacheableUnaryCall( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse - - /// One request followed by a sequence of responses (streamed download). - /// The server returns the payload with client desired type and sizes. - func streamingOutputCall( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// A sequence of requests followed by one response (streamed upload). - /// The server returns the aggregated size of client payload as the result. - func streamingInputCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse - - /// A sequence of requests with each request served by the server immediately. - /// As one request could lead to multiple responses, this interface - /// demonstrates the idea of full duplexing. - func fullDuplexCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// A sequence of requests followed by a sequence of responses. - /// The server buffers all the client requests and then serves them in order. A - /// stream of responses are returned to the client when the server starts with - /// first request. - func halfDuplexCall( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - /// The test server will not implement this method. It will be used - /// to test the behavior when clients call unimplemented methods. - func unimplementedCall( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse -} - -/// Partial conformance to `Grpc_Testing_TestService_StreamingServiceProtocol`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Default implementation of streaming methods from 'StreamingServiceProtocol'. extension Grpc_Testing_TestService.ServiceProtocol { public func emptyCall( request: GRPCCore.StreamingServerRequest, @@ -430,7 +769,7 @@ extension Grpc_Testing_TestService.ServiceProtocol { ) return GRPCCore.StreamingServerResponse(single: response) } - + public func unaryCall( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext @@ -441,7 +780,7 @@ extension Grpc_Testing_TestService.ServiceProtocol { ) return GRPCCore.StreamingServerResponse(single: response) } - + public func cacheableUnaryCall( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext @@ -452,7 +791,7 @@ extension Grpc_Testing_TestService.ServiceProtocol { ) return GRPCCore.StreamingServerResponse(single: response) } - + public func streamingOutputCall( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext @@ -463,7 +802,7 @@ extension Grpc_Testing_TestService.ServiceProtocol { ) return response } - + public func streamingInputCall( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext @@ -474,7 +813,7 @@ extension Grpc_Testing_TestService.ServiceProtocol { ) return GRPCCore.StreamingServerResponse(single: response) } - + public func unimplementedCall( request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext @@ -487,367 +826,893 @@ extension Grpc_Testing_TestService.ServiceProtocol { } } -/// A simple service NOT implemented at servers so clients can test for -/// that case. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_UnimplementedService_StreamingServiceProtocol: GRPCCore.RegistrableRPCService { - /// A call that no server should implement - func unimplementedCall( - request: GRPCCore.StreamingServerRequest, +// Default implementation of methods from 'ServiceProtocol'. +extension Grpc_Testing_TestService.SimpleServiceProtocol { + public func emptyCall( + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse -} - -/// Conformance to `GRPCCore.RegistrableRPCService`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -extension Grpc_Testing_UnimplementedService.StreamingServiceProtocol { - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public func registerMethods(with router: inout GRPCCore.RPCRouter) { - router.registerHandler( - forMethod: Grpc_Testing_UnimplementedService.Method.UnimplementedCall.descriptor, - deserializer: GRPCProtobuf.ProtobufDeserializer(), - serializer: GRPCProtobuf.ProtobufSerializer(), - handler: { request, context in - try await self.unimplementedCall( - request: request, - context: context - ) - } + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.emptyCall( + request: request.message, + context: context + ), + metadata: [:] ) } -} -/// A simple service NOT implemented at servers so clients can test for -/// that case. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_UnimplementedService_ServiceProtocol: Grpc_Testing_UnimplementedService.StreamingServiceProtocol { - /// A call that no server should implement - func unimplementedCall( - request: GRPCCore.ServerRequest, + public func unaryCall( + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse -} + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.unaryCall( + request: request.message, + context: context + ), + metadata: [:] + ) + } -/// Partial conformance to `Grpc_Testing_UnimplementedService_StreamingServiceProtocol`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -extension Grpc_Testing_UnimplementedService.ServiceProtocol { - public func unimplementedCall( - request: GRPCCore.StreamingServerRequest, + public func cacheableUnaryCall( + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse { - let response = try await self.unimplementedCall( - request: GRPCCore.ServerRequest(stream: request), - context: context + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.cacheableUnaryCall( + request: request.message, + context: context + ), + metadata: [:] ) - return GRPCCore.StreamingServerResponse(single: response) } -} -/// A service used to control reconnect server. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_ReconnectService_StreamingServiceProtocol: GRPCCore.RegistrableRPCService { - func start( - request: GRPCCore.StreamingServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse - - func stop( - request: GRPCCore.StreamingServerRequest, + public func streamingOutputCall( + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse -} - -/// Conformance to `GRPCCore.RegistrableRPCService`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -extension Grpc_Testing_ReconnectService.StreamingServiceProtocol { - @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) - public func registerMethods(with router: inout GRPCCore.RPCRouter) { - router.registerHandler( - forMethod: Grpc_Testing_ReconnectService.Method.Start.descriptor, - deserializer: GRPCProtobuf.ProtobufDeserializer(), - serializer: GRPCProtobuf.ProtobufSerializer(), - handler: { request, context in - try await self.start( - request: request, + ) async throws -> GRPCCore.StreamingServerResponse { + return GRPCCore.StreamingServerResponse( + metadata: [:], + producer: { writer in + try await self.streamingOutputCall( + request: request.message, + response: writer, context: context ) + return [:] } ) - router.registerHandler( - forMethod: Grpc_Testing_ReconnectService.Method.Stop.descriptor, - deserializer: GRPCProtobuf.ProtobufDeserializer(), - serializer: GRPCProtobuf.ProtobufSerializer(), - handler: { request, context in - try await self.stop( - request: request, + } + + public func streamingInputCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.streamingInputCall( + request: request.messages, + context: context + ), + metadata: [:] + ) + } + + public func fullDuplexCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + return GRPCCore.StreamingServerResponse( + metadata: [:], + producer: { writer in + try await self.fullDuplexCall( + request: request.messages, + response: writer, context: context ) + return [:] } ) } -} -/// A service used to control reconnect server. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_ReconnectService_ServiceProtocol: Grpc_Testing_ReconnectService.StreamingServiceProtocol { - func start( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse - - func stop( - request: GRPCCore.ServerRequest, - context: GRPCCore.ServerContext - ) async throws -> GRPCCore.ServerResponse -} - -/// Partial conformance to `Grpc_Testing_ReconnectService_StreamingServiceProtocol`. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -extension Grpc_Testing_ReconnectService.ServiceProtocol { - public func start( - request: GRPCCore.StreamingServerRequest, + public func halfDuplexCall( + request: GRPCCore.StreamingServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse { - let response = try await self.start( - request: GRPCCore.ServerRequest(stream: request), - context: context + ) async throws -> GRPCCore.StreamingServerResponse { + return GRPCCore.StreamingServerResponse( + metadata: [:], + producer: { writer in + try await self.halfDuplexCall( + request: request.messages, + response: writer, + context: context + ) + return [:] + } ) - return GRPCCore.StreamingServerResponse(single: response) } - - public func stop( - request: GRPCCore.StreamingServerRequest, + + public func unimplementedCall( + request: GRPCCore.ServerRequest, context: GRPCCore.ServerContext - ) async throws -> GRPCCore.StreamingServerResponse { - let response = try await self.stop( - request: GRPCCore.ServerRequest(stream: request), - context: context + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.unimplementedCall( + request: request.message, + context: context + ), + metadata: [:] ) - return GRPCCore.StreamingServerResponse(single: response) } } -/// A simple service to test the various types of RPCs and experiment with -/// performance with various types of payload. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_TestService_ClientProtocol: Sendable { - /// One empty request followed by one empty response. - func emptyCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// One request followed by one response. - func unaryCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// One request followed by one response. Response has cache control - /// headers set such that a caching HTTP proxy (such as GFE) can - /// satisfy subsequent requests. - func cacheableUnaryCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// One request followed by a sequence of responses (streamed download). - /// The server returns the payload with client desired type and sizes. - func streamingOutputCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// A sequence of requests followed by one response (streamed upload). - /// The server returns the aggregated size of client payload as the result. - func streamingInputCall( - request: GRPCCore.StreamingClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// A sequence of requests with each request served by the server immediately. - /// As one request could lead to multiple responses, this interface - /// demonstrates the idea of full duplexing. - func fullDuplexCall( - request: GRPCCore.StreamingClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// A sequence of requests followed by a sequence of responses. - /// The server buffers all the client requests and then serves them in order. A - /// stream of responses are returned to the client when the server starts with - /// first request. - func halfDuplexCall( - request: GRPCCore.StreamingClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - /// The test server will not implement this method. It will be used - /// to test the behavior when clients call unimplemented methods. - func unimplementedCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable -} +// MARK: grpc.testing.TestService (client) -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -extension Grpc_Testing_TestService.ClientProtocol { - public func emptyCall( - request: GRPCCore.ClientRequest, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.emptyCall( - request: request, - serializer: GRPCProtobuf.ProtobufSerializer(), - deserializer: GRPCProtobuf.ProtobufDeserializer(), - options: options, - body - ) +extension Grpc_Testing_TestService { + /// Generated client protocol for the "grpc.testing.TestService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service to test the various types of RPCs and experiment with + /// > performance with various types of payload. + public protocol ClientProtocol: Sendable { + /// Call the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func emptyCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - serializer: A serializer for `Grpc_Testing_SimpleRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_SimpleResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func unaryCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - serializer: A serializer for `Grpc_Testing_SimpleRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_SimpleResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func cacheableUnaryCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_StreamingOutputCallRequest` message. + /// - serializer: A serializer for `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func streamingOutputCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingInputCallRequest` messages. + /// - serializer: A serializer for `Grpc_Testing_StreamingInputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingInputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func streamingInputCall( + request: GRPCCore.StreamingClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - serializer: A serializer for `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func fullDuplexCall( + request: GRPCCore.StreamingClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - serializer: A serializer for `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func halfDuplexCall( + request: GRPCCore.StreamingClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func unimplementedCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable } - - public func unaryCall( - request: GRPCCore.ClientRequest, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + + /// Generated client for the "grpc.testing.TestService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service to test the various types of RPCs and experiment with + /// > performance with various types of payload. + public struct Client: ClientProtocol { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client } - ) async throws -> R where R: Sendable { - try await self.unaryCall( - request: request, - serializer: GRPCProtobuf.ProtobufSerializer(), - deserializer: GRPCProtobuf.ProtobufDeserializer(), - options: options, - body - ) - } - - public func cacheableUnaryCall( - request: GRPCCore.ClientRequest, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + + /// Call the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func emptyCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_TestService.Method.EmptyCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) } - ) async throws -> R where R: Sendable { - try await self.cacheableUnaryCall( - request: request, - serializer: GRPCProtobuf.ProtobufSerializer(), - deserializer: GRPCProtobuf.ProtobufDeserializer(), - options: options, - body - ) - } - - public func streamingOutputCall( - request: GRPCCore.ClientRequest, + + /// Call the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - serializer: A serializer for `Grpc_Testing_SimpleRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_SimpleResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func unaryCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_TestService.Method.UnaryCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - serializer: A serializer for `Grpc_Testing_SimpleRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_SimpleResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cacheableUnaryCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_TestService.Method.CacheableUnaryCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_StreamingOutputCallRequest` message. + /// - serializer: A serializer for `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamingOutputCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.client.serverStreaming( + request: request, + descriptor: Grpc_Testing_TestService.Method.StreamingOutputCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingInputCallRequest` messages. + /// - serializer: A serializer for `Grpc_Testing_StreamingInputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingInputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamingInputCall( + request: GRPCCore.StreamingClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.clientStreaming( + request: request, + descriptor: Grpc_Testing_TestService.Method.StreamingInputCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - serializer: A serializer for `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func fullDuplexCall( + request: GRPCCore.StreamingClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.client.bidirectionalStreaming( + request: request, + descriptor: Grpc_Testing_TestService.Method.FullDuplexCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - serializer: A serializer for `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - deserializer: A deserializer for `Grpc_Testing_StreamingOutputCallResponse` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func halfDuplexCall( + request: GRPCCore.StreamingClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { + try await self.client.bidirectionalStreaming( + request: request, + descriptor: Grpc_Testing_TestService.Method.HalfDuplexCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func unimplementedCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_TestService.Method.UnimplementedCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. +extension Grpc_Testing_TestService.ClientProtocol { + /// Call the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func emptyCall( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.emptyCall( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func unaryCall( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.unaryCall( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_SimpleRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func cacheableUnaryCall( + request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.cacheableUnaryCall( + request: request, + serializer: GRPCProtobuf.ProtobufSerializer(), + deserializer: GRPCProtobuf.ProtobufDeserializer(), + options: options, + onResponse: handleResponse + ) + } + + /// Call the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_StreamingOutputCallRequest` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamingOutputCall( + request: GRPCCore.ClientRequest, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { try await self.streamingOutputCall( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } - - public func streamingInputCall( + + /// Call the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingInputCallRequest` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func streamingInputCall( request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } - ) async throws -> R where R: Sendable { + ) async throws -> Result where Result: Sendable { try await self.streamingInputCall( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } - - public func fullDuplexCall( + + /// Call the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func fullDuplexCall( request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { try await self.fullDuplexCall( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } - - public func halfDuplexCall( + + /// Call the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - request: A streaming request producing `Grpc_Testing_StreamingOutputCallRequest` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func halfDuplexCall( request: GRPCCore.StreamingClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { + onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable { try await self.halfDuplexCall( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } - - public func unimplementedCall( + + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func unimplementedCall( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } - ) async throws -> R where R: Sendable { + ) async throws -> Result where Result: Sendable { try await self.unimplementedCall( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing sugared APIs for 'ClientProtocol' methods. extension Grpc_Testing_TestService.ClientProtocol { - /// One empty request followed by one empty response. + /// Call the "EmptyCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One empty request followed by one empty response. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func emptyCall( _ message: Grpc_Testing_Empty, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -857,17 +1722,30 @@ extension Grpc_Testing_TestService.ClientProtocol { return try await self.emptyCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// One request followed by one response. + + /// Call the "UnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func unaryCall( _ message: Grpc_Testing_SimpleRequest, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -877,19 +1755,32 @@ extension Grpc_Testing_TestService.ClientProtocol { return try await self.unaryCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// One request followed by one response. Response has cache control - /// headers set such that a caching HTTP proxy (such as GFE) can - /// satisfy subsequent requests. + + /// Call the "CacheableUnaryCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by one response. Response has cache control + /// > headers set such that a caching HTTP proxy (such as GFE) can + /// > satisfy subsequent requests. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func cacheableUnaryCall( _ message: Grpc_Testing_SimpleRequest, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -899,12 +1790,25 @@ extension Grpc_Testing_TestService.ClientProtocol { return try await self.cacheableUnaryCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// One request followed by a sequence of responses (streamed download). - /// The server returns the payload with client desired type and sizes. + + /// Call the "StreamingOutputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > One request followed by a sequence of responses (streamed download). + /// > The server returns the payload with client desired type and sizes. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func streamingOutputCall( _ message: Grpc_Testing_StreamingOutputCallRequest, metadata: GRPCCore.Metadata = [:], @@ -918,80 +1822,135 @@ extension Grpc_Testing_TestService.ClientProtocol { return try await self.streamingOutputCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// A sequence of requests followed by one response (streamed upload). - /// The server returns the aggregated size of client payload as the result. + + /// Call the "StreamingInputCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by one response (streamed upload). + /// > The server returns the aggregated size of client payload as the result. + /// + /// - Parameters: + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - producer: A closure producing request messages to send to the server. The request + /// stream is closed when the closure returns. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func streamingInputCall( metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - requestProducer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.StreamingClientRequest( metadata: metadata, - producer: requestProducer + producer: producer ) return try await self.streamingInputCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// A sequence of requests with each request served by the server immediately. - /// As one request could lead to multiple responses, this interface - /// demonstrates the idea of full duplexing. + + /// Call the "FullDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests with each request served by the server immediately. + /// > As one request could lead to multiple responses, this interface + /// > demonstrates the idea of full duplexing. + /// + /// - Parameters: + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - producer: A closure producing request messages to send to the server. The request + /// stream is closed when the closure returns. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func fullDuplexCall( metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - requestProducer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, + requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { let request = GRPCCore.StreamingClientRequest( metadata: metadata, - producer: requestProducer + producer: producer ) return try await self.fullDuplexCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// A sequence of requests followed by a sequence of responses. - /// The server buffers all the client requests and then serves them in order. A - /// stream of responses are returned to the client when the server starts with - /// first request. + + /// Call the "HalfDuplexCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A sequence of requests followed by a sequence of responses. + /// > The server buffers all the client requests and then serves them in order. A + /// > stream of responses are returned to the client when the server starts with + /// > first request. + /// + /// - Parameters: + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - producer: A closure producing request messages to send to the server. The request + /// stream is closed when the closure returns. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func halfDuplexCall( metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - requestProducer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, + requestProducer producer: @Sendable @escaping (GRPCCore.RPCWriter) async throws -> Void, onResponse handleResponse: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> Result ) async throws -> Result where Result: Sendable { let request = GRPCCore.StreamingClientRequest( metadata: metadata, - producer: requestProducer + producer: producer ) return try await self.halfDuplexCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - - /// The test server will not implement this method. It will be used - /// to test the behavior when clients call unimplemented methods. + + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > The test server will not implement this method. It will be used + /// > to test the behavior when clients call unimplemented methods. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func unimplementedCall( _ message: Grpc_Testing_Empty, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -1001,228 +1960,339 @@ extension Grpc_Testing_TestService.ClientProtocol { return try await self.unimplementedCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } } -/// A simple service to test the various types of RPCs and experiment with -/// performance with various types of payload. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public struct Grpc_Testing_TestService_Client: Grpc_Testing_TestService.ClientProtocol { - private let client: GRPCCore.GRPCClient - - public init(wrapping client: GRPCCore.GRPCClient) { - self.client = client - } - - /// One empty request followed by one empty response. - public func emptyCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_TestService.Method.EmptyCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) - } - - /// One request followed by one response. - public func unaryCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message +// MARK: - grpc.testing.UnimplementedService + +/// Namespace containing generated types for the "grpc.testing.UnimplementedService" service. +public enum Grpc_Testing_UnimplementedService { + /// Service descriptor for the "grpc.testing.UnimplementedService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.UnimplementedService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "UnimplementedCall" metadata. + public enum UnimplementedCall { + /// Request type for "UnimplementedCall". + public typealias Input = Grpc_Testing_Empty + /// Response type for "UnimplementedCall". + public typealias Output = Grpc_Testing_Empty + /// Descriptor for "UnimplementedCall". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.UnimplementedService"), + method: "UnimplementedCall" + ) } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_TestService.Method.UnaryCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) + /// Descriptors for all methods in the "grpc.testing.UnimplementedService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + UnimplementedCall.descriptor + ] } - - /// One request followed by one response. Response has cache control - /// headers set such that a caching HTTP proxy (such as GFE) can - /// satisfy subsequent requests. - public func cacheableUnaryCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_TestService.Method.CacheableUnaryCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) +} + +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "grpc.testing.UnimplementedService" service. + public static let grpc_testing_UnimplementedService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.UnimplementedService") +} + +// MARK: grpc.testing.UnimplementedService (server) + +extension Grpc_Testing_UnimplementedService { + /// Streaming variant of the service protocol for the "grpc.testing.UnimplementedService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service NOT implemented at servers so clients can test for + /// > that case. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_Empty` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_Empty` messages. + func unimplementedCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse } - - /// One request followed by a sequence of responses (streamed download). - /// The server returns the payload with client desired type and sizes. - public func streamingOutputCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { - try await self.client.serverStreaming( - request: request, - descriptor: Grpc_Testing_TestService.Method.StreamingOutputCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) + + /// Service protocol for the "grpc.testing.UnimplementedService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service NOT implemented at servers so clients can test for + /// > that case. + public protocol ServiceProtocol: Grpc_Testing_UnimplementedService.StreamingServiceProtocol { + /// Handle the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_Empty` message. + func unimplementedCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse } - - /// A sequence of requests followed by one response (streamed upload). - /// The server returns the aggregated size of client payload as the result. - public func streamingInputCall( - request: GRPCCore.StreamingClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.clientStreaming( - request: request, - descriptor: Grpc_Testing_TestService.Method.StreamingInputCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) + + /// Simple service protocol for the "grpc.testing.UnimplementedService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service NOT implemented at servers so clients can test for + /// > that case. + public protocol SimpleServiceProtocol: Grpc_Testing_UnimplementedService.ServiceProtocol { + /// Handle the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - request: A `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_Empty` to respond with. + func unimplementedCall( + request: Grpc_Testing_Empty, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_Empty } - - /// A sequence of requests with each request served by the server immediately. - /// As one request could lead to multiple responses, this interface - /// demonstrates the idea of full duplexing. - public func fullDuplexCall( - request: GRPCCore.StreamingClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { - try await self.client.bidirectionalStreaming( - request: request, - descriptor: Grpc_Testing_TestService.Method.FullDuplexCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body +} + +// Default implementation of 'registerMethods(with:)'. +extension Grpc_Testing_UnimplementedService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) { + router.registerHandler( + forMethod: Grpc_Testing_UnimplementedService.Method.UnimplementedCall.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.unimplementedCall( + request: request, + context: context + ) + } ) } - - /// A sequence of requests followed by a sequence of responses. - /// The server buffers all the client requests and then serves them in order. A - /// stream of responses are returned to the client when the server starts with - /// first request. - public func halfDuplexCall( - request: GRPCCore.StreamingClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.StreamingClientResponse) async throws -> R - ) async throws -> R where R: Sendable { - try await self.client.bidirectionalStreaming( - request: request, - descriptor: Grpc_Testing_TestService.Method.HalfDuplexCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body +} + +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +extension Grpc_Testing_UnimplementedService.ServiceProtocol { + public func unimplementedCall( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.unimplementedCall( + request: GRPCCore.ServerRequest(stream: request), + context: context ) + return GRPCCore.StreamingServerResponse(single: response) } - - /// The test server will not implement this method. It will be used - /// to test the behavior when clients call unimplemented methods. - public func unimplementedCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_TestService.Method.UnimplementedCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body +} + +// Default implementation of methods from 'ServiceProtocol'. +extension Grpc_Testing_UnimplementedService.SimpleServiceProtocol { + public func unimplementedCall( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.unimplementedCall( + request: request.message, + context: context + ), + metadata: [:] ) } } -/// A simple service NOT implemented at servers so clients can test for -/// that case. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_UnimplementedService_ClientProtocol: Sendable { - /// A call that no server should implement - func unimplementedCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable +// MARK: grpc.testing.UnimplementedService (client) + +extension Grpc_Testing_UnimplementedService { + /// Generated client protocol for the "grpc.testing.UnimplementedService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service NOT implemented at servers so clients can test for + /// > that case. + public protocol ClientProtocol: Sendable { + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func unimplementedCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "grpc.testing.UnimplementedService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > A simple service NOT implemented at servers so clients can test for + /// > that case. + public struct Client: ClientProtocol { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func unimplementedCall( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_UnimplementedService.Method.UnimplementedCall.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing default arguments to 'ClientProtocol' methods. extension Grpc_Testing_UnimplementedService.ClientProtocol { - public func unimplementedCall( + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func unimplementedCall( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } - ) async throws -> R where R: Sendable { + ) async throws -> Result where Result: Sendable { try await self.unimplementedCall( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing sugared APIs for 'ClientProtocol' methods. extension Grpc_Testing_UnimplementedService.ClientProtocol { - /// A call that no server should implement + /// Call the "UnimplementedCall" method. + /// + /// > Source IDL Documentation: + /// > + /// > A call that no server should implement + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func unimplementedCall( _ message: Grpc_Testing_Empty, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -1232,105 +2302,470 @@ extension Grpc_Testing_UnimplementedService.ClientProtocol { return try await self.unimplementedCall( request: request, options: options, - handleResponse + onResponse: handleResponse ) } } -/// A simple service NOT implemented at servers so clients can test for -/// that case. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public struct Grpc_Testing_UnimplementedService_Client: Grpc_Testing_UnimplementedService.ClientProtocol { - private let client: GRPCCore.GRPCClient - - public init(wrapping client: GRPCCore.GRPCClient) { - self.client = client - } - - /// A call that no server should implement - public func unimplementedCall( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message +// MARK: - grpc.testing.ReconnectService + +/// Namespace containing generated types for the "grpc.testing.ReconnectService" service. +public enum Grpc_Testing_ReconnectService { + /// Service descriptor for the "grpc.testing.ReconnectService" service. + public static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.ReconnectService") + /// Namespace for method metadata. + public enum Method { + /// Namespace for "Start" metadata. + public enum Start { + /// Request type for "Start". + public typealias Input = Grpc_Testing_ReconnectParams + /// Response type for "Start". + public typealias Output = Grpc_Testing_Empty + /// Descriptor for "Start". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.ReconnectService"), + method: "Start" + ) } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_UnimplementedService.Method.UnimplementedCall.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body + /// Namespace for "Stop" metadata. + public enum Stop { + /// Request type for "Stop". + public typealias Input = Grpc_Testing_Empty + /// Response type for "Stop". + public typealias Output = Grpc_Testing_ReconnectInfo + /// Descriptor for "Stop". + public static let descriptor = GRPCCore.MethodDescriptor( + service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.ReconnectService"), + method: "Stop" + ) + } + /// Descriptors for all methods in the "grpc.testing.ReconnectService" service. + public static let descriptors: [GRPCCore.MethodDescriptor] = [ + Start.descriptor, + Stop.descriptor + ] + } +} + +extension GRPCCore.ServiceDescriptor { + /// Service descriptor for the "grpc.testing.ReconnectService" service. + public static let grpc_testing_ReconnectService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "grpc.testing.ReconnectService") +} + +// MARK: grpc.testing.ReconnectService (server) + +extension Grpc_Testing_ReconnectService { + /// Streaming variant of the service protocol for the "grpc.testing.ReconnectService" service. + /// + /// This protocol is the lowest-level of the service protocols generated for this service + /// giving you the most flexibility over the implementation of your service. This comes at + /// the cost of more verbose and less strict APIs. Each RPC requires you to implement it in + /// terms of a request stream and response stream. Where only a single request or response + /// message is expected, you are responsible for enforcing this invariant is maintained. + /// + /// Where possible, prefer using the stricter, less-verbose ``ServiceProtocol`` + /// or ``SimpleServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A service used to control reconnect server. + public protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService { + /// Handle the "Start" method. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_ReconnectParams` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_Empty` messages. + func start( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + + /// Handle the "Stop" method. + /// + /// - Parameters: + /// - request: A streaming request of `Grpc_Testing_Empty` messages. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A streaming response of `Grpc_Testing_ReconnectInfo` messages. + func stop( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse + } + + /// Service protocol for the "grpc.testing.ReconnectService" service. + /// + /// This protocol is higher level than ``StreamingServiceProtocol`` but lower level than + /// the ``SimpleServiceProtocol``, it provides access to request and response metadata and + /// trailing response metadata. If you don't need these then consider using + /// the ``SimpleServiceProtocol``. If you need fine grained control over your RPCs then + /// use ``StreamingServiceProtocol``. + /// + /// > Source IDL Documentation: + /// > + /// > A service used to control reconnect server. + public protocol ServiceProtocol: Grpc_Testing_ReconnectService.StreamingServiceProtocol { + /// Handle the "Start" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_ReconnectParams` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_Empty` message. + func start( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + + /// Handle the "Stop" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A response containing a single `Grpc_Testing_ReconnectInfo` message. + func stop( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse + } + + /// Simple service protocol for the "grpc.testing.ReconnectService" service. + /// + /// This is the highest level protocol for the service. The API is the easiest to use but + /// doesn't provide access to request or response metadata. If you need access to these + /// then use ``ServiceProtocol`` instead. + /// + /// > Source IDL Documentation: + /// > + /// > A service used to control reconnect server. + public protocol SimpleServiceProtocol: Grpc_Testing_ReconnectService.ServiceProtocol { + /// Handle the "Start" method. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_ReconnectParams` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_Empty` to respond with. + func start( + request: Grpc_Testing_ReconnectParams, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_Empty + + /// Handle the "Stop" method. + /// + /// - Parameters: + /// - request: A `Grpc_Testing_Empty` message. + /// - context: Context providing information about the RPC. + /// - Throws: Any error which occurred during the processing of the request. Thrown errors + /// of type `RPCError` are mapped to appropriate statuses. All other errors are converted + /// to an internal error. + /// - Returns: A `Grpc_Testing_ReconnectInfo` to respond with. + func stop( + request: Grpc_Testing_Empty, + context: GRPCCore.ServerContext + ) async throws -> Grpc_Testing_ReconnectInfo + } +} + +// Default implementation of 'registerMethods(with:)'. +extension Grpc_Testing_ReconnectService.StreamingServiceProtocol { + public func registerMethods(with router: inout GRPCCore.RPCRouter) { + router.registerHandler( + forMethod: Grpc_Testing_ReconnectService.Method.Start.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.start( + request: request, + context: context + ) + } + ) + router.registerHandler( + forMethod: Grpc_Testing_ReconnectService.Method.Stop.descriptor, + deserializer: GRPCProtobuf.ProtobufDeserializer(), + serializer: GRPCProtobuf.ProtobufSerializer(), + handler: { request, context in + try await self.stop( + request: request, + context: context + ) + } ) } } -/// A service used to control reconnect server. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public protocol Grpc_Testing_ReconnectService_ClientProtocol: Sendable { - func start( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable - - func stop( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R - ) async throws -> R where R: Sendable +// Default implementation of streaming methods from 'StreamingServiceProtocol'. +extension Grpc_Testing_ReconnectService.ServiceProtocol { + public func start( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.start( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } + + public func stop( + request: GRPCCore.StreamingServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.StreamingServerResponse { + let response = try await self.stop( + request: GRPCCore.ServerRequest(stream: request), + context: context + ) + return GRPCCore.StreamingServerResponse(single: response) + } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Default implementation of methods from 'ServiceProtocol'. +extension Grpc_Testing_ReconnectService.SimpleServiceProtocol { + public func start( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.start( + request: request.message, + context: context + ), + metadata: [:] + ) + } + + public func stop( + request: GRPCCore.ServerRequest, + context: GRPCCore.ServerContext + ) async throws -> GRPCCore.ServerResponse { + return GRPCCore.ServerResponse( + message: try await self.stop( + request: request.message, + context: context + ), + metadata: [:] + ) + } +} + +// MARK: grpc.testing.ReconnectService (client) + +extension Grpc_Testing_ReconnectService { + /// Generated client protocol for the "grpc.testing.ReconnectService" service. + /// + /// You don't need to implement this protocol directly, use the generated + /// implementation, ``Client``. + /// + /// > Source IDL Documentation: + /// > + /// > A service used to control reconnect server. + public protocol ClientProtocol: Sendable { + /// Call the "Start" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_ReconnectParams` message. + /// - serializer: A serializer for `Grpc_Testing_ReconnectParams` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func start( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + + /// Call the "Stop" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_ReconnectInfo` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + func stop( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result + ) async throws -> Result where Result: Sendable + } + + /// Generated client for the "grpc.testing.ReconnectService" service. + /// + /// The ``Client`` provides an implementation of ``ClientProtocol`` which wraps + /// a `GRPCCore.GRPCCClient`. The underlying `GRPCClient` provides the long-lived + /// means of communication with the remote peer. + /// + /// > Source IDL Documentation: + /// > + /// > A service used to control reconnect server. + public struct Client: ClientProtocol { + private let client: GRPCCore.GRPCClient + + /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`. + /// + /// - Parameters: + /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service. + public init(wrapping client: GRPCCore.GRPCClient) { + self.client = client + } + + /// Call the "Start" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_ReconnectParams` message. + /// - serializer: A serializer for `Grpc_Testing_ReconnectParams` messages. + /// - deserializer: A deserializer for `Grpc_Testing_Empty` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func start( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_ReconnectService.Method.Start.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + + /// Call the "Stop" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - serializer: A serializer for `Grpc_Testing_Empty` messages. + /// - deserializer: A deserializer for `Grpc_Testing_ReconnectInfo` messages. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func stop( + request: GRPCCore.ClientRequest, + serializer: some GRPCCore.MessageSerializer, + deserializer: some GRPCCore.MessageDeserializer, + options: GRPCCore.CallOptions = .defaults, + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message + } + ) async throws -> Result where Result: Sendable { + try await self.client.unary( + request: request, + descriptor: Grpc_Testing_ReconnectService.Method.Stop.descriptor, + serializer: serializer, + deserializer: deserializer, + options: options, + onResponse: handleResponse + ) + } + } +} + +// Helpers providing default arguments to 'ClientProtocol' methods. extension Grpc_Testing_ReconnectService.ClientProtocol { - public func start( + /// Call the "Start" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_ReconnectParams` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func start( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } - ) async throws -> R where R: Sendable { + ) async throws -> Result where Result: Sendable { try await self.start( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } - - public func stop( + + /// Call the "Stop" method. + /// + /// - Parameters: + /// - request: A request containing a single `Grpc_Testing_Empty` message. + /// - options: Options to apply to this RPC. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. + public func stop( request: GRPCCore.ClientRequest, options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } - ) async throws -> R where R: Sendable { + ) async throws -> Result where Result: Sendable { try await self.stop( request: request, serializer: GRPCProtobuf.ProtobufSerializer(), deserializer: GRPCProtobuf.ProtobufDeserializer(), options: options, - body + onResponse: handleResponse ) } } -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) +// Helpers providing sugared APIs for 'ClientProtocol' methods. extension Grpc_Testing_ReconnectService.ClientProtocol { + /// Call the "Start" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func start( _ message: Grpc_Testing_ReconnectParams, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -1340,16 +2775,26 @@ extension Grpc_Testing_ReconnectService.ClientProtocol { return try await self.start( request: request, options: options, - handleResponse + onResponse: handleResponse ) } - + + /// Call the "Stop" method. + /// + /// - Parameters: + /// - message: request message to send. + /// - metadata: Additional metadata to send, defaults to empty. + /// - options: Options to apply to this RPC, defaults to `.defaults`. + /// - handleResponse: A closure which handles the response, the result of which is + /// returned to the caller. Returning from the closure will cancel the RPC if it + /// hasn't already finished. + /// - Returns: The result of `handleResponse`. public func stop( _ message: Grpc_Testing_Empty, metadata: GRPCCore.Metadata = [:], options: GRPCCore.CallOptions = .defaults, - onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { - try $0.message + onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> Result = { response in + try response.message } ) async throws -> Result where Result: Sendable { let request = GRPCCore.ClientRequest( @@ -1359,55 +2804,7 @@ extension Grpc_Testing_ReconnectService.ClientProtocol { return try await self.stop( request: request, options: options, - handleResponse - ) - } -} - -/// A service used to control reconnect server. -@available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) -public struct Grpc_Testing_ReconnectService_Client: Grpc_Testing_ReconnectService.ClientProtocol { - private let client: GRPCCore.GRPCClient - - public init(wrapping client: GRPCCore.GRPCClient) { - self.client = client - } - - public func start( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_ReconnectService.Method.Start.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body - ) - } - - public func stop( - request: GRPCCore.ClientRequest, - serializer: some GRPCCore.MessageSerializer, - deserializer: some GRPCCore.MessageDeserializer, - options: GRPCCore.CallOptions = .defaults, - _ body: @Sendable @escaping (GRPCCore.ClientResponse) async throws -> R = { - try $0.message - } - ) async throws -> R where R: Sendable { - try await self.client.unary( - request: request, - descriptor: Grpc_Testing_ReconnectService.Method.Stop.descriptor, - serializer: serializer, - deserializer: deserializer, - options: options, - handler: body + onResponse: handleResponse ) } } \ No newline at end of file diff --git a/Tests/GRPCHealthServiceTests/HealthTests.swift b/Tests/GRPCHealthServiceTests/HealthTests.swift index 420db23..df0ef2f 100644 --- a/Tests/GRPCHealthServiceTests/HealthTests.swift +++ b/Tests/GRPCHealthServiceTests/HealthTests.swift @@ -21,13 +21,13 @@ import XCTest final class HealthTests: XCTestCase { private func withHealthClient( - _ body: @Sendable (Grpc_Health_V1_Health_Client, Health.Provider) async throws -> Void + _ body: @Sendable (Grpc_Health_V1_Health.Client, Health.Provider) async throws -> Void ) async throws { let health = Health() let inProcess = InProcessTransport() let server = GRPCServer(transport: inProcess.server, services: [health.service]) let client = GRPCClient(transport: inProcess.client) - let healthClient = Grpc_Health_V1_Health_Client(wrapping: client) + let healthClient = Grpc_Health_V1_Health.Client(wrapping: client) try await withThrowingDiscardingTaskGroup { group in group.addTask { diff --git a/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift b/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift index b6f93eb..009f046 100644 --- a/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift +++ b/Tests/GRPCInterceptorsTests/TracingInterceptorTests.swift @@ -37,7 +37,7 @@ final class TracingInterceptorTests: XCTestCase { // This is blocked on: https://github.com/apple/swift-service-context/pull/46 try await ServiceContext.$current.withValue(serviceContext) { let methodDescriptor = MethodDescriptor( - service: "TracingInterceptorTests", + fullyQualifiedService: "TracingInterceptorTests", method: "testClientInterceptor" ) let response = try await interceptor.intercept( @@ -95,7 +95,7 @@ final class TracingInterceptorTests: XCTestCase { func testClientInterceptorAllEventsRecorded() async throws { let methodDescriptor = MethodDescriptor( - service: "TracingInterceptorTests", + fullyQualifiedService: "TracingInterceptorTests", method: "testClientInterceptorAllEventsRecorded" ) var serviceContext = ServiceContext.topLevel @@ -174,14 +174,14 @@ final class TracingInterceptorTests: XCTestCase { func testServerInterceptorErrorResponse() async throws { let methodDescriptor = MethodDescriptor( - service: "TracingInterceptorTests", + fullyQualifiedService: "TracingInterceptorTests", method: "testServerInterceptorErrorResponse" ) let interceptor = ServerTracingInterceptor(emitEventOnEachWrite: false) let single = ServerRequest(metadata: ["trace-id": "some-trace-id"], message: [UInt8]()) let response = try await interceptor.intercept( request: .init(single: single), - context: .init(descriptor: methodDescriptor, cancellation: .init()) + context: .init(descriptor: methodDescriptor, peer: "", cancellation: .init()) ) { _, _ in StreamingServerResponse(error: .init(code: .unknown, message: "Test error")) } @@ -202,7 +202,7 @@ final class TracingInterceptorTests: XCTestCase { func testServerInterceptor() async throws { let methodDescriptor = MethodDescriptor( - service: "TracingInterceptorTests", + fullyQualifiedService: "TracingInterceptorTests", method: "testServerInterceptor" ) let (stream, continuation) = AsyncStream.makeStream() @@ -210,7 +210,7 @@ final class TracingInterceptorTests: XCTestCase { let single = ServerRequest(metadata: ["trace-id": "some-trace-id"], message: [UInt8]()) let response = try await interceptor.intercept( request: .init(single: single), - context: .init(descriptor: methodDescriptor, cancellation: .init()) + context: .init(descriptor: methodDescriptor, peer: "", cancellation: .init()) ) { _, _ in { [serviceContext = ServiceContext.current] in return StreamingServerResponse( @@ -267,7 +267,7 @@ final class TracingInterceptorTests: XCTestCase { func testServerInterceptorAllEventsRecorded() async throws { let methodDescriptor = MethodDescriptor( - service: "TracingInterceptorTests", + fullyQualifiedService: "TracingInterceptorTests", method: "testServerInterceptorAllEventsRecorded" ) let (stream, continuation) = AsyncStream.makeStream() @@ -275,7 +275,7 @@ final class TracingInterceptorTests: XCTestCase { let single = ServerRequest(metadata: ["trace-id": "some-trace-id"], message: [UInt8]()) let response = try await interceptor.intercept( request: .init(single: single), - context: .init(descriptor: methodDescriptor, cancellation: .init()) + context: .init(descriptor: methodDescriptor, peer: "", cancellation: .init()) ) { _, _ in { [serviceContext = ServiceContext.current] in return StreamingServerResponse(