module std.rpc
std.rpc — status codes, metadata and in-process access to the wire entry of a service (§10.1, D-2900..).
callRaw / callStatus / callDetails run exactly the code a gRPC server runs for an incoming request (decode the
request message, call the handler with the usual policies, encode the response or the typed error detail) without a
socket: they are the seam tests and the transport (W3-J2) use.
Example:
use std.rpc { callStatus, Status }
service Echo {
@public rpc ping() -> str
}
impl Echo {
rpc ping() => "pong"
}
fn main() io, net {
print("{callStatus(Echo, "ping", b"") == Status.Ok}")
}Вывод
true
Типы
data CallDetails | A typed error detail of a failed call |
data SessionError | Why a session could not be created or ended (the session store is the cluster's replicated key-value store). |
enum Status | gRPC status codes (the variants are in the order of the numeric codes). |
Функции
asScoped | Runs body with a narrower caller (§13.2) |
asService | Runs body as this node's own service (§13.2) |
callDetails | The typed error detail of the call (empty type name when it succeeded or failed without one). |
callRaw | Sends the encoded request message to rpc method of service S through its wire entry; the encoded response message or a NetError (an application error is a ProtocolError here |
callStatus | The gRPC status of the call (Ok, a @grpc_status of an application error, or the status of a NetError). |
createSession | Creates a server-side session for user user (§13.2, provider session(cookie |
endSession | Ends the session id (logout) |
statusFromCode | Status for a numeric gRPC code (Unknown for anything else). |
statusOf | The status a NetError becomes on the wire (§10.1). |
withMeta | Runs body with extra request metadata |