OxL Справочник OxL
РусскийEnglish

fn withMeta

Runs body with extra request metadata: every rpc it calls (and every task it spawns) carries meta in ctx.meta. The user id travels as x-oxl-user (D-2905).

Example:

oxl✓ проверяется в CI
use std.rpc { withMeta }

fn main() io {
  var meta: Map<str, str> = Map.new()
  meta.insert("x-request-id", "r-1")
  let n = withMeta(meta) { 40 + 2 }
  print("{n}")
}
Вывод
42
pub(api) fn withMeta<T, effect F>(meta: Map<str, str>, body: fn() -> T F) -> T  F

Потокобезопасность. the metadata belongs to the calling task and the tasks it spawns inside `body`; other tasks do not see it.

С версии. 1.0.0-beta

Параметры

ИмяТип
metaMap<str, str>
bodyfn() -> T F

Возвращает

T F

Эффекты

не объявлены (чистая, пока тело не говорит иное)

Определено в: std/rpc/rpc.oxl:280

См. также