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

data DynHandle

A live typed value of a dynamic config (§14.2). get() is the current value for this node (and the caller's tenant), changes() a stream of the new values from now on.

Example:

oxl✓ проверяется в CI
dynamic Limits {
  rps: u32 = 100
  title: str = "shop"
}

fn main() io {
  let l = Limits.get()
  print("{l.rps.get()} {l.title.get()}")
}
Вывод
100 shop
pub(api) data DynHandle<T>

Потокобезопасность. a handle may be shared by tasks; reads see the latest value, `set` is atomic.

С версии. 1.0.0-beta

Методы

open(cfg: str, key: str, default: T, gate: DynGate) -> DynHandle<T> where T: Serializable
Declares the field (once per process) and returns the handle; called by the generated Config.get().
get() -> T where T: Serializable
The current value
changes() -> stream<T> where T: Serializable
The values this field takes from now on (a new element whenever the value seen by this node changes).
version() -> u64
The version of the field
set(v: T, layer: DynScope) -> () | DynError where T: Serializable
Sets the override of layer (checked by policy Name { allow set if …
setAs(p: &Principal, v: T, layer: DynScope) -> () | DynError where T: Serializable
set on behalf of p (a service acting for a user; the policy is evaluated for p).
check(text: str) -> str | DynError where T: Serializable
Would text (JSON, or plain text for a str) be accepted as a value of this field?
unset(layer: DynScope) -> () | DynError
Removes the override of layer.
rollback(to: u64, layer: DynScope?) -> () | DynError
Undoes the latest change (of layer when given) or, with to, goes back to the state after that version (layer
unsetAs(p: &Principal, layer: DynScope) -> () | DynError
Removes the override of layer on behalf of p.

Определено в: std/core/dynconf.oxl:404

См. также