GClientStreamingCall
public class GClientStreamingCall<Request, Response> : ICall where Request : Message, Response : Message
A client streaming Grebe call.
The client sends a sequence of request messages to the server. Once the client has finished writing the messages it waits for the server to read them and return its response
Example usage of GClientStreamingCall
Consider the following protobuf definition for a simple echo service. The service defines one client streaming RPC. You send a stream of messages and it sends one messages back to you.
syntax = "proto3";
service EchoService {
rpc echo (stream EchoRequest) returns (EchoResponse);
}
message EchoRequest {
string message = 1;
}
message EchoResponse {
string message = 1;
}
You can create a GClientStreamingCall
like this:
let requests = Publishers.Sequence<[EchoRequest], Error>(
sequence: [EchoRequest.with { $0.message = "hello"}, EchoRequest.with { $0.message = "world"}]
).eraseToAnyPublisher()
GClientStreamingCall(request: requests, callOptions: callOptions, closure: echo)
-
Declaration
Swift
public typealias CallClosure = ( _ callOptions: CallOptions? ) -> GRPC.ClientStreamingCall<Request, Response>
-
The request message stream for the call.
Declaration
Swift
public var request: AnyPublisher<Request, Error>
-
Declaration
Swift
public let callClosure: CallClosure
-
Declaration
Swift
public let callOptions: CallOptions?
-
Sets up an new client streaming Grebe call.
Declaration
Swift
public init( request: 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 client 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.