| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- /// Copyright 2015 gRPC authors.
- ///
- /// 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
- //
- // Generated by the gRPC Swift generator plugin for the protocol buffer compiler.
- // Source: helloworld.proto
- //
- // For information on using the generated types, please see the documentation:
- // https://github.com/grpc/grpc-swift
- import GRPCCore
- import GRPCProtobuf
- // MARK: - helloworld.Greeter
- /// Namespace containing generated types for the "helloworld.Greeter" service.
- internal enum Helloworld_Greeter {
- /// Service descriptor for the "helloworld.Greeter" service.
- internal static let descriptor = GRPCCore.ServiceDescriptor(fullyQualifiedService: "helloworld.Greeter")
- /// Namespace for method metadata.
- internal enum Method {
- /// Namespace for "SayHello" metadata.
- internal enum SayHello {
- /// Request type for "SayHello".
- internal typealias Input = Helloworld_HelloRequest
- /// Response type for "SayHello".
- internal typealias Output = Helloworld_HelloReply
- /// Descriptor for "SayHello".
- internal static let descriptor = GRPCCore.MethodDescriptor(
- service: GRPCCore.ServiceDescriptor(fullyQualifiedService: "helloworld.Greeter"),
- method: "SayHello"
- )
- }
- /// Descriptors for all methods in the "helloworld.Greeter" service.
- internal static let descriptors: [GRPCCore.MethodDescriptor] = [
- SayHello.descriptor
- ]
- }
- }
- extension GRPCCore.ServiceDescriptor {
- /// Service descriptor for the "helloworld.Greeter" service.
- internal static let helloworld_Greeter = GRPCCore.ServiceDescriptor(fullyQualifiedService: "helloworld.Greeter")
- }
- // MARK: helloworld.Greeter (server)
- extension Helloworld_Greeter {
- /// Streaming variant of the service protocol for the "helloworld.Greeter" 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:
- /// >
- /// > The greeting service definition.
- internal protocol StreamingServiceProtocol: GRPCCore.RegistrableRPCService {
- /// Handle the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - Parameters:
- /// - request: A streaming request of `Helloworld_HelloRequest` 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 `Helloworld_HelloReply` messages.
- func sayHello(
- request: GRPCCore.StreamingServerRequest<Helloworld_HelloRequest>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.StreamingServerResponse<Helloworld_HelloReply>
- }
- /// Service protocol for the "helloworld.Greeter" 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:
- /// >
- /// > The greeting service definition.
- internal protocol ServiceProtocol: Helloworld_Greeter.StreamingServiceProtocol {
- /// Handle the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - Parameters:
- /// - request: A request containing a single `Helloworld_HelloRequest` 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 `Helloworld_HelloReply` message.
- func sayHello(
- request: GRPCCore.ServerRequest<Helloworld_HelloRequest>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.ServerResponse<Helloworld_HelloReply>
- }
- /// Simple service protocol for the "helloworld.Greeter" 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:
- /// >
- /// > The greeting service definition.
- internal protocol SimpleServiceProtocol: Helloworld_Greeter.ServiceProtocol {
- /// Handle the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - Parameters:
- /// - request: A `Helloworld_HelloRequest` 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 `Helloworld_HelloReply` to respond with.
- func sayHello(
- request: Helloworld_HelloRequest,
- context: GRPCCore.ServerContext
- ) async throws -> Helloworld_HelloReply
- }
- }
- // Default implementation of 'registerMethods(with:)'.
- extension Helloworld_Greeter.StreamingServiceProtocol {
- internal func registerMethods(with router: inout GRPCCore.RPCRouter) {
- router.registerHandler(
- forMethod: Helloworld_Greeter.Method.SayHello.descriptor,
- deserializer: GRPCProtobuf.ProtobufDeserializer<Helloworld_HelloRequest>(),
- serializer: GRPCProtobuf.ProtobufSerializer<Helloworld_HelloReply>(),
- handler: { request, context in
- try await self.sayHello(
- request: request,
- context: context
- )
- }
- )
- }
- }
- // Default implementation of streaming methods from 'StreamingServiceProtocol'.
- extension Helloworld_Greeter.ServiceProtocol {
- internal func sayHello(
- request: GRPCCore.StreamingServerRequest<Helloworld_HelloRequest>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.StreamingServerResponse<Helloworld_HelloReply> {
- let response = try await self.sayHello(
- request: GRPCCore.ServerRequest(stream: request),
- context: context
- )
- return GRPCCore.StreamingServerResponse(single: response)
- }
- }
- // Default implementation of methods from 'ServiceProtocol'.
- extension Helloworld_Greeter.SimpleServiceProtocol {
- internal func sayHello(
- request: GRPCCore.ServerRequest<Helloworld_HelloRequest>,
- context: GRPCCore.ServerContext
- ) async throws -> GRPCCore.ServerResponse<Helloworld_HelloReply> {
- return GRPCCore.ServerResponse<Helloworld_HelloReply>(
- message: try await self.sayHello(
- request: request.message,
- context: context
- ),
- metadata: [:]
- )
- }
- }
- // MARK: helloworld.Greeter (client)
- extension Helloworld_Greeter {
- /// Generated client protocol for the "helloworld.Greeter" service.
- ///
- /// You don't need to implement this protocol directly, use the generated
- /// implementation, ``Client``.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > The greeting service definition.
- internal protocol ClientProtocol: Sendable {
- /// Call the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - Parameters:
- /// - request: A request containing a single `Helloworld_HelloRequest` message.
- /// - serializer: A serializer for `Helloworld_HelloRequest` messages.
- /// - deserializer: A deserializer for `Helloworld_HelloReply` 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 sayHello<Result>(
- request: GRPCCore.ClientRequest<Helloworld_HelloRequest>,
- serializer: some GRPCCore.MessageSerializer<Helloworld_HelloRequest>,
- deserializer: some GRPCCore.MessageDeserializer<Helloworld_HelloReply>,
- options: GRPCCore.CallOptions,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Helloworld_HelloReply>) async throws -> Result
- ) async throws -> Result where Result: Sendable
- }
- /// Generated client for the "helloworld.Greeter" 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:
- /// >
- /// > The greeting service definition.
- internal 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.
- internal init(wrapping client: GRPCCore.GRPCClient) {
- self.client = client
- }
- /// Call the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - Parameters:
- /// - request: A request containing a single `Helloworld_HelloRequest` message.
- /// - serializer: A serializer for `Helloworld_HelloRequest` messages.
- /// - deserializer: A deserializer for `Helloworld_HelloReply` 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 sayHello<Result>(
- request: GRPCCore.ClientRequest<Helloworld_HelloRequest>,
- serializer: some GRPCCore.MessageSerializer<Helloworld_HelloRequest>,
- deserializer: some GRPCCore.MessageDeserializer<Helloworld_HelloReply>,
- options: GRPCCore.CallOptions = .defaults,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Helloworld_HelloReply>) async throws -> Result = { response in
- try response.message
- }
- ) async throws -> Result where Result: Sendable {
- try await self.client.unary(
- request: request,
- descriptor: Helloworld_Greeter.Method.SayHello.descriptor,
- serializer: serializer,
- deserializer: deserializer,
- options: options,
- onResponse: handleResponse
- )
- }
- }
- }
- // Helpers providing default arguments to 'ClientProtocol' methods.
- extension Helloworld_Greeter.ClientProtocol {
- /// Call the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - Parameters:
- /// - request: A request containing a single `Helloworld_HelloRequest` 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 sayHello<Result>(
- request: GRPCCore.ClientRequest<Helloworld_HelloRequest>,
- options: GRPCCore.CallOptions = .defaults,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Helloworld_HelloReply>) async throws -> Result = { response in
- try response.message
- }
- ) async throws -> Result where Result: Sendable {
- try await self.sayHello(
- request: request,
- serializer: GRPCProtobuf.ProtobufSerializer<Helloworld_HelloRequest>(),
- deserializer: GRPCProtobuf.ProtobufDeserializer<Helloworld_HelloReply>(),
- options: options,
- onResponse: handleResponse
- )
- }
- }
- // Helpers providing sugared APIs for 'ClientProtocol' methods.
- extension Helloworld_Greeter.ClientProtocol {
- /// Call the "SayHello" method.
- ///
- /// > Source IDL Documentation:
- /// >
- /// > Sends a greeting
- ///
- /// - 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 sayHello<Result>(
- _ message: Helloworld_HelloRequest,
- metadata: GRPCCore.Metadata = [:],
- options: GRPCCore.CallOptions = .defaults,
- onResponse handleResponse: @Sendable @escaping (GRPCCore.ClientResponse<Helloworld_HelloReply>) async throws -> Result = { response in
- try response.message
- }
- ) async throws -> Result where Result: Sendable {
- let request = GRPCCore.ClientRequest<Helloworld_HelloRequest>(
- message: message,
- metadata: metadata
- )
- return try await self.sayHello(
- request: request,
- options: options,
- onResponse: handleResponse
- )
- }
- }
|