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),
)
}
Constructors
-
Options( timeout: option.Option(Int), metadata: dict.Dict(String, BitArray), )Arguments
- timeout
-
Milliseconds the call may take, sent to the server and enforced locally.
- metadata
-
The request metadata.
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, status.Status)
Sends a request. An error means the call ended, with that status (OK when the server finished it successfully); its responses can still be read.
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)