| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317 |
- //
- // Copyright 2024, gRPC Authors All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- // DO NOT EDIT.
- // swift-format-ignore-file
- // swiftlint:disable all
- //
- // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
- // Source: error-service.proto
- //
- // For information on using the generated types, please see the documentation:
- // https://github.com/grpc/grpc-swift
- internal import GRPCCore
- internal import GRPCProtobuf
- internal import SwiftProtobuf
- // MARK: - ErrorService
- /// Namespace containing generated types for the "ErrorService" service.
- internal enum ErrorService {
- /// Service descriptor for the "ErrorService" service.
- internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ErrorService")
- /// Namespace for method metadata.
- internal enum Method {
- /// Namespace for "ThrowError" metadata.
- internal enum ThrowError {
- /// Request type for "ThrowError".
- internal typealias Input = ThrowInput
- /// Response type for "ThrowError".
- internal typealias Output = SwiftProtobuf.Google_Protobuf_Empty
- /// Descriptor for "ThrowError".
- internal static let descriptor = GRPCCore.MethodDescriptor(
- service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "ErrorService"),
- method: "ThrowError"
- )
- }
- /// Descriptors for all methods in the "ErrorService" service.
- internal static let descriptors: [GRPCCore.MethodDescriptor] = [
- ThrowError.descriptor
- ]
- }
- }
- extension GRPCCore.ServiceDescriptor {
- /// Service descriptor for the "ErrorService" service.
- internal static let ErrorService = GRPCCore.ServiceDescriptor(fullyQualifiedService: "ErrorService")
- }
- // MARK: ErrorService (server)
- extension ErrorService {
- /// Streaming variant of the service protocol for the "ErrorService" 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.
- internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
- /// Handle the "ThrowError" method.
- ///
- /// - Parameters:
- /// - request: A streaming request of `ThrowInput` 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 `SwiftProtobuf.Google_Protobuf_Empty` messages.
- func throwError(
- request: GRPCCore.StreamingServerRequest<ThrowInput>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.StreamingServerResponse<SwiftProtobuf.Google_Protobuf_Empty>
- }
- /// Service protocol for the "ErrorService" 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``.
- internal protocol ServiceProtocol: ErrorService.StreamingServiceProtocol {
- /// Handle the "ThrowError" method.
- ///
- /// - Parameters:
- /// - request: A request containing a single `ThrowInput` 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 `SwiftProtobuf.Google_Protobuf_Empty` message.
- func throwError(
- request: GRPCCore.ServerRequest<ThrowInput>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.ServerResponse<SwiftProtobuf.Google_Protobuf_Empty>
- }
- /// Simple service protocol for the "ErrorService" 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.
- internal protocol SimpleServiceProtocol: ErrorService.ServiceProtocol {
- /// Handle the "ThrowError" method.
- ///
- /// - Parameters:
- /// - request: A `ThrowInput` 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 `SwiftProtobuf.Google_Protobuf_Empty` to respond with.
- func throwError(
- request: ThrowInput,
- context: GRPCCore.ServerContext
- ) async throws -> SwiftProtobuf.Google_Protobuf_Empty
- }
- }
- // Default implementation of 'registerMethods(with:)'.
- extension ErrorService.StreamingServiceProtocol {
- internal func registerMethods<Transport>(with router: inout GRPCCore.RPCRouter<Transport>) where Transport: GRPCCore.ServerTransport {
- router.registerHandler(
- forMethod: ErrorService.Method.ThrowError.descriptor,
- deserializer: GRPCProtobuf.ProtobufDeserializer<ThrowInput>(),
- serializer: GRPCProtobuf.ProtobufSerializer<SwiftProtobuf.Google_Protobuf_Empty>(),
- handler: { request, context in
- try await self.throwError(
- request: request,
- context: context
- )
- }
- )
- }
- }
- // Default implementation of streaming methods from 'StreamingServiceProtocol'.
- extension ErrorService.ServiceProtocol {
- internal func throwError(
- request: GRPCCore.StreamingServerRequest<ThrowInput>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.StreamingServerResponse<SwiftProtobuf.Google_Protobuf_Empty> {
- let response = try await self.throwError(
- request: GRPCCore.ServerRequest(stream: request),
- context: context
- )
- return GRPCCore.StreamingServerResponse(single: response)
- }
- }
- // Default implementation of methods from 'ServiceProtocol'.
- extension ErrorService.SimpleServiceProtocol {
- internal func throwError(
- request: GRPCCore.ServerRequest<ThrowInput>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.ServerResponse<SwiftProtobuf.Google_Protobuf_Empty> {
- return GRPCCore.ServerResponse<SwiftProtobuf.Google_Protobuf_Empty>(
- message: try await self.throwError(
- request: request.message,
- context: context
- ),
- metadata: [:]
- )
- }
- }
- // MARK: ErrorService (client)
- extension ErrorService {
- /// Generated client protocol for the "ErrorService" service.
- ///
- /// You don't need to implement this protocol directly, use the generated
- /// implementation, ``Client``.
- internal protocol ClientProtocol: Sendable {
- /// Call the "ThrowError" method.
- ///
- /// - Parameters:
- /// - request: A request containing a single `ThrowInput` message.
- /// - serializer: A serializer for `ThrowInput` messages.
- /// - deserializer: A deserializer for `SwiftProtobuf.Google_Protobuf_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 throwError<Result>(
- request: GRPCCore.ClientRequest<ThrowInput>,
- serializer: some GRPCCore.MessageSerializer<ThrowInput>,
- deserializer: some GRPCCore.MessageDeserializer<SwiftProtobuf.Google_Protobuf_Empty>,
- options: GRPCCore.CallOptions,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<SwiftProtobuf.Google_Protobuf_Empty>) async throws -> Result
- ) async throws -> Result where Result: Sendable
- }
- /// Generated client for the "ErrorService" 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.
- internal struct Client<Transport>: ClientProtocol where Transport: GRPCCore.ClientTransport {
- private let client: GRPCCore.GRPCClient<Transport>
- /// Creates a new client wrapping the provided `GRPCCore.GRPCClient`.
- ///
- /// - Parameters:
- /// - client: A `GRPCCore.GRPCClient` providing a communication channel to the service.
- internal init(wrapping client: GRPCCore.GRPCClient<Transport>) {
- self.client = client
- }
- /// Call the "ThrowError" method.
- ///
- /// - Parameters:
- /// - request: A request containing a single `ThrowInput` message.
- /// - serializer: A serializer for `ThrowInput` messages.
- /// - deserializer: A deserializer for `SwiftProtobuf.Google_Protobuf_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`.
- internal func throwError<Result>(
- request: GRPCCore.ClientRequest<ThrowInput>,
- serializer: some GRPCCore.MessageSerializer<ThrowInput>,
- deserializer: some GRPCCore.MessageDeserializer<SwiftProtobuf.Google_Protobuf_Empty>,
- options: GRPCCore.CallOptions = .defaults,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<SwiftProtobuf.Google_Protobuf_Empty>) async throws -> Result = { response in
- try response.message
- }
- ) async throws -> Result where Result: Sendable {
- try await self.client.unary(
- request: request,
- descriptor: ErrorService.Method.ThrowError.descriptor,
- serializer: serializer,
- deserializer: deserializer,
- options: options,
- onResponse: handleResponse
- )
- }
- }
- }
- // Helpers providing default arguments to 'ClientProtocol' methods.
- extension ErrorService.ClientProtocol {
- /// Call the "ThrowError" method.
- ///
- /// - Parameters:
- /// - request: A request containing a single `ThrowInput` 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`.
- internal func throwError<Result>(
- request: GRPCCore.ClientRequest<ThrowInput>,
- options: GRPCCore.CallOptions = .defaults,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<SwiftProtobuf.Google_Protobuf_Empty>) async throws -> Result = { response in
- try response.message
- }
- ) async throws -> Result where Result: Sendable {
- try await self.throwError(
- request: request,
- serializer: GRPCProtobuf.ProtobufSerializer<ThrowInput>(),
- deserializer: GRPCProtobuf.ProtobufDeserializer<SwiftProtobuf.Google_Protobuf_Empty>(),
- options: options,
- onResponse: handleResponse
- )
- }
- }
- // Helpers providing sugared APIs for 'ClientProtocol' methods.
- extension ErrorService.ClientProtocol {
- /// Call the "ThrowError" 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`.
- internal func throwError<Result>(
- _ message: ThrowInput,
- metadata: GRPCCore.Metadata = [:],
- options: GRPCCore.CallOptions = .defaults,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<SwiftProtobuf.Google_Protobuf_Empty>) async throws -> Result = { response in
- try response.message
- }
- ) async throws -> Result where Result: Sendable {
- let request = GRPCCore.ClientRequest<ThrowInput>(
- message: message,
- metadata: metadata
- )
- return try await self.throwError(
- request: request,
- options: options,
- onResponse: handleResponse
- )
- }
- }
|