// // DO NOT EDIT. // // Generated by the protocol buffer compiler. // Source: src/proto/grpc/testing/test.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 /// A simple service to test the various types of RPCs and experiment with /// performance with various types of payload. /// /// Usage: instantiate `Grpc_Testing_TestServiceClient`, then call methods of this protocol to make API calls. public protocol Grpc_Testing_TestServiceClientProtocol: GRPCClient { var serviceName: String { get } var interceptors: Grpc_Testing_TestServiceClientInterceptorFactoryProtocol? { get } func emptyCall( _ request: Grpc_Testing_Empty, callOptions: CallOptions? ) -> UnaryCall func unaryCall( _ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? ) -> UnaryCall func cacheableUnaryCall( _ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? ) -> UnaryCall func streamingOutputCall( _ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void ) -> ServerStreamingCall func streamingInputCall( callOptions: CallOptions? ) -> ClientStreamingCall func fullDuplexCall( callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void ) -> BidirectionalStreamingCall func halfDuplexCall( callOptions: CallOptions?, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void ) -> BidirectionalStreamingCall func unimplementedCall( _ request: Grpc_Testing_Empty, callOptions: CallOptions? ) -> UnaryCall } extension Grpc_Testing_TestServiceClientProtocol { public var serviceName: String { return "grpc.testing.TestService" } /// One empty request followed by one empty response. /// /// - Parameters: /// - request: Request to send to EmptyCall. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func emptyCall( _ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.TestService/EmptyCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeEmptyCallInterceptors() ?? [] ) } /// One request followed by one response. /// /// - Parameters: /// - request: Request to send to UnaryCall. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func unaryCall( _ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.TestService/UnaryCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeUnaryCallInterceptors() ?? [] ) } /// One request followed by one response. Response has cache control /// headers set such that a caching HTTP proxy (such as GFE) can /// satisfy subsequent requests. /// /// - Parameters: /// - request: Request to send to CacheableUnaryCall. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func cacheableUnaryCall( _ request: Grpc_Testing_SimpleRequest, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.TestService/CacheableUnaryCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeCacheableUnaryCallInterceptors() ?? [] ) } /// One request followed by a sequence of responses (streamed download). /// The server returns the payload with client desired type and sizes. /// /// - Parameters: /// - request: Request to send to StreamingOutputCall. /// - 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 streamingOutputCall( _ request: Grpc_Testing_StreamingOutputCallRequest, callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void ) -> ServerStreamingCall { return self.makeServerStreamingCall( path: "/grpc.testing.TestService/StreamingOutputCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStreamingOutputCallInterceptors() ?? [], handler: handler ) } /// A sequence of requests followed by one response (streamed upload). /// The server returns the aggregated size of client payload as the result. /// /// 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 streamingInputCall( callOptions: CallOptions? = nil ) -> ClientStreamingCall { return self.makeClientStreamingCall( path: "/grpc.testing.TestService/StreamingInputCall", callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStreamingInputCallInterceptors() ?? [] ) } /// A sequence of requests with each request served by the server immediately. /// As one request could lead to multiple responses, this interface /// demonstrates the idea of full duplexing. /// /// 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 fullDuplexCall( callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void ) -> BidirectionalStreamingCall { return self.makeBidirectionalStreamingCall( path: "/grpc.testing.TestService/FullDuplexCall", callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeFullDuplexCallInterceptors() ?? [], handler: handler ) } /// A sequence of requests followed by a sequence of responses. /// The server buffers all the client requests and then serves them in order. A /// stream of responses are returned to the client when the server starts with /// first request. /// /// 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 halfDuplexCall( callOptions: CallOptions? = nil, handler: @escaping (Grpc_Testing_StreamingOutputCallResponse) -> Void ) -> BidirectionalStreamingCall { return self.makeBidirectionalStreamingCall( path: "/grpc.testing.TestService/HalfDuplexCall", callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeHalfDuplexCallInterceptors() ?? [], handler: handler ) } /// The test server will not implement this method. It will be used /// to test the behavior when clients call unimplemented methods. /// /// - Parameters: /// - request: Request to send to UnimplementedCall. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func unimplementedCall( _ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.TestService/UnimplementedCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeUnimplementedCallInterceptors() ?? [] ) } } public protocol Grpc_Testing_TestServiceClientInterceptorFactoryProtocol { /// - Returns: Interceptors to use when invoking 'emptyCall'. func makeEmptyCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'unaryCall'. func makeUnaryCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'cacheableUnaryCall'. func makeCacheableUnaryCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'streamingOutputCall'. func makeStreamingOutputCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'streamingInputCall'. func makeStreamingInputCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'fullDuplexCall'. func makeFullDuplexCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'halfDuplexCall'. func makeHalfDuplexCallInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'unimplementedCall'. func makeUnimplementedCallInterceptors() -> [ClientInterceptor] } public final class Grpc_Testing_TestServiceClient: Grpc_Testing_TestServiceClientProtocol { public let channel: GRPCChannel public var defaultCallOptions: CallOptions public var interceptors: Grpc_Testing_TestServiceClientInterceptorFactoryProtocol? /// Creates a client for the grpc.testing.TestService 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: Grpc_Testing_TestServiceClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self.defaultCallOptions = defaultCallOptions self.interceptors = interceptors } } /// A simple service NOT implemented at servers so clients can test for /// that case. /// /// Usage: instantiate `Grpc_Testing_UnimplementedServiceClient`, then call methods of this protocol to make API calls. public protocol Grpc_Testing_UnimplementedServiceClientProtocol: GRPCClient { var serviceName: String { get } var interceptors: Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol? { get } func unimplementedCall( _ request: Grpc_Testing_Empty, callOptions: CallOptions? ) -> UnaryCall } extension Grpc_Testing_UnimplementedServiceClientProtocol { public var serviceName: String { return "grpc.testing.UnimplementedService" } /// A call that no server should implement /// /// - Parameters: /// - request: Request to send to UnimplementedCall. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func unimplementedCall( _ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.UnimplementedService/UnimplementedCall", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeUnimplementedCallInterceptors() ?? [] ) } } public protocol Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol { /// - Returns: Interceptors to use when invoking 'unimplementedCall'. func makeUnimplementedCallInterceptors() -> [ClientInterceptor] } public final class Grpc_Testing_UnimplementedServiceClient: Grpc_Testing_UnimplementedServiceClientProtocol { public let channel: GRPCChannel public var defaultCallOptions: CallOptions public var interceptors: Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol? /// Creates a client for the grpc.testing.UnimplementedService 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: Grpc_Testing_UnimplementedServiceClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self.defaultCallOptions = defaultCallOptions self.interceptors = interceptors } } /// A service used to control reconnect server. /// /// Usage: instantiate `Grpc_Testing_ReconnectServiceClient`, then call methods of this protocol to make API calls. public protocol Grpc_Testing_ReconnectServiceClientProtocol: GRPCClient { var serviceName: String { get } var interceptors: Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol? { get } func start( _ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? ) -> UnaryCall func stop( _ request: Grpc_Testing_Empty, callOptions: CallOptions? ) -> UnaryCall } extension Grpc_Testing_ReconnectServiceClientProtocol { public var serviceName: String { return "grpc.testing.ReconnectService" } /// Unary call to Start /// /// - Parameters: /// - request: Request to send to Start. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func start( _ request: Grpc_Testing_ReconnectParams, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.ReconnectService/Start", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStartInterceptors() ?? [] ) } /// Unary call to Stop /// /// - Parameters: /// - request: Request to send to Stop. /// - callOptions: Call options. /// - Returns: A `UnaryCall` with futures for the metadata, status and response. public func stop( _ request: Grpc_Testing_Empty, callOptions: CallOptions? = nil ) -> UnaryCall { return self.makeUnaryCall( path: "/grpc.testing.ReconnectService/Stop", request: request, callOptions: callOptions ?? self.defaultCallOptions, interceptors: self.interceptors?.makeStopInterceptors() ?? [] ) } } public protocol Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol { /// - Returns: Interceptors to use when invoking 'start'. func makeStartInterceptors() -> [ClientInterceptor] /// - Returns: Interceptors to use when invoking 'stop'. func makeStopInterceptors() -> [ClientInterceptor] } public final class Grpc_Testing_ReconnectServiceClient: Grpc_Testing_ReconnectServiceClientProtocol { public let channel: GRPCChannel public var defaultCallOptions: CallOptions public var interceptors: Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol? /// Creates a client for the grpc.testing.ReconnectService 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: Grpc_Testing_ReconnectServiceClientInterceptorFactoryProtocol? = nil ) { self.channel = channel self.defaultCallOptions = defaultCallOptions self.interceptors = interceptors } } /// A simple service to test the various types of RPCs and experiment with /// performance with various types of payload. /// /// To build a server, implement a class that conforms to this protocol. public protocol Grpc_Testing_TestServiceProvider: CallHandlerProvider { var interceptors: Grpc_Testing_TestServiceServerInterceptorFactoryProtocol? { get } /// One empty request followed by one empty response. func emptyCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture /// One request followed by one response. func unaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture /// One request followed by one response. Response has cache control /// headers set such that a caching HTTP proxy (such as GFE) can /// satisfy subsequent requests. func cacheableUnaryCall(request: Grpc_Testing_SimpleRequest, context: StatusOnlyCallContext) -> EventLoopFuture /// One request followed by a sequence of responses (streamed download). /// The server returns the payload with client desired type and sizes. func streamingOutputCall(request: Grpc_Testing_StreamingOutputCallRequest, context: StreamingResponseCallContext) -> EventLoopFuture /// A sequence of requests followed by one response (streamed upload). /// The server returns the aggregated size of client payload as the result. func streamingInputCall(context: UnaryResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> /// A sequence of requests with each request served by the server immediately. /// As one request could lead to multiple responses, this interface /// demonstrates the idea of full duplexing. func fullDuplexCall(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> /// A sequence of requests followed by a sequence of responses. /// The server buffers all the client requests and then serves them in order. A /// stream of responses are returned to the client when the server starts with /// first request. func halfDuplexCall(context: StreamingResponseCallContext) -> EventLoopFuture<(StreamEvent) -> Void> } extension Grpc_Testing_TestServiceProvider { public var serviceName: Substring { return "grpc.testing.TestService" } /// 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 handleMethod( _ methodName: Substring, callHandlerContext: CallHandlerContext ) -> GRPCCallHandler? { switch methodName { case "EmptyCall": return CallHandlerFactory.makeUnary( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeEmptyCallInterceptors() ?? [] ) { context in return { request in self.emptyCall(request: request, context: context) } } case "UnaryCall": return CallHandlerFactory.makeUnary( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeUnaryCallInterceptors() ?? [] ) { context in return { request in self.unaryCall(request: request, context: context) } } case "CacheableUnaryCall": return CallHandlerFactory.makeUnary( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeCacheableUnaryCallInterceptors() ?? [] ) { context in return { request in self.cacheableUnaryCall(request: request, context: context) } } case "StreamingOutputCall": return CallHandlerFactory.makeServerStreaming( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeStreamingOutputCallInterceptors() ?? [] ) { context in return { request in self.streamingOutputCall(request: request, context: context) } } case "StreamingInputCall": return CallHandlerFactory.makeClientStreaming( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeStreamingInputCallInterceptors() ?? [] ) { context in self.streamingInputCall(context: context) } case "FullDuplexCall": return CallHandlerFactory.makeBidirectionalStreaming( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeFullDuplexCallInterceptors() ?? [] ) { context in self.fullDuplexCall(context: context) } case "HalfDuplexCall": return CallHandlerFactory.makeBidirectionalStreaming( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeHalfDuplexCallInterceptors() ?? [] ) { context in self.halfDuplexCall(context: context) } default: return nil } } } public protocol Grpc_Testing_TestServiceServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'emptyCall'. /// Defaults to calling `self.makeInterceptors()`. func makeEmptyCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'unaryCall'. /// Defaults to calling `self.makeInterceptors()`. func makeUnaryCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'cacheableUnaryCall'. /// Defaults to calling `self.makeInterceptors()`. func makeCacheableUnaryCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'streamingOutputCall'. /// Defaults to calling `self.makeInterceptors()`. func makeStreamingOutputCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'streamingInputCall'. /// Defaults to calling `self.makeInterceptors()`. func makeStreamingInputCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'fullDuplexCall'. /// Defaults to calling `self.makeInterceptors()`. func makeFullDuplexCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'halfDuplexCall'. /// Defaults to calling `self.makeInterceptors()`. func makeHalfDuplexCallInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'unimplementedCall'. /// Defaults to calling `self.makeInterceptors()`. func makeUnimplementedCallInterceptors() -> [ServerInterceptor] } /// A simple service NOT implemented at servers so clients can test for /// that case. /// /// To build a server, implement a class that conforms to this protocol. public protocol Grpc_Testing_UnimplementedServiceProvider: CallHandlerProvider { var interceptors: Grpc_Testing_UnimplementedServiceServerInterceptorFactoryProtocol? { get } /// A call that no server should implement func unimplementedCall(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture } extension Grpc_Testing_UnimplementedServiceProvider { public var serviceName: Substring { return "grpc.testing.UnimplementedService" } /// 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 handleMethod( _ methodName: Substring, callHandlerContext: CallHandlerContext ) -> GRPCCallHandler? { switch methodName { case "UnimplementedCall": return CallHandlerFactory.makeUnary( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeUnimplementedCallInterceptors() ?? [] ) { context in return { request in self.unimplementedCall(request: request, context: context) } } default: return nil } } } public protocol Grpc_Testing_UnimplementedServiceServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'unimplementedCall'. /// Defaults to calling `self.makeInterceptors()`. func makeUnimplementedCallInterceptors() -> [ServerInterceptor] } /// A service used to control reconnect server. /// /// To build a server, implement a class that conforms to this protocol. public protocol Grpc_Testing_ReconnectServiceProvider: CallHandlerProvider { var interceptors: Grpc_Testing_ReconnectServiceServerInterceptorFactoryProtocol? { get } func start(request: Grpc_Testing_ReconnectParams, context: StatusOnlyCallContext) -> EventLoopFuture func stop(request: Grpc_Testing_Empty, context: StatusOnlyCallContext) -> EventLoopFuture } extension Grpc_Testing_ReconnectServiceProvider { public var serviceName: Substring { return "grpc.testing.ReconnectService" } /// 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 handleMethod( _ methodName: Substring, callHandlerContext: CallHandlerContext ) -> GRPCCallHandler? { switch methodName { case "Start": return CallHandlerFactory.makeUnary( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeStartInterceptors() ?? [] ) { context in return { request in self.start(request: request, context: context) } } case "Stop": return CallHandlerFactory.makeUnary( callHandlerContext: callHandlerContext, interceptors: self.interceptors?.makeStopInterceptors() ?? [] ) { context in return { request in self.stop(request: request, context: context) } } default: return nil } } } public protocol Grpc_Testing_ReconnectServiceServerInterceptorFactoryProtocol { /// - Returns: Interceptors to use when handling 'start'. /// Defaults to calling `self.makeInterceptors()`. func makeStartInterceptors() -> [ServerInterceptor] /// - Returns: Interceptors to use when handling 'stop'. /// Defaults to calling `self.makeInterceptors()`. func makeStopInterceptors() -> [ServerInterceptor] }