trevrpc/client
Calls on a channel. A call belongs to the process that started it,
which alone reads and writes it; if that process exits, the channel
cancels the call. A call is finished once it ends (End or an error)
or is cancelled; reading or writing it then, or from another process,
is an error with code FailedPrecondition.
Types
pub type Options {
Options(
timeout: option.Option(Int),
metadata: dict.Dict(String, BitArray),
max_response_messages: option.Option(Int),
max_response_stream_body_size: option.Option(Int),
stream_idle_timeout: option.Option(Int),
)
}
Constructors
-
Options( timeout: option.Option(Int), metadata: dict.Dict(String, BitArray), max_response_messages: option.Option(Int), max_response_stream_body_size: option.Option(Int), stream_idle_timeout: option.Option(Int), )Arguments
- timeout
-
Milliseconds the call may take, sent to the server and enforced locally.
- metadata
-
The request metadata.
- max_response_messages
-
The most response messages the call takes; one more ends it with
ResourceExhausted. - max_response_stream_body_size
-
The most bytes its response messages may carry in all, decompressed; one more ends the call with
ResourceExhausted. - stream_idle_timeout
-
Milliseconds the call may wait for its next response frame before it ends with
Unavailable.
Why send did not send a request.
pub type SendError {
Ended(status.Status)
Invalid(status.Status)
}
Constructors
-
Ended(status.Status)The call ended, with this status (OK when the server finished it successfully); its responses can still be read.
-
Invalid(status.Status)The channel’s validator rejected the request, with this status, normally
InvalidArgumentwith the violationsviolations.from_statusreads: it was not sent, and the call goes on. Seetrevrpc/validator.
Values
pub fn bidi(
channel: channel.Channel,
method: schema.Method(request, response),
options: Options,
) -> Result(Call(request, response), status.Status)
pub fn client_stream(
channel: channel.Channel,
method: schema.Method(request, response),
options: Options,
) -> Result(Call(request, response), status.Status)
Starts a client-streaming call: send its requests, then
close_and_recv its response.
pub fn close_and_recv(
call: Call(request, response),
) -> Result(response, status.Status)
Ends the requests of a client-streaming call and reads its response.
pub fn close_send(
call: Call(request, response),
) -> Result(Nil, status.Status)
Ends the requests.
pub fn headers(
call: Call(request, response),
) -> Result(dict.Dict(String, BitArray), status.Status)
The response headers, reading as far as needed.
pub fn recv(
call: Call(request, response),
) -> Result(Received(response), status.Status)
Reads the next response, or the end of the call.
pub fn recv_within(
call: Call(request, response),
within milliseconds: Int,
) -> Result(option.Option(Received(response)), status.Status)
Reads the next response, or the end of the call, as recv does, but
waits for it at most within milliseconds: Ok(None) means none arrived
in time, and the call goes on. The call’s timeout still ends it.
pub fn send(
call: Call(request, response),
request: request,
) -> Result(Nil, SendError)
Sends a request.
pub fn server_stream(
channel: channel.Channel,
method: schema.Method(request, response),
request: request,
options: Options,
) -> Result(Call(request, response), status.Status)
Starts a server-streaming call; read its responses with recv.
pub fn unary(
channel: channel.Channel,
method: schema.Method(request, response),
request: request,
options: Options,
) -> Result(Reply(response), status.Status)