data Ctx
The context of a request, available as ctx in impl of a service and propagated into the calls a handler makes.
Example:
service Whoami {
@public rpc me() -> str
}
impl Whoami {
rpc me() => "{ctx.node.name.len() > 0} {ctx.traceId.len()}"
}
fn main() io, net {
print("{Whoami.me()!}")
}true 32
pub(api) data CtxС версии. 1.0.0-beta
Поля
pub(api) caller: Principal | Who made the call. |
pub(api) via: Principal | The service that made the call (from its mTLS certificate); |
pub(api) deadline: Time | Absolute deadline (wall clock); far in the future when the call has none. |
pub(api) traceId: str | The W3C trace id (32 hex digits) of the request: the same in every process the request touches (§15.5). |
pub(api) spanId: str | The id (16 hex digits) of the span the code runs in: the rpc handler's own, or the user span being open; empty without a ctx. |
pub(api) meta: Map<str, str> | Request metadata (headers) of the call. |
pub(api) idempotencyKey: str | The idempotency key of the call ( |
pub(api) node: NodeId | The node that runs the handler. |
pub(api) resumeFrom: u64? = none |
|
Методы
userId | () -> str | AccessDeniedThe id of the calling user; AccessDenied when the caller is not a user (ctx.caller.userId(), §13.2). |
Определено в: std/core/rpc.oxl:243