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:
dynamic Limits {
rps: u32 = 100
title: str = "shop"
}
fn main() io {
let l = Limits.get()
print("{l.rps.get()} {l.title.get()}")
}Output
100 shop
pub(api) data DynHandle<T>Thread safety. a handle may be shared by tasks; reads see the latest value, `set` is atomic.
Since. 1.0.0-beta
Methods
open | (cfg: str, key: str, default: T, gate: DynGate) -> DynHandle<T> where T: SerializableDeclares the field (once per process) and returns the handle; called by the generated Config.get(). |
get | () -> T where T: SerializableThe current value |
changes | () -> stream<T> where T: SerializableThe values this field takes from now on (a new element whenever the value seen by this node changes). |
version | () -> u64The version of the field |
set | (v: T, layer: DynScope) -> () | DynError where T: SerializableSets the override of layer (checked by policy Name { allow set if … |
setAs | (p: &Principal, v: T, layer: DynScope) -> () | DynError where T: Serializableset on behalf of p (a service acting for a user; the policy is evaluated for p). |
check | (text: str) -> str | DynError where T: SerializableWould text (JSON, or plain text for a str) be accepted as a value of this field? |
unset | (layer: DynScope) -> () | DynErrorRemoves the override of layer. |
rollback | (to: u64, layer: DynScope?) -> () | DynErrorUndoes the latest change (of layer when given) or, with to, goes back to the state after that version (layer |
unsetAs | (p: &Principal, layer: DynScope) -> () | DynErrorRemoves the override of layer on behalf of p. |
Defined in: std/core/dynconf.oxl:404