@procedures/client 0.47.2 → 0.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/adapters/http/client/batch.d.ts.map +1 -1
- package/dist/adapters/http/client/batch.js.map +1 -1
- package/dist/adapters/http/server/body.d.ts.map +1 -1
- package/dist/adapters/http/server/body.js.map +1 -1
- package/dist/adapters/http/shared/constants.d.ts +82 -78
- package/dist/adapters/http/shared/constants.d.ts.map +1 -1
- package/dist/adapters/http/shared/constants.js +78 -80
- package/dist/adapters/http/shared/constants.js.map +1 -1
- package/dist/adapters/http/shared/errors.d.ts +15 -13
- package/dist/adapters/http/shared/errors.d.ts.map +1 -1
- package/dist/adapters/http/shared/errors.js +13 -14
- package/dist/adapters/http/shared/errors.js.map +1 -1
- package/dist/adapters/port/transport.d.ts.map +1 -1
- package/dist/adapters/port/transport.js.map +1 -1
- package/dist/adapters/sequence.d.ts.map +1 -1
- package/dist/adapters/sequence.js.map +1 -1
- package/dist/adapters/websocket/client/types.d.ts +16 -6
- package/dist/adapters/websocket/client/types.d.ts.map +1 -1
- package/dist/adapters/websocket/client/types.js +7 -8
- package/dist/adapters/websocket/client/types.js.map +1 -1
- package/dist/adapters/websocket/shared/rpc.d.ts.map +1 -1
- package/dist/adapters/websocket/shared/rpc.js.map +1 -1
- package/dist/browser.d.ts +3 -1
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -0
- package/dist/browser.js.map +1 -1
- package/dist/client/batch-executor.d.ts.map +1 -1
- package/dist/client/batch-executor.js.map +1 -1
- package/dist/client/client.d.ts.map +1 -1
- package/dist/client/client.js +3 -4
- package/dist/client/client.js.map +1 -1
- package/dist/client/errors/codes.d.ts +66 -64
- package/dist/client/errors/codes.d.ts.map +1 -1
- package/dist/client/errors/codes.js +64 -65
- package/dist/client/errors/codes.js.map +1 -1
- package/dist/client/errors/http-status.d.ts +69 -67
- package/dist/client/errors/http-status.d.ts.map +1 -1
- package/dist/client/errors/http-status.js +67 -68
- package/dist/client/errors/http-status.js.map +1 -1
- package/dist/client/errors/types.d.ts +38 -15
- package/dist/client/errors/types.d.ts.map +1 -1
- package/dist/client/errors/types.js +17 -19
- package/dist/client/errors/types.js.map +1 -1
- package/dist/client/middleware/circuit-breaker.d.ts.map +1 -1
- package/dist/client/middleware/circuit-breaker.js.map +1 -1
- package/dist/client/middleware/lru.d.ts +1 -1
- package/dist/client/middleware/lru.d.ts.map +1 -1
- package/dist/client/middleware/lru.js.map +1 -1
- package/dist/client/middleware/rate-limit.d.ts.map +1 -1
- package/dist/client/middleware/rate-limit.js.map +1 -1
- package/dist/client/middleware/resilience.d.ts.map +1 -1
- package/dist/client/middleware/resilience.js +2 -1
- package/dist/client/middleware/resilience.js.map +1 -1
- package/dist/client/route-resolver.d.ts.map +1 -1
- package/dist/client/route-resolver.js.map +1 -1
- package/dist/client/types.d.ts.map +1 -1
- package/dist/client/types.js.map +1 -1
- package/dist/client/validation/types.d.ts +1 -7
- package/dist/client/validation/types.d.ts.map +1 -1
- package/dist/client/validation/types.js +4 -7
- package/dist/client/validation/types.js.map +1 -1
- package/dist/events/bus.d.ts +35 -0
- package/dist/events/bus.d.ts.map +1 -1
- package/dist/events/bus.js +135 -22
- package/dist/events/bus.js.map +1 -1
- package/dist/events/index.d.ts +5 -1
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +3 -0
- package/dist/events/index.js.map +1 -1
- package/dist/events/live-state.d.ts +289 -0
- package/dist/events/live-state.d.ts.map +1 -0
- package/dist/events/live-state.js +501 -0
- package/dist/events/live-state.js.map +1 -0
- package/dist/events/live-view.d.ts +38 -0
- package/dist/events/live-view.d.ts.map +1 -0
- package/dist/events/live-view.js +109 -0
- package/dist/events/live-view.js.map +1 -0
- package/dist/events/publisher.d.ts +18 -1
- package/dist/events/publisher.d.ts.map +1 -1
- package/dist/events/publisher.js +27 -8
- package/dist/events/publisher.js.map +1 -1
- package/dist/events/recheck.d.ts.map +1 -1
- package/dist/events/recheck.js.map +1 -1
- package/dist/events/remote.d.ts +1 -7
- package/dist/events/remote.d.ts.map +1 -1
- package/dist/events/remote.js +4 -7
- package/dist/events/remote.js.map +1 -1
- package/dist/events/types.d.ts +30 -0
- package/dist/events/types.d.ts.map +1 -1
- package/dist/middleware/compose.d.ts.map +1 -1
- package/dist/middleware/compose.js +6 -10
- package/dist/middleware/compose.js.map +1 -1
- package/dist/procedures/collection/hint-filter.d.ts +1 -7
- package/dist/procedures/collection/hint-filter.d.ts.map +1 -1
- package/dist/procedures/collection/hint-filter.js +4 -7
- package/dist/procedures/collection/hint-filter.js.map +1 -1
- package/dist/server/procedure-server.d.ts.map +1 -1
- package/dist/server/procedure-server.js +3 -0
- package/dist/server/procedure-server.js.map +1 -1
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/types.js.map +1 -1
- package/package.json +7 -4
- package/src/adapters/http/client/batch.ts +4 -1
- package/src/adapters/http/server/body.ts +4 -1
- package/src/adapters/http/shared/constants.ts +84 -78
- package/src/adapters/http/shared/errors.ts +16 -13
- package/src/adapters/port/transport.ts +4 -1
- package/src/adapters/sequence.ts +5 -1
- package/src/adapters/websocket/client/types.ts +19 -6
- package/src/adapters/websocket/shared/rpc.ts +15 -3
- package/src/browser.ts +20 -0
- package/src/client/batch-executor.ts +5 -1
- package/src/client/client.ts +3 -4
- package/src/client/errors/README.md +12 -12
- package/src/client/errors/codes.ts +67 -64
- package/src/client/errors/http-status.ts +70 -67
- package/src/client/errors/types.ts +44 -15
- package/src/client/middleware/circuit-breaker.ts +7 -2
- package/src/client/middleware/lru.ts +7 -2
- package/src/client/middleware/rate-limit.ts +4 -1
- package/src/client/middleware/resilience.ts +2 -1
- package/src/client/route-resolver.ts +5 -1
- package/src/client/types.ts +7 -2
- package/src/client/validation/types.ts +13 -6
- package/src/events/bus.ts +152 -23
- package/src/events/index.ts +30 -0
- package/src/events/live-state.ts +666 -0
- package/src/events/live-view.ts +134 -0
- package/src/events/publisher.ts +53 -10
- package/src/events/recheck.ts +4 -1
- package/src/events/remote.ts +33 -12
- package/src/events/types.ts +34 -0
- package/src/middleware/compose.ts +6 -22
- package/src/procedures/collection/hint-filter.ts +13 -6
- package/src/server/procedure-server.ts +2 -0
- package/src/server/types.ts +7 -2
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The live state of a topic (documentation/LIVE-STATE-2026-11.md).
|
|
3
|
+
*
|
|
4
|
+
* Some state changes many times a second, and each reader needs only its latest value: who is here,
|
|
5
|
+
* and where a cursor is. This state keeps the latest value of each key of a topic in memory. It
|
|
6
|
+
* makes no store write and no numbered change.
|
|
7
|
+
*
|
|
8
|
+
* - A set keeps the value and publishes it to the subscribers of the topic, through the bus. The
|
|
9
|
+
* first change on an idle topic goes at once and opens a window. One event at the end of the
|
|
10
|
+
* window carries each key that changed in it, and that event opens the next window.
|
|
11
|
+
* - A snapshot gives the live values, so a new reader sees them at once.
|
|
12
|
+
* - A key ends after a stated time with no set, when the connection of its owner closes, and at a
|
|
13
|
+
* leave call. Each end publishes a `gone` item.
|
|
14
|
+
*
|
|
15
|
+
* The state fills from the bus too. A bus that hosts share thus shares the state. A snapshot holds
|
|
16
|
+
* only what this host saw.
|
|
17
|
+
*/
|
|
18
|
+
import * as z from "zod";
|
|
19
|
+
import type { PartitionResolver } from "../procedures/collection/partition.js";
|
|
20
|
+
import type { AnyProcedure, Capability, ProcedureContext } from "../procedures/types.js";
|
|
21
|
+
import type { Principal } from "../server/types.js";
|
|
22
|
+
import { type Duration } from "../duration.js";
|
|
23
|
+
import { type Clock } from "../clock.js";
|
|
24
|
+
import type { EventBus } from "./types.js";
|
|
25
|
+
/** The path of the procedure that sets a key of a live topic. */
|
|
26
|
+
export declare const LIVE_SET_PATH: readonly string[];
|
|
27
|
+
/** The path of the procedure that gives the live values of a topic. */
|
|
28
|
+
export declare const LIVE_SNAPSHOT_PATH: readonly string[];
|
|
29
|
+
/** The path of the procedure that ends a key of a live topic. */
|
|
30
|
+
export declare const LIVE_LEAVE_PATH: readonly string[];
|
|
31
|
+
/** The longest key of a live topic, in characters. */
|
|
32
|
+
export declare const MAX_LIVE_KEY_LENGTH = 256;
|
|
33
|
+
/** The default limit of the keys of one live topic. */
|
|
34
|
+
export declare const DEFAULT_LIVE_KEYS = 1024;
|
|
35
|
+
/** The default limit of the bytes of one value, as JSON. */
|
|
36
|
+
export declare const DEFAULT_LIVE_VALUE_BYTES = 16384;
|
|
37
|
+
/** The default limit of the topics of one live state. */
|
|
38
|
+
export declare const DEFAULT_LIVE_TOPICS = 4096;
|
|
39
|
+
/** The live value of a key. */
|
|
40
|
+
export interface LiveEntry<T = unknown> {
|
|
41
|
+
/** The key. */
|
|
42
|
+
readonly key: string;
|
|
43
|
+
/** The latest value. */
|
|
44
|
+
readonly value: T;
|
|
45
|
+
/** The name from `admitSet`. A value from the caller cannot replace it. */
|
|
46
|
+
readonly by?: string | undefined;
|
|
47
|
+
/** The time of the set on the clock of the host that took it, in milliseconds. */
|
|
48
|
+
readonly at: number;
|
|
49
|
+
}
|
|
50
|
+
/** Why a key ended: no set for the stated time, the connection of its owner closed, or a leave call ended it. */
|
|
51
|
+
export type LiveGoneReason = "expired" | "closed" | "left";
|
|
52
|
+
/** The end of a key. */
|
|
53
|
+
export interface LiveGone {
|
|
54
|
+
/** The key. */
|
|
55
|
+
readonly key: string;
|
|
56
|
+
/** Why the key ended. */
|
|
57
|
+
readonly reason: LiveGoneReason;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The event of a live topic: each key that changed in one window. The two lists have no key in
|
|
61
|
+
* common, and the latest change of a key wins.
|
|
62
|
+
*/
|
|
63
|
+
export interface LiveEvent<T = unknown> {
|
|
64
|
+
/** The id of the live state that published the event. A live state ignores its own events. */
|
|
65
|
+
readonly origin: string;
|
|
66
|
+
/** The keys with a new value. */
|
|
67
|
+
readonly set: ReadonlyArray<LiveEntry<T>>;
|
|
68
|
+
/** The keys that ended. */
|
|
69
|
+
readonly gone: readonly LiveGone[];
|
|
70
|
+
}
|
|
71
|
+
/** The facts of a set, for `admitSet`. */
|
|
72
|
+
export interface LiveSetCall {
|
|
73
|
+
/** The topic of the bus, after the partition rule. */
|
|
74
|
+
readonly topic: string;
|
|
75
|
+
/** The key. */
|
|
76
|
+
readonly key: string;
|
|
77
|
+
/** The value of the caller. */
|
|
78
|
+
readonly value: unknown;
|
|
79
|
+
/** The capability of the call. */
|
|
80
|
+
readonly capability: Capability;
|
|
81
|
+
/** The metadata of the call: the connection id and the headers of a network request. */
|
|
82
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
83
|
+
/** The principal of the call, from the authentication of the host. */
|
|
84
|
+
readonly principal?: Principal | undefined;
|
|
85
|
+
}
|
|
86
|
+
/** What `admitSet` gives for a set that it admits. */
|
|
87
|
+
export interface LiveAdmission {
|
|
88
|
+
/** The name of who set the value. Each reader gets it, and a value from the caller cannot replace it. */
|
|
89
|
+
readonly by?: string | undefined;
|
|
90
|
+
/** The value to keep in place of the value of the caller, when this field is present: a value with owner fields, for example. */
|
|
91
|
+
readonly value?: unknown;
|
|
92
|
+
}
|
|
93
|
+
/** The right to set a key. An admission admits the set. Null refuses it with `FORBIDDEN` and the reason `write-not-allowed`. */
|
|
94
|
+
export type AdmitLiveSet = (call: LiveSetCall) => LiveAdmission | null | Promise<LiveAdmission | null>;
|
|
95
|
+
/** The facts of a leave call, for `admitLeave`. */
|
|
96
|
+
export interface LiveLeaveCall {
|
|
97
|
+
/** The topic of the bus, after the partition rule. */
|
|
98
|
+
readonly topic: string;
|
|
99
|
+
/** The key. */
|
|
100
|
+
readonly key: string;
|
|
101
|
+
/** The name that `admitSet` gave for the last set of the key. */
|
|
102
|
+
readonly by?: string | undefined;
|
|
103
|
+
/** The connection of the last set of the key on this host. */
|
|
104
|
+
readonly owner?: string | undefined;
|
|
105
|
+
/** The capability of the call. */
|
|
106
|
+
readonly capability: Capability;
|
|
107
|
+
/** The metadata of the call: the connection id and the headers of a network request. */
|
|
108
|
+
readonly metadata: Readonly<Record<string, unknown>>;
|
|
109
|
+
/** The principal of the call, from the authentication of the host. */
|
|
110
|
+
readonly principal?: Principal | undefined;
|
|
111
|
+
}
|
|
112
|
+
/** The right to end a key. False refuses the call with `FORBIDDEN` and the reason `write-not-allowed`. */
|
|
113
|
+
export type AdmitLiveLeave = (call: LiveLeaveCall) => boolean | Promise<boolean>;
|
|
114
|
+
/** The options of a live state. */
|
|
115
|
+
export interface LiveStateOptions {
|
|
116
|
+
/** The time with no set after which a key ends. Only the app knows how often its clients repeat. */
|
|
117
|
+
expiresAfter: Duration;
|
|
118
|
+
/** The right to set a key, with the name and the value to keep. A host must give this option, so each host states who can write. */
|
|
119
|
+
admitSet: AdmitLiveSet;
|
|
120
|
+
/**
|
|
121
|
+
* The right to end a key with `live.leave`. Without this rule, only the connection of the last
|
|
122
|
+
* set of a key on this host can end the key.
|
|
123
|
+
*/
|
|
124
|
+
admitLeave?: AdmitLiveLeave | undefined;
|
|
125
|
+
/**
|
|
126
|
+
* The window that joins the changes of a topic into one event, or a function that gives the window
|
|
127
|
+
* of a topic of the bus. The first change on an idle topic goes at once. `ms(0)` publishes each
|
|
128
|
+
* change at once.
|
|
129
|
+
* @default ms(120)
|
|
130
|
+
*/
|
|
131
|
+
window?: Duration | ((topic: string) => Duration) | undefined;
|
|
132
|
+
/**
|
|
133
|
+
* The rule of the partition of a live topic, as for a collection. Null refuses the call. Without
|
|
134
|
+
* this rule, a topic with a partition gets `FORBIDDEN`.
|
|
135
|
+
*/
|
|
136
|
+
partition?: PartitionResolver | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The limit of the keys of one topic. A set of a new key at the limit gets `FORBIDDEN`.
|
|
139
|
+
* @default DEFAULT_LIVE_KEYS
|
|
140
|
+
*/
|
|
141
|
+
maxKeysPerTopic?: number | undefined;
|
|
142
|
+
/**
|
|
143
|
+
* The limit of the bytes of one value, as JSON. A larger value gets `FORBIDDEN`.
|
|
144
|
+
* @default DEFAULT_LIVE_VALUE_BYTES
|
|
145
|
+
*/
|
|
146
|
+
maxValueBytes?: number | undefined;
|
|
147
|
+
/**
|
|
148
|
+
* The limit of the topics. A set on a new topic at the limit gets `FORBIDDEN`, unless a topic
|
|
149
|
+
* without a key can go.
|
|
150
|
+
* @default DEFAULT_LIVE_TOPICS
|
|
151
|
+
*/
|
|
152
|
+
maxTopics?: number | undefined;
|
|
153
|
+
/**
|
|
154
|
+
* The clock of the deadlines and of the window. A test gives the `fakeClock` of
|
|
155
|
+
* `@mark1russell7/service/testing`.
|
|
156
|
+
* @default the clock of the publisher
|
|
157
|
+
*/
|
|
158
|
+
clock?: Clock | undefined;
|
|
159
|
+
}
|
|
160
|
+
/** The parts of a publisher that a live state uses. */
|
|
161
|
+
export interface LiveStateHost {
|
|
162
|
+
/** The bus of the events. */
|
|
163
|
+
readonly bus: EventBus;
|
|
164
|
+
/** The clock, when the options give none. */
|
|
165
|
+
readonly clock?: Clock | undefined;
|
|
166
|
+
/** The schema of a topic of the publisher. */
|
|
167
|
+
readonly topicSchema: z.ZodString;
|
|
168
|
+
/** This function runs the checks of a subscription on a topic, and gives the topic of the bus. */
|
|
169
|
+
admit(topic: string, ctx: ProcedureContext): Promise<string>;
|
|
170
|
+
}
|
|
171
|
+
/** The options of a direct set by the host. */
|
|
172
|
+
export interface LiveSetOptions {
|
|
173
|
+
/** The name of who set the value. */
|
|
174
|
+
readonly by?: string | undefined;
|
|
175
|
+
/** The connection that owns the key: its close ends the key. */
|
|
176
|
+
readonly owner?: string | undefined;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* This function gives a live topic: `live.<name>`, or `live.<name>.<partition>`. The name encodes
|
|
180
|
+
* `%` and `.`, so the first dot after the name ends the name, as in a topic of a collection.
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* liveTopic("presence"); // "live.presence"
|
|
185
|
+
* liveTopic("presence", "acme/board:b1"); // "live.presence.acme/board:b1"
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export declare function liveTopic(name: string, partition?: string): string;
|
|
189
|
+
/**
|
|
190
|
+
* This function gives the name and the partition of a live topic, or undefined for another topic.
|
|
191
|
+
* Only the canonical form counts: `liveTopic()` gives the same topic back.
|
|
192
|
+
*/
|
|
193
|
+
export declare function liveTopicTarget(topic: string): {
|
|
194
|
+
readonly name: string;
|
|
195
|
+
readonly partition?: string;
|
|
196
|
+
} | undefined;
|
|
197
|
+
/**
|
|
198
|
+
* The live values of the topics of one publisher. A host gets one with the option `live` of
|
|
199
|
+
* `EventPublisher`, and the server registers its `procedures`.
|
|
200
|
+
*/
|
|
201
|
+
export declare class LiveState {
|
|
202
|
+
/** The procedures `live.set`, `live.snapshot` and `live.leave`. The expose rule of the host applies to them. */
|
|
203
|
+
readonly procedures: readonly AnyProcedure[];
|
|
204
|
+
private readonly bus;
|
|
205
|
+
private readonly clock;
|
|
206
|
+
private readonly admit;
|
|
207
|
+
private readonly admitSet;
|
|
208
|
+
private readonly admitLeave;
|
|
209
|
+
private readonly partition;
|
|
210
|
+
private readonly expiresMs;
|
|
211
|
+
private readonly windowOf;
|
|
212
|
+
private readonly maxKeys;
|
|
213
|
+
private readonly maxValueBytes;
|
|
214
|
+
private readonly maxTopics;
|
|
215
|
+
private readonly origin;
|
|
216
|
+
private readonly topics;
|
|
217
|
+
/** Each key in the order of its last set. All keys have the same time, so this is the order of the deadlines. */
|
|
218
|
+
private readonly deadlines;
|
|
219
|
+
private readonly owned;
|
|
220
|
+
private timer;
|
|
221
|
+
private closed;
|
|
222
|
+
constructor(options: LiveStateOptions, host: LiveStateHost);
|
|
223
|
+
/** The number of live keys of this state. */
|
|
224
|
+
get size(): number;
|
|
225
|
+
/**
|
|
226
|
+
* The topic of the bus for a live topic of a call, or undefined for another topic. The publisher
|
|
227
|
+
* calls it for each subscription and each re-check, so a change of the partition ends a
|
|
228
|
+
* subscription.
|
|
229
|
+
*/
|
|
230
|
+
route(topic: string, ctx: ProcedureContext): Promise<string | undefined>;
|
|
231
|
+
/**
|
|
232
|
+
* This method keeps the latest value of a key and publishes it. This is the direct form for the
|
|
233
|
+
* host: it runs no check of a right, and `topic` is a topic of the bus.
|
|
234
|
+
*
|
|
235
|
+
* @returns The time of the set on the clock
|
|
236
|
+
* @throws `InvocationError` with the code `FORBIDDEN` at a limit, and the existing values stay
|
|
237
|
+
*/
|
|
238
|
+
set(topic: string, key: string, value: unknown, options?: LiveSetOptions): number;
|
|
239
|
+
/** This method gives the live values of a topic of the bus. */
|
|
240
|
+
snapshot(topic: string): LiveEntry[];
|
|
241
|
+
/**
|
|
242
|
+
* This method ends a key and publishes the end with the reason `left`. This is the direct form for
|
|
243
|
+
* the host: it runs no check of a right, and `topic` is a topic of the bus.
|
|
244
|
+
*
|
|
245
|
+
* @returns True when the key was live
|
|
246
|
+
*/
|
|
247
|
+
leave(topic: string, key: string): boolean;
|
|
248
|
+
/** This method ends each key that the connection owns. The transport of the host calls it at a close. */
|
|
249
|
+
connectionClosed(connection: string): void;
|
|
250
|
+
/** This method stops the timers and the listeners. The state then holds nothing. */
|
|
251
|
+
close(): void;
|
|
252
|
+
/** This method refuses a value above the limit. A text has at most 3 bytes for each UTF-16 unit. */
|
|
253
|
+
private checkValue;
|
|
254
|
+
/**
|
|
255
|
+
* The state of a topic. The first use starts the listener of the bus. A topic stays after its
|
|
256
|
+
* last key, and goes when a new topic needs its place. Undefined means that no place is free.
|
|
257
|
+
*/
|
|
258
|
+
private stateOf;
|
|
259
|
+
/** This method applies an event of another host. Its subscribers on this host got it from the bus. */
|
|
260
|
+
private heard;
|
|
261
|
+
/** This method moves a key to the end of the deadlines. */
|
|
262
|
+
private renew;
|
|
263
|
+
/** This method sets the owner of a key. The owner is the connection of the last set. */
|
|
264
|
+
private own;
|
|
265
|
+
/** This method removes a key, and publishes its end when this host decided it. */
|
|
266
|
+
private end;
|
|
267
|
+
/** This method starts the one timer of the deadlines, at the first deadline. */
|
|
268
|
+
private armDeadline;
|
|
269
|
+
/** This method ends each key at its deadline. */
|
|
270
|
+
private expire;
|
|
271
|
+
/**
|
|
272
|
+
* This method adds a change to a topic. On an idle topic the change goes at once, so one writer
|
|
273
|
+
* has no added delay, and the window opens. In an open window the change waits, and the latest
|
|
274
|
+
* change of a key wins.
|
|
275
|
+
*/
|
|
276
|
+
private queue;
|
|
277
|
+
/** This method publishes the changes that wait as one event, and opens the next window. */
|
|
278
|
+
private publishWaiting;
|
|
279
|
+
/** The procedure `live.set`: the checks of a subscription, then `admitSet`, then the set. */
|
|
280
|
+
private setProcedure;
|
|
281
|
+
/**
|
|
282
|
+
* The procedure `live.leave`: the checks of a subscription, then the right to end the key. A set
|
|
283
|
+
* that comes during the check of the right keeps the key, because the check read the older set.
|
|
284
|
+
*/
|
|
285
|
+
private leaveProcedure;
|
|
286
|
+
/** The procedure `live.snapshot`: the checks of a subscription, then the live values. */
|
|
287
|
+
private snapshotProcedure;
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=live-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"live-state.d.ts","sourceRoot":"","sources":["../../src/events/live-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AAIzB,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAY,KAAK,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAA0B,KAAK,KAAK,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,YAAY,CAAC;AAExD,i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