GBidirectionalStreamingCall
public class GBidirectionalStreamingCall<Request, Response> : ICall where Request : Message, Response : Message
A bidirectional streaming Grebe call.
Both sides, the client and the server, send a sequence of messages. The two streams operate independently, so clients and servers can read and write and whatever oder they like: for example, the server could wait to receive all the client messages before writing its responses, or it could alternately read a message then write a message, or some other combination of reads and writes.
Example usage of GBidirectionalStreamingCall
Consider the following protobuf definition for a simple echo service. The service defines one bidirectional streaming RPC. You send a stream of messages and it echoes a stream of messages back to you.
syntax = "proto3";
service EchoService {
rpc echo (stream EchoRequest) returns (stream EchoResponse);
}
message EchoRequest {
string message = 1;
}
message EchoResponse {
string message = 1;
}
You can create a GBidirectionalStreamingCall
like this:
let requests = Publishers.Sequence<[EchoRequest], Error>(
sequence: [EchoRequest.with { $0.message = "hello"}, EchoRequest.with { $0.message = "world"}]
).eraseToAnyPublisher()
GBidirectionalStreamingCall(request: requests, callOptions: callOptions, closure: echo)
-
Declaration
Swift
public typealias CallClosure = ( _ callOptions: CallOptions?, _ handler: @escaping (Response) -> Void ) -> GRPC.BidirectionalStreamingCall<Request, Response>
-
The request message stream for the call.
Declaration
Swift
public var requests: AnyPublisher<Request, Error>
-
Declaration
Swift
public let callClosure: CallClosure
-
Declaration
Swift
public let callOptions: CallOptions?
-
Sets up an new bidirectional streaming Grebe call.
Declaration
Swift
public init( requests: AnyPublisher<Request, Error>, callOptions: CallOptions? = nil, closure: @escaping CallClosure )
Parameters
request
The request message stream for the call.
callOptions
Options to use for each service call.
closure
The closure which contains the executable call.
-
Executes the Grebe bidirectional streaming call.
Declaration
Swift
public func execute() -> AnyPublisher<Response, GRPCStatus>
Return Value
A stream of
Response
elements. The response publisher may fail with aGRPCStatus
error.