// // DO NOT EDIT. // // Generated by the protocol buffer compiler. // Source: b.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 /// Usage: instantiate B_ServiceBClient, then call methods of this protocol to make API calls. internal protocol B_ServiceBClientProtocol: GRPCClient { var interceptors: B_ServiceBClientInterceptorFactoryProtocol? { get } func callServiceB( _ request: B_MessageB, callOptions: CallOptions? ) -> UnaryCall } extension B_ServiceBClientProtocol { /// Unary call to CallServiceB /// /// - Parameters: /// - request: Request to send to CallServiceB. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. internal func callServiceB( _ request: B_MessageB, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/b.ServiceB/CallServiceB", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeCallServiceBInterceptors() ?? [] ) } } internal protocol B_ServiceBClientInterceptorFactoryProtocol { /// Makes an array of generic interceptors. The per-method interceptor /// factories default to calling this function and it therefore provides a /// convenient way of setting interceptors for all methods on a client. /// - Returns: An array of interceptors generic over `Request` and `Response`. /// Defaults to an empty array. func makeInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'callServiceB'. /// Defaults to calling `self.makeInterceptors()`. func makeCallServiceBInterceptors() -> [ClientInterceptor] } extension B_ServiceBClientInterceptorFactoryProtocol { internal func makeInterceptors() -> [ClientInterceptor] { return [] } internal func makeCallServiceBInterceptors() -> [ClientInterceptor] { return self.makeInterceptors() } } internal final class B_ServiceBClient: B_ServiceBClientProtocol { internal let channel: GRPCChannel internal var defaultCallOptions: CallOptions internal var interceptors: B_ServiceBClientInterceptorFactoryProtocol? /// Creates a client for the b.ServiceB 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: B_ServiceBClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self.defaultCallOptions = defaultCallOptions self.interceptors = interceptors } } /// To build a server, implement a class that conforms to this protocol. internal protocol B_ServiceBProvider: CallHandlerProvider { func callServiceB(request: B_MessageB, context: StatusOnlyCallContext) -> EventLoopFuture } extension B_ServiceBProvider { internal var serviceName: Substring { return "b.ServiceB" } /// 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 handleMethod(_ methodName: Substring, callHandlerContext: CallHandlerContext) -> GRPCCallHandler? { switch methodName { case "CallServiceB": return CallHandlerFactory.makeUnary(callHandlerContext: callHandlerContext) { context in return { request in self.callServiceB(request: request, context: context) } } default: return nil } } }