GUnaryCall
public class GUnaryCall<Request, Response> : ICall where Request : Message, Response : Message
A unary Grebe call.
The client sends a single request to the server and gets a single response back, just like a normal function call.
Example usage of GUnaryCall
Consider the following protobuf definition for a simple echo service. The service defines one unary RPC. You send one message and it echoes the message back to you.
syntax = "proto3";
service EchoService {
rpc echo (EchoRequest) returns (EchoResponse);
}
message EchoRequest {
string message = 1;
}
message EchoResponse {
string message = 1;
}
You can create a GUnaryCall
like this:
GUnaryCall(request: EchoRequest.with { $0.message = "hello"}, closure: echo)
-
Declaration
Swift
public typealias CallClosure = ( _ request: Request, _ callOptions: CallOptions? ) -> GRPC.UnaryCall<Request, Response>
-
The request message for the call.
Declaration
Swift
public var request: Request
-
Declaration
Swift
public let callClosure: CallClosure
-
Declaration
Swift
public let callOptions: CallOptions?
-
Sets up an new unary Grebe call.
Declaration
Swift
public init( request: Request, callOptions: CallOptions? = nil, closure: @escaping CallClosure )
Parameters
request
The request message for the call.
callOptions
Options to use for each service call.
closure
The closure which contains the executable call.
-
Executes the Grebe unary call.
Declaration
Swift
public func execute() -> AnyPublisher<Response, GRPCStatus>
Return Value
A stream of
Response
elements. The response publisher may fail with aGRPCStatus
error.