| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298 |
- //
- // DO NOT EDIT.
- //
- // Generated by the protocol buffer compiler.
- // Source: route_guide.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 SwiftProtobuf
- /// Interface exported by the server.
- ///
- /// Usage: instantiate `Routeguide_RouteGuideClient`, then call methods of this protocol to make API calls.
- public protocol Routeguide_RouteGuideClientProtocol: GRPCClient {
- var serviceName: String { get }
- var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol? { get }
- func getFeature(
- _ request: Routeguide_Point,
- callOptions: CallOptions?
- ) -> UnaryCall<Routeguide_Point, Routeguide_Feature>
- func listFeatures(
- _ request: Routeguide_Rectangle,
- callOptions: CallOptions?,
- handler: @escaping (Routeguide_Feature) -> Void
- ) -> ServerStreamingCall<Routeguide_Rectangle, Routeguide_Feature>
- func recordRoute(
- callOptions: CallOptions?
- ) -> ClientStreamingCall<Routeguide_Point, Routeguide_RouteSummary>
- func routeChat(
- callOptions: CallOptions?,
- handler: @escaping (Routeguide_RouteNote) -> Void
- ) -> BidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote>
- }
- extension Routeguide_RouteGuideClientProtocol {
- public var serviceName: String {
- return "routeguide.RouteGuide"
- }
- /// A simple RPC.
- ///
- /// Obtains the feature at a given position.
- ///
- /// A feature with an empty name is returned if there's no feature at the given
- /// position.
- ///
- /// - Parameters:
- /// - request: Request to send to GetFeature.
- /// - callOptions: Call options.
- /// - Returns: A `UnaryCall` with futures for the metadata, status and response.
- public func getFeature(
- _ request: Routeguide_Point,
- callOptions: CallOptions? = nil
- ) -> UnaryCall<Routeguide_Point, Routeguide_Feature> {
- return self.makeUnaryCall(
- path: "/routeguide.RouteGuide/GetFeature",
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? []
- )
- }
- /// A server-to-client streaming RPC.
- ///
- /// Obtains the Features available within the given Rectangle. Results are
- /// streamed rather than returned at once (e.g. in a response message with a
- /// repeated field), as the rectangle may cover a large area and contain a
- /// huge number of features.
- ///
- /// - Parameters:
- /// - request: Request to send to ListFeatures.
- /// - 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 listFeatures(
- _ request: Routeguide_Rectangle,
- callOptions: CallOptions? = nil,
- handler: @escaping (Routeguide_Feature) -> Void
- ) -> ServerStreamingCall<Routeguide_Rectangle, Routeguide_Feature> {
- return self.makeServerStreamingCall(
- path: "/routeguide.RouteGuide/ListFeatures",
- request: request,
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? [],
- handler: handler
- )
- }
- /// A client-to-server streaming RPC.
- ///
- /// Accepts a stream of Points on a route being traversed, returning a
- /// RouteSummary when traversal is completed.
- ///
- /// 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 recordRoute(
- callOptions: CallOptions? = nil
- ) -> ClientStreamingCall<Routeguide_Point, Routeguide_RouteSummary> {
- return self.makeClientStreamingCall(
- path: "/routeguide.RouteGuide/RecordRoute",
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? []
- )
- }
- /// A Bidirectional streaming RPC.
- ///
- /// Accepts a stream of RouteNotes sent while a route is being traversed,
- /// while receiving other RouteNotes (e.g. from other users).
- ///
- /// 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 routeChat(
- callOptions: CallOptions? = nil,
- handler: @escaping (Routeguide_RouteNote) -> Void
- ) -> BidirectionalStreamingCall<Routeguide_RouteNote, Routeguide_RouteNote> {
- return self.makeBidirectionalStreamingCall(
- path: "/routeguide.RouteGuide/RouteChat",
- callOptions: callOptions ?? self.defaultCallOptions,
- interceptors: self.interceptors?.makeRouteChatInterceptors() ?? [],
- handler: handler
- )
- }
- }
- public protocol Routeguide_RouteGuideClientInterceptorFactoryProtocol {
- /// - Returns: Interceptors to use when invoking 'getFeature'.
- func makeGetFeatureInterceptors() -> [ClientInterceptor<Routeguide_Point, Routeguide_Feature>]
- /// - Returns: Interceptors to use when invoking 'listFeatures'.
- func makeListFeaturesInterceptors() -> [ClientInterceptor<Routeguide_Rectangle, Routeguide_Feature>]
- /// - Returns: Interceptors to use when invoking 'recordRoute'.
- func makeRecordRouteInterceptors() -> [ClientInterceptor<Routeguide_Point, Routeguide_RouteSummary>]
- /// - Returns: Interceptors to use when invoking 'routeChat'.
- func makeRouteChatInterceptors() -> [ClientInterceptor<Routeguide_RouteNote, Routeguide_RouteNote>]
- }
- public final class Routeguide_RouteGuideClient: Routeguide_RouteGuideClientProtocol {
- public let channel: GRPCChannel
- public var defaultCallOptions: CallOptions
- public var interceptors: Routeguide_RouteGuideClientInterceptorFactoryProtocol?
- /// Creates a client for the routeguide.RouteGuide 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: Routeguide_RouteGuideClientInterceptorFactoryProtocol? = nil
- ) {
- self.channel = channel
- self.defaultCallOptions = defaultCallOptions
- self.interceptors = interceptors
- }
- }
- /// Interface exported by the server.
- ///
- /// To build a server, implement a class that conforms to this protocol.
- public protocol Routeguide_RouteGuideProvider: CallHandlerProvider {
- var interceptors: Routeguide_RouteGuideServerInterceptorFactoryProtocol? { get }
- /// A simple RPC.
- ///
- /// Obtains the feature at a given position.
- ///
- /// A feature with an empty name is returned if there's no feature at the given
- /// position.
- func getFeature(request: Routeguide_Point, context: StatusOnlyCallContext) -> EventLoopFuture<Routeguide_Feature>
- /// A server-to-client streaming RPC.
- ///
- /// Obtains the Features available within the given Rectangle. Results are
- /// streamed rather than returned at once (e.g. in a response message with a
- /// repeated field), as the rectangle may cover a large area and contain a
- /// huge number of features.
- func listFeatures(request: Routeguide_Rectangle, context: StreamingResponseCallContext<Routeguide_Feature>) -> EventLoopFuture<GRPCStatus>
- /// A client-to-server streaming RPC.
- ///
- /// Accepts a stream of Points on a route being traversed, returning a
- /// RouteSummary when traversal is completed.
- func recordRoute(context: UnaryResponseCallContext<Routeguide_RouteSummary>) -> EventLoopFuture<(StreamEvent<Routeguide_Point>) -> Void>
- /// A Bidirectional streaming RPC.
- ///
- /// Accepts a stream of RouteNotes sent while a route is being traversed,
- /// while receiving other RouteNotes (e.g. from other users).
- func routeChat(context: StreamingResponseCallContext<Routeguide_RouteNote>) -> EventLoopFuture<(StreamEvent<Routeguide_RouteNote>) -> Void>
- }
- extension Routeguide_RouteGuideProvider {
- public var serviceName: Substring { return "routeguide.RouteGuide" }
- /// 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 "GetFeature":
- return UnaryServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Routeguide_Point>(),
- responseSerializer: ProtobufSerializer<Routeguide_Feature>(),
- interceptors: self.interceptors?.makeGetFeatureInterceptors() ?? [],
- userFunction: self.getFeature(request:context:)
- )
- case "ListFeatures":
- return ServerStreamingServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Routeguide_Rectangle>(),
- responseSerializer: ProtobufSerializer<Routeguide_Feature>(),
- interceptors: self.interceptors?.makeListFeaturesInterceptors() ?? [],
- userFunction: self.listFeatures(request:context:)
- )
- case "RecordRoute":
- return ClientStreamingServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Routeguide_Point>(),
- responseSerializer: ProtobufSerializer<Routeguide_RouteSummary>(),
- interceptors: self.interceptors?.makeRecordRouteInterceptors() ?? [],
- observerFactory: self.recordRoute(context:)
- )
- case "RouteChat":
- return BidirectionalStreamingServerHandler(
- context: context,
- requestDeserializer: ProtobufDeserializer<Routeguide_RouteNote>(),
- responseSerializer: ProtobufSerializer<Routeguide_RouteNote>(),
- interceptors: self.interceptors?.makeRouteChatInterceptors() ?? [],
- observerFactory: self.routeChat(context:)
- )
- default:
- return nil
- }
- }
- }
- public protocol Routeguide_RouteGuideServerInterceptorFactoryProtocol {
- /// - Returns: Interceptors to use when handling 'getFeature'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeGetFeatureInterceptors() -> [ServerInterceptor<Routeguide_Point, Routeguide_Feature>]
- /// - Returns: Interceptors to use when handling 'listFeatures'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeListFeaturesInterceptors() -> [ServerInterceptor<Routeguide_Rectangle, Routeguide_Feature>]
- /// - Returns: Interceptors to use when handling 'recordRoute'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeRecordRouteInterceptors() -> [ServerInterceptor<Routeguide_Point, Routeguide_RouteSummary>]
- /// - Returns: Interceptors to use when handling 'routeChat'.
- /// Defaults to calling `self.makeInterceptors()`.
- func makeRouteChatInterceptors() -> [ServerInterceptor<Routeguide_RouteNote, Routeguide_RouteNote>]
- }
|