| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- //
- // DO NOT EDIT.
- // swift-format-ignore-file
- //
- // Generated by the protocol buffer compiler.
- // Source: echo.proto
- //
- import GRPC
- import NIO
- import SwiftProtobuf
- /// Usage: instantiate `Echo_EchoClient`, then call methods of this protocol to make API calls.
- internal 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 {
- internal 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.
- internal func get(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil
- ) -> UnaryCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeUnaryCall(
- path: "/echo.Echo/Get",
- 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.
- internal func expand(
- _ request: Echo_EchoRequest,
- callOptions: CallOptions? = nil,
- handler: @escaping (Echo_EchoResponse) -> Void
- ) -> ServerStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeServerStreamingCall(
- path: "/echo.Echo/Expand",
- 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.
- internal func collect(
- callOptions: CallOptions? = nil
- ) -> ClientStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeClientStreamingCall(
- path: "/echo.Echo/Collect",
- 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.
- internal func update(
- callOptions: CallOptions? = nil,
- handler: @escaping (Echo_EchoResponse) -> Void
- ) -> BidirectionalStreamingCall<Echo_EchoRequest, Echo_EchoResponse> {
- return self.makeBidirectionalStreamingCall(
- path: "/echo.Echo/Update",
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeUpdateInterceptors() ?? [],
- handler: handler
- )
- }
- }
- internal protocol Echo_EchoClientInterceptorFactoryProtocol {
- /// - 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>]
- }
- internal final class Echo_EchoClient: Echo_EchoClientProtocol {
- internal let channel: GRPCChannel
- internal var defaultCallOptions: CallOptions
- internal 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.
- internal init(
- channel: GRPCChannel,
- defaultCallOptions: CallOptions = CallOptions(),
- interceptors: Echo_EchoClientInterceptorFactoryProtocol? = nil
- ) {
- self.channel = channel
- self.defaultCallOptions = defaultCallOptions
- self.interceptors = interceptors
- }
- }
- /// To build a server, implement a class that conforms to this protocol.
- internal 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 {
- internal var serviceName: Substring { return "echo.Echo" }
- /// Determines, calls and returns the appropriate request handler, depending on the request's method.
- /// Returns nil for methods not handled by this service.
- internal 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
- }
- }
- }
- internal protocol Echo_EchoServerInterceptorFactoryProtocol {
- /// - 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>]
- }
|