| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764 |
- //
- // DO NOT EDIT.
- //
- // Generated by the protocol buffer compiler.
- // Source: echo.proto
- //
- //
- // Copyright 2018, 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.
- //
- import GRPC
- import NIO
- import NIOConcurrencyHelpers
- import SwiftProtobuf
- /// Usage: instantiate `Echo_EchoClient`, then call methods of this protocol to make API calls.
- public protocol Echo_EchoClientProtocol: GRPCClient {
- var serviceName: String { get }
- var interceptors: Echo_EchoClientInterceptorFactoryProtocol? { get }
- func get(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions?
- ) -> UnaryCall<Echo_EchoRequest, Echo_EchoResponse>
- func expand(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions?,
- handler: @escaping (Echo_EchoResponse) -> Void
- ) -> ServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
- func collect(
- callOptions: CallOptions?
- ) -> ClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
- func update(
- callOptions: CallOptions?,
- handler: @escaping (Echo_EchoResponse) -> Void
- ) -> BidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
- }
- extension Echo_EchoClientProtocol {
- public var serviceName: String {
- return "echo.Echo"
- }
- /// Immediately returns an echo of a request.
- ///
- /// - Parameters:
- /// - request: Request to send to Get.
- /// - callOptions: Call options.
- /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
- public func get(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil
- ) -> UnaryCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeUnaryCall(
- path: Echo_EchoClientMetadata.Methods.get.path,
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeGetInterceptors() ?? []
- )
- }
- /// Splits a request into words and returns each word in a stream of messages.
- ///
- /// - Parameters:
- /// - request: Request to send to Expand.
- /// - callOptions: Call options.
- /// - handler: A closure called when each response is received from the server.
- /// - Returns: A `ServerStreamingCall` with futures for the metadata and status.
- public func expand(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil,
- handler: @escaping (Echo_EchoResponse) -> Void
- ) -> ServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeServerStreamingCall(
- path: Echo_EchoClientMetadata.Methods.expand.path,
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeExpandInterceptors() ?? [],
- handler: handler
- )
- }
- /// Collects a stream of messages and returns them concatenated when the caller closes.
- ///
- /// Callers should use the `send` method on the returned object to send messages
- /// to the server. The caller should send an `.end` after the final message has been sent.
- ///
- /// - Parameters:
- /// - callOptions: Call options.
- /// - Returns: A `ClientStreamingCall` with futures for the metadata, status and response.
- public func collect(
- callOptions: CallOptions? = nil
- ) -> ClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeClientStreamingCall(
- path: Echo_EchoClientMetadata.Methods.collect.path,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeCollectInterceptors() ?? []
- )
- }
- /// Streams back messages as they are received in an input stream.
- ///
- /// Callers should use the `send` method on the returned object to send messages
- /// to the server. The caller should send an `.end` after the final message has been sent.
- ///
- /// - Parameters:
- /// - callOptions: Call options.
- /// - handler: A closure called when each response is received from the server.
- /// - Returns: A `ClientStreamingCall` with futures for the metadata and status.
- public func update(
- callOptions: CallOptions? = nil,
- handler: @escaping (Echo_EchoResponse) -> Void
- ) -> BidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeBidirectionalStreamingCall(
- path: Echo_EchoClientMetadata.Methods.update.path,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
- handler: handler
- )
- }
- }
- @available(*, deprecated)
- extension Echo_EchoClient: @unchecked Sendable {}
- @available(*, deprecated, renamed: "Echo_EchoNIOClient")
- public final class Echo_EchoClient: Echo_EchoClientProtocol {
- private let lock = Lock()
- private var _defaultCallOptions: CallOptions
- private var _interceptors: Echo_EchoClientInterceptorFactoryProtocol?
- public let channel: GRPCChannel
- public var defaultCallOptions: CallOptions {
- get { self.lock.withLock { return self._defaultCallOptions } }
- set { self.lock.withLockVoid { self._defaultCallOptions = newValue } }
- }
- public var interceptors: Echo_EchoClientInterceptorFactoryProtocol? {
- get { self.lock.withLock { return self._interceptors } }
- set { self.lock.withLockVoid { self._interceptors = newValue } }
- }
- /// Creates a client for the echo.Echo service.
- ///
- /// - Parameters:
- /// - channel: `GRPCChannel` to the service host.
- /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
- /// - interceptors: A factory providing interceptors for each RPC.
- public init(
- channel: GRPCChannel,
- defaultCallOptions: CallOptions = CallOptions(),
- interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
- ) {
- self.channel = channel
- self._defaultCallOptions = defaultCallOptions
- self._interceptors = interceptors
- }
- }
- public struct Echo_EchoNIOClient: Echo_EchoClientProtocol {
- public var channel: GRPCChannel
- public var defaultCallOptions: CallOptions
- public var interceptors: Echo_EchoClientInterceptorFactoryProtocol?
- /// Creates a client for the echo.Echo service.
- ///
- /// - Parameters:
- /// - channel: `GRPCChannel` to the service host.
- /// - defaultCallOptions: Options to use for each service call if the user doesn't provide them.
- /// - interceptors: A factory providing interceptors for each RPC.
- public init(
- channel: GRPCChannel,
- defaultCallOptions: CallOptions = CallOptions(),
- interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
- ) {
- self.channel = channel
- self.defaultCallOptions = defaultCallOptions
- self.interceptors = interceptors
- }
- }
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- public protocol Echo_EchoAsyncClientProtocol: GRPCClient {
- static var serviceDescriptor: GRPCServiceDescriptor { get }
- var interceptors: Echo_EchoClientInterceptorFactoryProtocol? { get }
- func makeGetCall(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions?
- ) -> GRPCAsyncUnaryCall<Echo_EchoRequest, Echo_EchoResponse>
- func makeExpandCall(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions?
- ) -> GRPCAsyncServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
- func makeCollectCall(
- callOptions: CallOptions?
- ) -> GRPCAsyncClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
- func makeUpdateCall(
- callOptions: CallOptions?
- ) -> GRPCAsyncBidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse>
- }
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- extension Echo_EchoAsyncClientProtocol {
- public static var serviceDescriptor: GRPCServiceDescriptor {
- return Echo_EchoClientMetadata.serviceDescriptor
- }
- public var interceptors: Echo_EchoClientInterceptorFactoryProtocol? {
- return nil
- }
- public func makeGetCall(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncUnaryCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeAsyncUnaryCall(
- path: Echo_EchoClientMetadata.Methods.get.path,
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeGetInterceptors() ?? []
- )
- }
- public func makeExpandCall(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeAsyncServerStreamingCall(
- path: Echo_EchoClientMetadata.Methods.expand.path,
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeExpandInterceptors() ?? []
- )
- }
- public func makeCollectCall(
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeAsyncClientStreamingCall(
- path: Echo_EchoClientMetadata.Methods.collect.path,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeCollectInterceptors() ?? []
- )
- }
- public func makeUpdateCall(
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncBidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeAsyncBidirectionalStreamingCall(
- path: Echo_EchoClientMetadata.Methods.update.path,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? []
- )
- }
- }
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- extension Echo_EchoAsyncClientProtocol {
- public func get(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil
- ) async throws -> Echo_EchoResponse {
- return try await self.performAsyncUnaryCall(
- path: Echo_EchoClientMetadata.Methods.get.path,
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeGetInterceptors() ?? []
- )
- }
- public func expand(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncResponseStream<Echo_EchoResponse> {
- return self.performAsyncServerStreamingCall(
- path: Echo_EchoClientMetadata.Methods.expand.path,
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeExpandInterceptors() ?? []
- )
- }
- public func collect<RequestStream>(
- _ requests: RequestStream,
- callOptions: CallOptions? = nil
- ) async throws -> Echo_EchoResponse where RequestStream: Sequence, RequestStream.Element == Echo_EchoRequest {
- return try await self.performAsyncClientStreamingCall(
- path: Echo_EchoClientMetadata.Methods.collect.path,
- requests: requests,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeCollectInterceptors() ?? []
- )
- }
- public func collect<RequestStream>(
- _ requests: RequestStream,
- callOptions: CallOptions? = nil
- ) async throws -> Echo_EchoResponse where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Echo_EchoRequest {
- return try await self.performAsyncClientStreamingCall(
- path: Echo_EchoClientMetadata.Methods.collect.path,
- requests: requests,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeCollectInterceptors() ?? []
- )
- }
- public func update<RequestStream>(
- _ requests: RequestStream,
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncResponseStream<Echo_EchoResponse> where RequestStream: Sequence, RequestStream.Element == Echo_EchoRequest {
- return self.performAsyncBidirectionalStreamingCall(
- path: Echo_EchoClientMetadata.Methods.update.path,
- requests: requests,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? []
- )
- }
- public func update<RequestStream>(
- _ requests: RequestStream,
- callOptions: CallOptions? = nil
- ) -> GRPCAsyncResponseStream<Echo_EchoResponse> where RequestStream: AsyncSequence & Sendable, RequestStream.Element == Echo_EchoRequest {
- return self.performAsyncBidirectionalStreamingCall(
- path: Echo_EchoClientMetadata.Methods.update.path,
- requests: requests,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? []
- )
- }
- }
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- public struct Echo_EchoAsyncClient: Echo_EchoAsyncClientProtocol {
- public var channel: GRPCChannel
- public var defaultCallOptions: CallOptions
- public var interceptors: Echo_EchoClientInterceptorFactoryProtocol?
- public init(
- channel: GRPCChannel,
- defaultCallOptions: CallOptions = CallOptions(),
- interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
- ) {
- self.channel = channel
- self.defaultCallOptions = defaultCallOptions
- self.interceptors = interceptors
- }
- }
- public protocol Echo_EchoClientInterceptorFactoryProtocol: Sendable {
- /// - Returns: Interceptors to use when invoking 'get'.
- func makeGetInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- /// - Returns: Interceptors to use when invoking 'expand'.
- func makeExpandInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- /// - Returns: Interceptors to use when invoking 'collect'.
- func makeCollectInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- /// - Returns: Interceptors to use when invoking 'update'.
- func makeUpdateInterceptors() -> [ClientInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- }
- public enum Echo_EchoClientMetadata {
- public static let serviceDescriptor = GRPCServiceDescriptor(
- name: "Echo",
- fullName: "echo.Echo",
- methods: [
- Echo_EchoClientMetadata.Methods.get,
- Echo_EchoClientMetadata.Methods.expand,
- Echo_EchoClientMetadata.Methods.collect,
- Echo_EchoClientMetadata.Methods.update,
- ]
- )
- public enum Methods {
- public static let get = GRPCMethodDescriptor(
- name: "Get",
- path: "/echo.Echo/Get",
- type: GRPCCallType.unary
- )
- public static let expand = GRPCMethodDescriptor(
- name: "Expand",
- path: "/echo.Echo/Expand",
- type: GRPCCallType.serverStreaming
- )
- public static let collect = GRPCMethodDescriptor(
- name: "Collect",
- path: "/echo.Echo/Collect",
- type: GRPCCallType.clientStreaming
- )
- public static let update = GRPCMethodDescriptor(
- name: "Update",
- path: "/echo.Echo/Update",
- type: GRPCCallType.bidirectionalStreaming
- )
- }
- }
- @available(swift, deprecated: 5.6)
- extension Echo_EchoTestClient: @unchecked Sendable {}
- @available(swift, deprecated: 5.6, message: "Test clients are not Sendable but the 'GRPCClient' API requires clients to be Sendable. Using a localhost client and server is the recommended alternative.")
- public final class Echo_EchoTestClient: Echo_EchoClientProtocol {
- private let fakeChannel: FakeChannel
- public var defaultCallOptions: CallOptions
- public var interceptors: Echo_EchoClientInterceptorFactoryProtocol?
- public var channel: GRPCChannel {
- return self.fakeChannel
- }
- public init(
- fakeChannel: FakeChannel = FakeChannel(),
- defaultCallOptions callOptions: CallOptions = CallOptions(),
- interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
- ) {
- self.fakeChannel = fakeChannel
- self.defaultCallOptions = callOptions
- self.interceptors = interceptors
- }
- /// Make a unary response for the Get RPC. This must be called
- /// before calling 'get'. See also 'FakeUnaryResponse'.
- ///
- /// - Parameter requestHandler: a handler for request parts sent by the RPC.
- public func makeGetResponseStream(
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) -> FakeUnaryResponse<Echo_EchoRequest, Echo_EchoResponse> {
- return self.fakeChannel.makeFakeUnaryResponse(path: Echo_EchoClientMetadata.Methods.get.path, requestHandler: requestHandler)
- }
- public func enqueueGetResponse(
- _ response: Echo_EchoResponse,
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) {
- let stream = self.makeGetResponseStream(requestHandler)
- // This is the only operation on the stream; try! is fine.
- try! stream.sendMessage(response)
- }
- /// Returns true if there are response streams enqueued for 'Get'
- public var hasGetResponsesRemaining: Bool {
- return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.get.path)
- }
- /// Make a streaming response for the Expand RPC. This must be called
- /// before calling 'expand'. See also 'FakeStreamingResponse'.
- ///
- /// - Parameter requestHandler: a handler for request parts sent by the RPC.
- public func makeExpandResponseStream(
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) -> FakeStreamingResponse<Echo_EchoRequest, Echo_EchoResponse> {
- return self.fakeChannel.makeFakeStreamingResponse(path: Echo_EchoClientMetadata.Methods.expand.path, requestHandler: requestHandler)
- }
- public func enqueueExpandResponses(
- _ responses: [Echo_EchoResponse],
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) {
- let stream = self.makeExpandResponseStream(requestHandler)
- // These are the only operation on the stream; try! is fine.
- responses.forEach { try! stream.sendMessage($0) }
- try! stream.sendEnd()
- }
- /// Returns true if there are response streams enqueued for 'Expand'
- public var hasExpandResponsesRemaining: Bool {
- return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.expand.path)
- }
- /// Make a unary response for the Collect RPC. This must be called
- /// before calling 'collect'. See also 'FakeUnaryResponse'.
- ///
- /// - Parameter requestHandler: a handler for request parts sent by the RPC.
- public func makeCollectResponseStream(
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) -> FakeUnaryResponse<Echo_EchoRequest, Echo_EchoResponse> {
- return self.fakeChannel.makeFakeUnaryResponse(path: Echo_EchoClientMetadata.Methods.collect.path, requestHandler: requestHandler)
- }
- public func enqueueCollectResponse(
- _ response: Echo_EchoResponse,
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) {
- let stream = self.makeCollectResponseStream(requestHandler)
- // This is the only operation on the stream; try! is fine.
- try! stream.sendMessage(response)
- }
- /// Returns true if there are response streams enqueued for 'Collect'
- public var hasCollectResponsesRemaining: Bool {
- return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.collect.path)
- }
- /// Make a streaming response for the Update RPC. This must be called
- /// before calling 'update'. See also 'FakeStreamingResponse'.
- ///
- /// - Parameter requestHandler: a handler for request parts sent by the RPC.
- public func makeUpdateResponseStream(
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) -> FakeStreamingResponse<Echo_EchoRequest, Echo_EchoResponse> {
- return self.fakeChannel.makeFakeStreamingResponse(path: Echo_EchoClientMetadata.Methods.update.path, requestHandler: requestHandler)
- }
- public func enqueueUpdateResponses(
- _ responses: [Echo_EchoResponse],
- _ requestHandler: @escaping (FakeRequestPart<Echo_EchoRequest>) -> () = { _ in }
- ) {
- let stream = self.makeUpdateResponseStream(requestHandler)
- // These are the only operation on the stream; try! is fine.
- responses.forEach { try! stream.sendMessage($0) }
- try! stream.sendEnd()
- }
- /// Returns true if there are response streams enqueued for 'Update'
- public var hasUpdateResponsesRemaining: Bool {
- return self.fakeChannel.hasFakeResponseEnqueued(forPath: Echo_EchoClientMetadata.Methods.update.path)
- }
- }
- /// To build a server, implement a class that conforms to this protocol.
- public protocol Echo_EchoProvider: CallHandlerProvider {
- var interceptors: Echo_EchoServerInterceptorFactoryProtocol? { get }
- /// Immediately returns an echo of a request.
- func get(request: Echo_EchoRequest, context: StatusOnlyCallContext) -> EventLoopFuture<Echo_EchoResponse>
- /// Splits a request into words and returns each word in a stream of messages.
- func expand(request: Echo_EchoRequest, context: StreamingResponseCallContext<Echo_EchoResponse>) -> EventLoopFuture<GRPCStatus>
- /// Collects a stream of messages and returns them concatenated when the caller closes.
- func collect(context: UnaryResponseCallContext<Echo_EchoResponse>) -> EventLoopFuture<(StreamEvent<Echo_EchoRequest>) -> Void>
- /// Streams back messages as they are received in an input stream.
- func update(context: StreamingResponseCallContext<Echo_EchoResponse>) -> EventLoopFuture<(StreamEvent<Echo_EchoRequest>) -> Void>
- }
- extension Echo_EchoProvider {
- public var serviceName: Substring {
- return Echo_EchoServerMetadata.serviceDescriptor.fullName[...]
- }
- /// Determines, calls and returns the appropriate request handler, depending on the request's method.
- /// Returns nil for methods not handled by this service.
- public func handle(
- method name: Substring,
- context: CallHandlerContext
- ) -> GRPCServerHandlerProtocol? {
- switch name {
- case "Get":
- return UnaryServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeGetInterceptors() ?? [],
- userFunction: self.get(request:context:)
- )
- case "Expand":
- return ServerStreamingServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeExpandInterceptors() ?? [],
- userFunction: self.expand(request:context:)
- )
- case "Collect":
- return ClientStreamingServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeCollectInterceptors() ?? [],
- observerFactory: self.collect(context:)
- )
- case "Update":
- return BidirectionalStreamingServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
- observerFactory: self.update(context:)
- )
- default:
- return nil
- }
- }
- }
- /// To implement a server, implement an object which conforms to this protocol.
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- public protocol Echo_EchoAsyncProvider: CallHandlerProvider, Sendable {
- static var serviceDescriptor: GRPCServiceDescriptor { get }
- var interceptors: Echo_EchoServerInterceptorFactoryProtocol? { get }
- /// Immediately returns an echo of a request.
- func get(
- request: Echo_EchoRequest,
- context: GRPCAsyncServerCallContext
- ) async throws -> Echo_EchoResponse
- /// Splits a request into words and returns each word in a stream of messages.
- func expand(
- request: Echo_EchoRequest,
- responseStream: GRPCAsyncResponseStreamWriter<Echo_EchoResponse>,
- context: GRPCAsyncServerCallContext
- ) async throws
- /// Collects a stream of messages and returns them concatenated when the caller closes.
- func collect(
- requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
- context: GRPCAsyncServerCallContext
- ) async throws -> Echo_EchoResponse
- /// Streams back messages as they are received in an input stream.
- func update(
- requestStream: GRPCAsyncRequestStream<Echo_EchoRequest>,
- responseStream: GRPCAsyncResponseStreamWriter<Echo_EchoResponse>,
- context: GRPCAsyncServerCallContext
- ) async throws
- }
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- extension Echo_EchoAsyncProvider {
- public static var serviceDescriptor: GRPCServiceDescriptor {
- return Echo_EchoServerMetadata.serviceDescriptor
- }
- public var serviceName: Substring {
- return Echo_EchoServerMetadata.serviceDescriptor.fullName[...]
- }
- public var interceptors: Echo_EchoServerInterceptorFactoryProtocol? {
- return nil
- }
- public func handle(
- method name: Substring,
- context: CallHandlerContext
- ) -> GRPCServerHandlerProtocol? {
- switch name {
- case "Get":
- return GRPCAsyncServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeGetInterceptors() ?? [],
- wrapping: { try await self.get(request: $0, context: $1) }
- )
- case "Expand":
- return GRPCAsyncServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeExpandInterceptors() ?? [],
- wrapping: { try await self.expand(request: $0, responseStream: $1, context: $2) }
- )
- case "Collect":
- return GRPCAsyncServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeCollectInterceptors() ?? [],
- wrapping: { try await self.collect(requestStream: $0, context: $1) }
- )
- case "Update":
- return GRPCAsyncServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Echo_EchoRequest>(),
- responseSerializer: ProtobufSerializer<Echo_EchoResponse>(),
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
- wrapping: { try await self.update(requestStream: $0, responseStream: $1, context: $2) }
- )
- default:
- return nil
- }
- }
- }
- public protocol Echo_EchoServerInterceptorFactoryProtocol: Sendable {
- /// - Returns: Interceptors to use when handling 'get'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeGetInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- /// - Returns: Interceptors to use when handling 'expand'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeExpandInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- /// - Returns: Interceptors to use when handling 'collect'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeCollectInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- /// - Returns: Interceptors to use when handling 'update'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeUpdateInterceptors() -> [ServerInterceptor<Echo_EchoRequest, Echo_EchoResponse>]
- }
- public enum Echo_EchoServerMetadata {
- public static let serviceDescriptor = GRPCServiceDescriptor(
- name: "Echo",
- fullName: "echo.Echo",
- methods: [
- Echo_EchoServerMetadata.Methods.get,
- Echo_EchoServerMetadata.Methods.expand,
- Echo_EchoServerMetadata.Methods.collect,
- Echo_EchoServerMetadata.Methods.update,
- ]
- )
- public enum Methods {
- public static let get = GRPCMethodDescriptor(
- name: "Get",
- path: "/echo.Echo/Get",
- type: GRPCCallType.unary
- )
- public static let expand = GRPCMethodDescriptor(
- name: "Expand",
- path: "/echo.Echo/Expand",
- type: GRPCCallType.serverStreaming
- )
- public static let collect = GRPCMethodDescriptor(
- name: "Collect",
- path: "/echo.Echo/Collect",
- type: GRPCCallType.clientStreaming
- )
- public static let update = GRPCMethodDescriptor(
- name: "Update",
- path: "/echo.Echo/Update",
- type: GRPCCallType.bidirectionalStreaming
- )
- }
- }
|