OxL Reference

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:

oxl✓ checked in CI
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}")
}
Output
true

Types

data CallDetailsA typed error detail of a failed call
data SessionErrorWhy a session could not be created or ended (the session store is the cluster's replicated key-value store).
enum StatusgRPC status codes (the variants are in the order of the numeric codes).

Functions

asScopedRuns body with a narrower caller (§13.2)
asServiceRuns body as this node's own service (§13.2)
callDetailsThe typed error detail of the call (empty type name when it succeeded or failed without one).
callRawSends 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
callStatusThe gRPC status of the call (Ok, a @grpc_status of an application error, or the status of a NetError).
createSessionCreates a server-side session for user user (§13.2, provider session(cookie
endSessionEnds the session id (logout)
statusFromCodeStatus for a numeric gRPC code (Unknown for anything else).
statusOfThe status a NetError becomes on the wire (§10.1).
withMetaRuns body with extra request metadata

See also