Module state is hq ADR 0201 after all: the derived-value record moved to 0202 on hq main
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
// State — the current value of something a module keeps on the bus, which every machine sees,
|
||||
// including one that joins later (novox/hq ADR 0202). Not history: that is an event. Never a secret,
|
||||
// including one that joins later (novox/hq ADR 0201). Not history: that is an event. Never a secret,
|
||||
// sealed or not: a bucket is kept, and a machine joining a year later reads it whole.
|
||||
//
|
||||
// A module declares the state it keeps (`state` in its manifest) and the state of others it reads
|
||||
@@ -65,7 +65,7 @@ function bound(): StateChannel {
|
||||
if (!channel) {
|
||||
throw new Error(
|
||||
"no runtime to keep state through — a module's state is reached through the runtime that launched " +
|
||||
"its bundle (novox/hq ADR 0202)",
|
||||
"its bundle (novox/hq ADR 0201)",
|
||||
);
|
||||
}
|
||||
return channel;
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ function startSession(): Session {
|
||||
});
|
||||
const ask = (method: string, params: unknown): Promise<unknown> => askAs(`bundle-${nextOut++}`, method, params);
|
||||
|
||||
// The module's state (ADR 0202): each watch's changes arrive as `mesh/state` requests naming the
|
||||
// The module's state (ADR 0201): each watch's changes arrive as `mesh/state` requests naming the
|
||||
// watch by the id it was asked with, so its handler is registered under that id before it is asked
|
||||
// — the current values arrive before the watch itself is answered.
|
||||
const watches = new Map<string, (change: StateChange<unknown>) => Promise<void>>();
|
||||
@@ -176,7 +176,7 @@ function startSession(): Session {
|
||||
return;
|
||||
}
|
||||
case "mesh/state": {
|
||||
// One change to a state this bundle watches (ADR 0202), answered once its handler has taken
|
||||
// One change to a state this bundle watches (ADR 0201), answered once its handler has taken
|
||||
// it. The runtime delivers a watch's changes one at a time, in order.
|
||||
const p = request.params as { watch?: string; change?: StateChange<unknown> } | undefined;
|
||||
const deliver = p?.watch !== undefined ? watches.get(String(p.watch)) : undefined;
|
||||
|
||||
Reference in New Issue
Block a user