| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227 |
- /*
- * Copyright 2021, 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.
- */
- #if compiler(>=5.6)
- import SwiftProtobuf
- @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
- extension GRPCChannel {
- /// Make a unary gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - request: The request to send.
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncUnaryCall<
- Request: Message & Sendable,
- Response: Message & Sendable
- >(
- path: String,
- request: Request,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncUnaryCall<Request, Response> {
- return GRPCAsyncUnaryCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .unary,
- callOptions: callOptions,
- interceptors: interceptors
- ),
- request
- )
- }
- /// Make a unary gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - request: The request to send.
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncUnaryCall<
- Request: GRPCPayload & Sendable,
- Response: GRPCPayload & Sendable
- >(
- path: String,
- request: Request,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncUnaryCall<Request, Response> {
- return GRPCAsyncUnaryCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .unary,
- callOptions: callOptions,
- interceptors: interceptors
- ),
- request
- )
- }
- /// Makes a client-streaming gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncClientStreamingCall<
- Request: Message & Sendable,
- Response: Message & Sendable
- >(
- path: String,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncClientStreamingCall<Request, Response> {
- return GRPCAsyncClientStreamingCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .clientStreaming,
- callOptions: callOptions,
- interceptors: interceptors
- )
- )
- }
- /// Makes a client-streaming gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncClientStreamingCall<
- Request: GRPCPayload & Sendable,
- Response: GRPCPayload & Sendable
- >(
- path: String,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncClientStreamingCall<Request, Response> {
- return GRPCAsyncClientStreamingCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .clientStreaming,
- callOptions: callOptions,
- interceptors: interceptors
- )
- )
- }
- /// Make a server-streaming gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - request: The request to send.
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncServerStreamingCall<
- Request: Message & Sendable,
- Response: Message & Sendable
- >(
- path: String,
- request: Request,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncServerStreamingCall<Request, Response> {
- return GRPCAsyncServerStreamingCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .serverStreaming,
- callOptions: callOptions,
- interceptors: interceptors
- ),
- request
- )
- }
- /// Make a server-streaming gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - request: The request to send.
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncServerStreamingCall<
- Request: GRPCPayload & Sendable,
- Response: GRPCPayload & Sendable
- >(
- path: String,
- request: Request,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncServerStreamingCall<Request, Response> {
- return GRPCAsyncServerStreamingCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .serverStreaming,
- callOptions: callOptions,
- interceptors: []
- ),
- request
- )
- }
- /// Makes a bidirectional-streaming gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncBidirectionalStreamingCall<
- Request: Message & Sendable,
- Response: Message & Sendable
- >(
- path: String,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncBidirectionalStreamingCall<Request, Response> {
- return GRPCAsyncBidirectionalStreamingCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .bidirectionalStreaming,
- callOptions: callOptions,
- interceptors: interceptors
- )
- )
- }
- /// Makes a bidirectional-streaming gRPC call.
- ///
- /// - Parameters:
- /// - path: Path of the RPC, e.g. "/echo.Echo/Get"
- /// - callOptions: Options for the RPC.
- /// - interceptors: A list of interceptors to intercept the request and response stream with.
- internal func makeAsyncBidirectionalStreamingCall<
- Request: GRPCPayload & Sendable,
- Response: GRPCPayload & Sendable
- >(
- path: String,
- callOptions: CallOptions,
- interceptors: [ClientInterceptor<Request, Response>] = []
- ) -> GRPCAsyncBidirectionalStreamingCall<Request, Response> {
- return GRPCAsyncBidirectionalStreamingCall.makeAndInvoke(
- call: self.makeCall(
- path: path,
- type: .bidirectionalStreaming,
- callOptions: callOptions,
- interceptors: interceptors
- )
- )
- }
- }
- #endif
|