@dxos/feed-store 0.8.3 → 0.8.4-main.03d5cd7b56
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/dist/lib/browser/{chunk-WS47OKDO.mjs → chunk-MB63GMGR.mjs} +112 -197
- package/dist/lib/browser/chunk-MB63GMGR.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +62 -202
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +19 -21
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node-esm/{chunk-AO5I2BX3.mjs → chunk-VZUET36D.mjs} +112 -197
- package/dist/lib/node-esm/chunk-VZUET36D.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +62 -202
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +19 -21
- package/dist/lib/node-esm/testing/index.mjs.map +3 -3
- package/dist/types/src/feed-factory.d.ts.map +1 -1
- package/dist/types/src/feed-iterator.d.ts.map +1 -1
- package/dist/types/src/feed-queue.d.ts.map +1 -1
- package/dist/types/src/feed-set-iterator.d.ts.map +1 -1
- package/dist/types/src/feed-store.d.ts.map +1 -1
- package/dist/types/src/feed-wrapper.d.ts +18 -19
- package/dist/types/src/feed-wrapper.d.ts.map +1 -1
- package/dist/types/src/feed-writer.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/testing/mocks.d.ts.map +1 -1
- package/dist/types/src/testing/test-builder.d.ts +2 -2
- package/dist/types/src/testing/test-builder.d.ts.map +1 -1
- package/dist/types/src/testing/test-generator.d.ts +2 -2
- package/dist/types/src/testing/test-generator.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +26 -26
- package/src/feed-queue.test.ts +1 -1
- package/src/feed-queue.ts +4 -2
- package/src/feed-set-iterator.test.ts +6 -6
- package/src/feed-store.node.test.ts +5 -5
- package/src/feed-wrapper.test.ts +45 -12
- package/src/feed-wrapper.ts +74 -35
- package/src/index.ts +1 -1
- package/src/testing/test-builder.ts +3 -4
- package/src/testing/test-generator.ts +5 -6
- package/dist/lib/browser/chunk-WS47OKDO.mjs.map +0 -7
- package/dist/lib/node/chunk-YOYJCS5J.cjs +0 -523
- package/dist/lib/node/chunk-YOYJCS5J.cjs.map +0 -7
- package/dist/lib/node/index.cjs +0 -593
- package/dist/lib/node/index.cjs.map +0 -7
- package/dist/lib/node/meta.json +0 -1
- package/dist/lib/node/testing/index.cjs +0 -173
- package/dist/lib/node/testing/index.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-AO5I2BX3.mjs.map +0 -7
|
@@ -3,38 +3,41 @@ import {
|
|
|
3
3
|
FeedFactory,
|
|
4
4
|
FeedStore,
|
|
5
5
|
FeedWrapper
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-MB63GMGR.mjs";
|
|
7
7
|
|
|
8
|
-
//
|
|
8
|
+
// src/feed-iterator.ts
|
|
9
9
|
import safeRace from "race-as-promised";
|
|
10
10
|
import { Trigger as Trigger2 } from "@dxos/async";
|
|
11
11
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
12
12
|
import { log as log2 } from "@dxos/log";
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// src/feed-queue.ts
|
|
15
15
|
import { inspect } from "@dxos/node-std/util";
|
|
16
16
|
import { Writable } from "streamx";
|
|
17
|
-
import { Event,
|
|
17
|
+
import { Event, Trigger, latch } from "@dxos/async";
|
|
18
18
|
import { inspectObject } from "@dxos/debug";
|
|
19
19
|
import { invariant } from "@dxos/invariant";
|
|
20
20
|
import { log } from "@dxos/log";
|
|
21
|
-
var __dxlog_file = "/
|
|
21
|
+
var __dxlog_file = "/__w/dxos/dxos/packages/common/feed-store/src/feed-queue.ts";
|
|
22
22
|
var defaultReadStreamOptions = {
|
|
23
23
|
live: true,
|
|
24
24
|
batch: 1024
|
|
25
25
|
};
|
|
26
26
|
var FeedQueue = class {
|
|
27
|
+
_feed;
|
|
28
|
+
_options;
|
|
29
|
+
updated = new Event();
|
|
30
|
+
_messageTrigger = new Trigger({
|
|
31
|
+
autoReset: true
|
|
32
|
+
});
|
|
33
|
+
_feedConsumer = void 0;
|
|
34
|
+
_next;
|
|
35
|
+
_currentBlock = void 0;
|
|
36
|
+
_index = -1;
|
|
27
37
|
// prettier-ignore
|
|
28
38
|
constructor(_feed, _options = {}) {
|
|
29
39
|
this._feed = _feed;
|
|
30
40
|
this._options = _options;
|
|
31
|
-
this.updated = new Event();
|
|
32
|
-
this._messageTrigger = new Trigger({
|
|
33
|
-
autoReset: true
|
|
34
|
-
});
|
|
35
|
-
this._feedConsumer = void 0;
|
|
36
|
-
this._currentBlock = void 0;
|
|
37
|
-
this._index = -1;
|
|
38
41
|
}
|
|
39
42
|
[inspect.custom]() {
|
|
40
43
|
return inspectObject(this);
|
|
@@ -73,12 +76,7 @@ var FeedQueue = class {
|
|
|
73
76
|
this._index = options.start ?? 0;
|
|
74
77
|
log("opening", {
|
|
75
78
|
feedKey: this._feed.key
|
|
76
|
-
}, {
|
|
77
|
-
F: __dxlog_file,
|
|
78
|
-
L: 92,
|
|
79
|
-
S: this,
|
|
80
|
-
C: (f, a) => f(...a)
|
|
81
|
-
});
|
|
79
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 69, S: this });
|
|
82
80
|
const opts = Object.assign({}, defaultReadStreamOptions, options);
|
|
83
81
|
const feedStream = this._feed.createReadableStream(opts);
|
|
84
82
|
this._feedConsumer = new Writable({
|
|
@@ -105,6 +103,9 @@ var FeedQueue = class {
|
|
|
105
103
|
this._destroyConsumer();
|
|
106
104
|
};
|
|
107
105
|
const onError = (err) => {
|
|
106
|
+
if (!this.isOpen) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
108
109
|
if (!err) {
|
|
109
110
|
return;
|
|
110
111
|
}
|
|
@@ -113,12 +114,7 @@ var FeedQueue = class {
|
|
|
113
114
|
}
|
|
114
115
|
log.catch(err, {
|
|
115
116
|
feedKey: this._feed.key
|
|
116
|
-
}, {
|
|
117
|
-
F: __dxlog_file,
|
|
118
|
-
L: 135,
|
|
119
|
-
S: this,
|
|
120
|
-
C: (f, a) => f(...a)
|
|
121
|
-
});
|
|
117
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 108, S: this });
|
|
122
118
|
};
|
|
123
119
|
this._feed.core.once("close", onClose);
|
|
124
120
|
this._feedConsumer.on("error", onError);
|
|
@@ -129,55 +125,24 @@ var FeedQueue = class {
|
|
|
129
125
|
}
|
|
130
126
|
this._destroyConsumer();
|
|
131
127
|
});
|
|
132
|
-
log("opened", void 0, {
|
|
133
|
-
F: __dxlog_file,
|
|
134
|
-
L: 153,
|
|
135
|
-
S: this,
|
|
136
|
-
C: (f, a) => f(...a)
|
|
137
|
-
});
|
|
128
|
+
log("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 124, S: this });
|
|
138
129
|
}
|
|
139
130
|
/**
|
|
140
131
|
* Closes the queue.
|
|
141
132
|
*/
|
|
142
133
|
async close() {
|
|
143
134
|
if (this.isOpen) {
|
|
144
|
-
invariant(this._feedConsumer, void 0, {
|
|
145
|
-
|
|
146
|
-
L: 161,
|
|
147
|
-
S: this,
|
|
148
|
-
A: [
|
|
149
|
-
"this._feedConsumer",
|
|
150
|
-
""
|
|
151
|
-
]
|
|
152
|
-
});
|
|
153
|
-
invariant(!this._feed.properties.closed, void 0, {
|
|
154
|
-
F: __dxlog_file,
|
|
155
|
-
L: 162,
|
|
156
|
-
S: this,
|
|
157
|
-
A: [
|
|
158
|
-
"!this._feed.properties.closed",
|
|
159
|
-
""
|
|
160
|
-
]
|
|
161
|
-
});
|
|
135
|
+
invariant(this._feedConsumer, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 130, S: this, A: ["this._feedConsumer", ""] });
|
|
136
|
+
invariant(!this._feed.properties.closed, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 131, S: this, A: ["!this._feed.properties.closed", ""] });
|
|
162
137
|
log("closing", {
|
|
163
138
|
feedKey: this._feed.key
|
|
164
|
-
}, {
|
|
165
|
-
F: __dxlog_file,
|
|
166
|
-
L: 164,
|
|
167
|
-
S: this,
|
|
168
|
-
C: (f, a) => f(...a)
|
|
169
|
-
});
|
|
139
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 132, S: this });
|
|
170
140
|
const [closed, setClosed] = latch();
|
|
171
141
|
this._feedConsumer.once("close", setClosed);
|
|
172
142
|
this._feedConsumer.destroy();
|
|
173
143
|
this._next?.();
|
|
174
144
|
await closed();
|
|
175
|
-
log("closed", void 0, {
|
|
176
|
-
F: __dxlog_file,
|
|
177
|
-
L: 170,
|
|
178
|
-
S: this,
|
|
179
|
-
C: (f, a) => f(...a)
|
|
180
|
-
});
|
|
145
|
+
log("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 140, S: this });
|
|
181
146
|
}
|
|
182
147
|
}
|
|
183
148
|
/**
|
|
@@ -206,12 +171,7 @@ var FeedQueue = class {
|
|
|
206
171
|
if (this._feedConsumer) {
|
|
207
172
|
log("queue closed", {
|
|
208
173
|
feedKey: this._feed.key
|
|
209
|
-
}, {
|
|
210
|
-
F: __dxlog_file,
|
|
211
|
-
L: 203,
|
|
212
|
-
S: this,
|
|
213
|
-
C: (f, a) => f(...a)
|
|
214
|
-
});
|
|
174
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file, L: 165, S: this });
|
|
215
175
|
this._feedConsumer = void 0;
|
|
216
176
|
this._next = void 0;
|
|
217
177
|
this._currentBlock = void 0;
|
|
@@ -220,14 +180,12 @@ var FeedQueue = class {
|
|
|
220
180
|
}
|
|
221
181
|
};
|
|
222
182
|
|
|
223
|
-
//
|
|
224
|
-
var __dxlog_file2 = "/
|
|
183
|
+
// src/feed-iterator.ts
|
|
184
|
+
var __dxlog_file2 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-iterator.ts";
|
|
225
185
|
var AbstractFeedIterator = class {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this._running = false;
|
|
230
|
-
}
|
|
186
|
+
_stopTrigger = new Trigger2();
|
|
187
|
+
_open = false;
|
|
188
|
+
_running = false;
|
|
231
189
|
toJSON() {
|
|
232
190
|
return {
|
|
233
191
|
open: this.isOpen,
|
|
@@ -242,66 +200,30 @@ var AbstractFeedIterator = class {
|
|
|
242
200
|
}
|
|
243
201
|
async open() {
|
|
244
202
|
if (!this._open) {
|
|
245
|
-
log2("opening...", void 0, {
|
|
246
|
-
F: __dxlog_file2,
|
|
247
|
-
L: 41,
|
|
248
|
-
S: this,
|
|
249
|
-
C: (f, a) => f(...a)
|
|
250
|
-
});
|
|
203
|
+
log2("opening...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 29, S: this });
|
|
251
204
|
await this._onOpen();
|
|
252
205
|
this._open = true;
|
|
253
206
|
await this.start();
|
|
254
|
-
log2("opened", void 0, {
|
|
255
|
-
F: __dxlog_file2,
|
|
256
|
-
L: 46,
|
|
257
|
-
S: this,
|
|
258
|
-
C: (f, a) => f(...a)
|
|
259
|
-
});
|
|
207
|
+
log2("opened", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 33, S: this });
|
|
260
208
|
}
|
|
261
209
|
}
|
|
262
210
|
async close() {
|
|
263
211
|
if (this._open) {
|
|
264
|
-
log2("closing...", void 0, {
|
|
265
|
-
F: __dxlog_file2,
|
|
266
|
-
L: 52,
|
|
267
|
-
S: this,
|
|
268
|
-
C: (f, a) => f(...a)
|
|
269
|
-
});
|
|
212
|
+
log2("closing...", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 38, S: this });
|
|
270
213
|
await this.stop();
|
|
271
214
|
await this._onClose();
|
|
272
215
|
this._open = false;
|
|
273
|
-
log2("closed", void 0, {
|
|
274
|
-
F: __dxlog_file2,
|
|
275
|
-
L: 57,
|
|
276
|
-
S: this,
|
|
277
|
-
C: (f, a) => f(...a)
|
|
278
|
-
});
|
|
216
|
+
log2("closed", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 42, S: this });
|
|
279
217
|
}
|
|
280
218
|
}
|
|
281
219
|
async start() {
|
|
282
|
-
invariant2(this._open, void 0, {
|
|
283
|
-
F: __dxlog_file2,
|
|
284
|
-
L: 62,
|
|
285
|
-
S: this,
|
|
286
|
-
A: [
|
|
287
|
-
"this._open",
|
|
288
|
-
""
|
|
289
|
-
]
|
|
290
|
-
});
|
|
220
|
+
invariant2(this._open, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 46, S: this, A: ["this._open", ""] });
|
|
291
221
|
if (!this._running) {
|
|
292
222
|
this._running = true;
|
|
293
223
|
}
|
|
294
224
|
}
|
|
295
225
|
async stop() {
|
|
296
|
-
invariant2(this._open, void 0, {
|
|
297
|
-
F: __dxlog_file2,
|
|
298
|
-
L: 69,
|
|
299
|
-
S: this,
|
|
300
|
-
A: [
|
|
301
|
-
"this._open",
|
|
302
|
-
""
|
|
303
|
-
]
|
|
304
|
-
});
|
|
226
|
+
invariant2(this._open, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 52, S: this, A: ["this._open", ""] });
|
|
305
227
|
if (this._running) {
|
|
306
228
|
this._running = false;
|
|
307
229
|
this._stopTrigger.wake();
|
|
@@ -314,12 +236,7 @@ var AbstractFeedIterator = class {
|
|
|
314
236
|
return this._generator();
|
|
315
237
|
}
|
|
316
238
|
async *_generator() {
|
|
317
|
-
log2("started", void 0, {
|
|
318
|
-
F: __dxlog_file2,
|
|
319
|
-
L: 85,
|
|
320
|
-
S: this,
|
|
321
|
-
C: (f, a) => f(...a)
|
|
322
|
-
});
|
|
239
|
+
log2("started", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 65, S: this });
|
|
323
240
|
while (this._running) {
|
|
324
241
|
const block = await safeRace([
|
|
325
242
|
this._stopTrigger.wait(),
|
|
@@ -330,15 +247,12 @@ var AbstractFeedIterator = class {
|
|
|
330
247
|
}
|
|
331
248
|
yield block;
|
|
332
249
|
}
|
|
333
|
-
log2("stopped", void 0, {
|
|
334
|
-
F: __dxlog_file2,
|
|
335
|
-
L: 97,
|
|
336
|
-
S: this,
|
|
337
|
-
C: (f, a) => f(...a)
|
|
338
|
-
});
|
|
250
|
+
log2("stopped", void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file2, L: 77, S: this });
|
|
339
251
|
}
|
|
340
252
|
};
|
|
341
253
|
var FeedIterator = class extends AbstractFeedIterator {
|
|
254
|
+
_feed;
|
|
255
|
+
_queue;
|
|
342
256
|
constructor(_feed) {
|
|
343
257
|
super(), this._feed = _feed;
|
|
344
258
|
this._queue = new FeedQueue(this._feed);
|
|
@@ -354,7 +268,7 @@ var FeedIterator = class extends AbstractFeedIterator {
|
|
|
354
268
|
}
|
|
355
269
|
};
|
|
356
270
|
|
|
357
|
-
//
|
|
271
|
+
// src/feed-set-iterator.ts
|
|
358
272
|
import { inspect as inspect2 } from "@dxos/node-std/util";
|
|
359
273
|
import { Event as Event2, SubscriptionList, Trigger as Trigger3 } from "@dxos/async";
|
|
360
274
|
import { inspectObject as inspectObject2 } from "@dxos/debug";
|
|
@@ -362,33 +276,23 @@ import { invariant as invariant3 } from "@dxos/invariant";
|
|
|
362
276
|
import { PublicKey } from "@dxos/keys";
|
|
363
277
|
import { log as log3 } from "@dxos/log";
|
|
364
278
|
import { ComplexMap, isNonNullable } from "@dxos/util";
|
|
365
|
-
var __dxlog_file3 = "/
|
|
279
|
+
var __dxlog_file3 = "/__w/dxos/dxos/packages/common/feed-store/src/feed-set-iterator.ts";
|
|
366
280
|
var defaultFeedSetIteratorOptions = {
|
|
367
281
|
stallTimeout: 1e3
|
|
368
282
|
};
|
|
369
283
|
var FeedSetIterator = class extends AbstractFeedIterator {
|
|
284
|
+
_selector;
|
|
285
|
+
options;
|
|
286
|
+
_feedQueues = new ComplexMap(PublicKey.hash);
|
|
287
|
+
_trigger = new Trigger3({
|
|
288
|
+
autoReset: true
|
|
289
|
+
});
|
|
290
|
+
_subscriptions = new SubscriptionList();
|
|
291
|
+
stalled = new Event2();
|
|
370
292
|
constructor(_selector, options = defaultFeedSetIteratorOptions) {
|
|
371
|
-
super(), this._selector = _selector, this.options = options
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
invariant3(_selector, void 0, {
|
|
375
|
-
F: __dxlog_file3,
|
|
376
|
-
L: 55,
|
|
377
|
-
S: this,
|
|
378
|
-
A: [
|
|
379
|
-
"_selector",
|
|
380
|
-
""
|
|
381
|
-
]
|
|
382
|
-
});
|
|
383
|
-
invariant3(options, void 0, {
|
|
384
|
-
F: __dxlog_file3,
|
|
385
|
-
L: 56,
|
|
386
|
-
S: this,
|
|
387
|
-
A: [
|
|
388
|
-
"options",
|
|
389
|
-
""
|
|
390
|
-
]
|
|
391
|
-
});
|
|
293
|
+
super(), this._selector = _selector, this.options = options;
|
|
294
|
+
invariant3(_selector, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 29, S: this, A: ["_selector", ""] });
|
|
295
|
+
invariant3(options, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 30, S: this, A: ["options", ""] });
|
|
392
296
|
}
|
|
393
297
|
[inspect2.custom]() {
|
|
394
298
|
return inspectObject2(this);
|
|
@@ -416,32 +320,11 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
416
320
|
this._trigger.wake();
|
|
417
321
|
}
|
|
418
322
|
async addFeed(feed) {
|
|
419
|
-
invariant3(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`, {
|
|
420
|
-
|
|
421
|
-
L: 91,
|
|
422
|
-
S: this,
|
|
423
|
-
A: [
|
|
424
|
-
"!this._feedQueues.has(feed.key)",
|
|
425
|
-
"`Feed already added: ${feed.key}`"
|
|
426
|
-
]
|
|
427
|
-
});
|
|
428
|
-
invariant3(feed.properties.opened, void 0, {
|
|
429
|
-
F: __dxlog_file3,
|
|
430
|
-
L: 92,
|
|
431
|
-
S: this,
|
|
432
|
-
A: [
|
|
433
|
-
"feed.properties.opened",
|
|
434
|
-
""
|
|
435
|
-
]
|
|
436
|
-
});
|
|
323
|
+
invariant3(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 58, S: this, A: ["!this._feedQueues.has(feed.key)", "`Feed already added: ${feed.key}`"] });
|
|
324
|
+
invariant3(feed.properties.opened, void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 59, S: this, A: ["feed.properties.opened", ""] });
|
|
437
325
|
log3("feed added", {
|
|
438
326
|
feedKey: feed.key
|
|
439
|
-
}, {
|
|
440
|
-
F: __dxlog_file3,
|
|
441
|
-
L: 93,
|
|
442
|
-
S: this,
|
|
443
|
-
C: (f, a) => f(...a)
|
|
444
|
-
});
|
|
327
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 60, S: this });
|
|
445
328
|
const queue = new FeedQueue(feed);
|
|
446
329
|
this._feedQueues.set(feed.key, queue);
|
|
447
330
|
this._subscriptions.add(queue.updated.on(() => {
|
|
@@ -478,12 +361,7 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
478
361
|
log3("selected", {
|
|
479
362
|
idx,
|
|
480
363
|
blocks
|
|
481
|
-
}, {
|
|
482
|
-
F: __dxlog_file3,
|
|
483
|
-
L: 143,
|
|
484
|
-
S: this,
|
|
485
|
-
C: (f, a) => f(...a)
|
|
486
|
-
});
|
|
364
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 100, S: this });
|
|
487
365
|
if (idx === void 0) {
|
|
488
366
|
if (t === void 0) {
|
|
489
367
|
t = setTimeout(() => {
|
|
@@ -500,33 +378,15 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
500
378
|
throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);
|
|
501
379
|
}
|
|
502
380
|
const queue = this._feedQueues.get(blocks[idx].feedKey);
|
|
503
|
-
log3("popping", queue.toJSON(), {
|
|
504
|
-
F: __dxlog_file3,
|
|
505
|
-
L: 163,
|
|
506
|
-
S: this,
|
|
507
|
-
C: (f, a) => f(...a)
|
|
508
|
-
});
|
|
381
|
+
log3("popping", queue.toJSON(), { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 122, S: this });
|
|
509
382
|
try {
|
|
510
383
|
const message = await queue.pop();
|
|
511
|
-
invariant3(message === blocks[idx], void 0, {
|
|
512
|
-
F: __dxlog_file3,
|
|
513
|
-
L: 166,
|
|
514
|
-
S: this,
|
|
515
|
-
A: [
|
|
516
|
-
"message === blocks[idx]",
|
|
517
|
-
""
|
|
518
|
-
]
|
|
519
|
-
});
|
|
384
|
+
invariant3(message === blocks[idx], void 0, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 125, S: this, A: ["message === blocks[idx]", ""] });
|
|
520
385
|
return message;
|
|
521
386
|
} catch (err) {
|
|
522
387
|
log3.warn("queue closed", {
|
|
523
388
|
feedKey: queue.feed.key
|
|
524
|
-
}, {
|
|
525
|
-
F: __dxlog_file3,
|
|
526
|
-
L: 170,
|
|
527
|
-
S: this,
|
|
528
|
-
C: (f, a) => f(...a)
|
|
529
|
-
});
|
|
389
|
+
}, { "~LogMeta": "~LogMeta", F: __dxlog_file3, L: 129, S: this });
|
|
530
390
|
}
|
|
531
391
|
}
|
|
532
392
|
}
|
|
@@ -535,7 +395,7 @@ var FeedSetIterator = class extends AbstractFeedIterator {
|
|
|
535
395
|
}
|
|
536
396
|
};
|
|
537
397
|
|
|
538
|
-
//
|
|
398
|
+
// src/feed-writer.ts
|
|
539
399
|
var createFeedWriter = (cb) => ({
|
|
540
400
|
write: async (data) => {
|
|
541
401
|
return cb(data);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/feed-iterator.ts", "../../../src/feed-queue.ts", "../../../src/feed-set-iterator.ts", "../../../src/feed-writer.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport safeRace from 'race-as-promised';\n\nimport { Trigger } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Base class for an async iterable feed.\n */\nexport abstract class AbstractFeedIterator<T> implements AsyncIterable<FeedBlock<T>> {\n private readonly _stopTrigger = new Trigger();\n\n protected _open = false;\n protected _running = false;\n\n toJSON(): { open: boolean; running: boolean } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n };\n }\n\n get isOpen() {\n return this._open;\n }\n\n get isRunning() {\n return this._running;\n }\n\n async open(): Promise<void> {\n if (!this._open) {\n log('opening...');\n await this._onOpen();\n this._open = true;\n\n await this.start();\n log('opened');\n }\n }\n\n async close(): Promise<void> {\n if (this._open) {\n log('closing...');\n await this.stop();\n\n await this._onClose();\n this._open = false;\n log('closed');\n }\n }\n\n async start(): Promise<void> {\n invariant(this._open);\n if (!this._running) {\n this._running = true;\n }\n }\n\n async stop(): Promise<void> {\n invariant(this._open);\n if (this._running) {\n this._running = false;\n this._stopTrigger.wake();\n }\n }\n\n //\n // AsyncIterable\n //\n\n [Symbol.asyncIterator]() {\n return this._generator();\n }\n\n async *_generator() {\n log('started');\n while (this._running) {\n // https://github.com/nodejs/node/issues/17469\n const block = await safeRace([this._stopTrigger.wait(), this._nextBlock()]);\n\n if (block === undefined) {\n break;\n }\n\n yield block;\n }\n\n log('stopped');\n }\n\n abstract _onOpen(): Promise<void>;\n abstract _onClose(): Promise<void>;\n abstract _nextBlock(): Promise<FeedBlock<T> | undefined>;\n}\n\n/**\n * Iterator that reads blocks from a single feed.\n */\nexport class FeedIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _queue: FeedQueue<T>;\n\n constructor(private readonly _feed: FeedWrapper<T>) {\n super();\n this._queue = new FeedQueue<T>(this._feed);\n }\n\n override async _onOpen(): Promise<void> {\n await this._queue.open();\n }\n\n override async _onClose(): Promise<void> {\n await this._queue.close();\n }\n\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n return this._queue.pop();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\nimport { Writable } from 'streamx';\n\nimport { Event, latch, Trigger } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport type { ReadStreamOptions } from '@dxos/hypercore';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\nexport const defaultReadStreamOptions: ReadStreamOptions = {\n live: true, // Keep reading until closed.\n batch: 1024, // Read in batches.\n};\n\nexport type FeedQueueOptions = {};\n\n/**\n * Async queue using an AsyncIterator created from a hypercore.\n */\nexport class FeedQueue<T extends {}> {\n public updated = new Event<FeedQueue<T>>();\n\n private readonly _messageTrigger = new Trigger<FeedBlock<T>>({\n autoReset: true,\n });\n\n private _feedConsumer?: Writable = undefined;\n private _next?: () => void;\n private _currentBlock?: FeedBlock<T> = undefined;\n private _index = -1;\n\n // prettier-ignore\n constructor(\n private readonly _feed: FeedWrapper<T>,\n private readonly _options: FeedQueueOptions = {},\n ) {}\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n toJSON() {\n return {\n feedKey: this._feed.key,\n index: this.index,\n length: this.length,\n open: this.isOpen,\n };\n }\n\n get feed() {\n return this._feed;\n }\n\n get isOpen(): boolean {\n return Boolean(this._feedConsumer);\n }\n\n get length(): number {\n return this._feed.properties.length;\n }\n\n /**\n * Index (seq) of the NEXT block to be read, or -1 if not open.\n */\n get index() {\n return this._index;\n }\n\n /**\n * Opens (or reopens) the queue.\n * @param options.start Starting index. First mutation to be read would have `seq == options.start`.\n */\n async open(options: ReadStreamOptions = {}): Promise<void> {\n if (this.isOpen) {\n // TODO(burdon): Warn if re-opening (e.g., with different starting point).\n return;\n }\n\n this._index = options.start ?? 0;\n // if (this._index !== 0) {\n // console.warn('Start index not yet supported.');\n // }\n\n log('opening', { feedKey: this._feed.key });\n\n // TODO(burdon): Open with starting range.\n const opts = Object.assign({}, defaultReadStreamOptions, options);\n const feedStream = this._feed.createReadableStream(opts);\n\n this._feedConsumer = new Writable({\n write: (data: any, next: () => void) => {\n this._next = () => {\n this._next = undefined;\n this._currentBlock = undefined;\n this._index++;\n next();\n };\n\n this._currentBlock = {\n feedKey: this._feed.key,\n seq: this._index,\n data,\n };\n\n this._messageTrigger.wake(this._currentBlock);\n this.updated.emit(this);\n },\n });\n\n const onClose = () => {\n this.feed.core.off('close', onClose);\n this._feedConsumer?.off('close', onClose);\n this._feedConsumer?.off('error', onError);\n\n this._destroyConsumer();\n };\n\n const onError = (err?: Error) => {\n if (!err) {\n return;\n }\n\n if (err.message === 'Writable stream closed prematurely' || err.message === 'Feed is closed') {\n return;\n }\n\n log.catch(err, { feedKey: this._feed.key });\n };\n\n // Called if feed is closed externally.\n this._feed.core.once('close', onClose);\n this._feedConsumer.on('error', onError);\n\n // Called when queue is closed. Throws exception if waiting for `pop`.\n this._feedConsumer.once('close', onClose);\n\n // Pipe readable stream into writable consumer.\n feedStream.pipe(this._feedConsumer, (err) => {\n if (err) {\n onError(err);\n }\n this._destroyConsumer();\n });\n\n log('opened');\n }\n\n /**\n * Closes the queue.\n */\n async close(): Promise<void> {\n if (this.isOpen) {\n invariant(this._feedConsumer);\n invariant(!this._feed.properties.closed);\n\n log('closing', { feedKey: this._feed.key });\n const [closed, setClosed] = latch();\n this._feedConsumer.once('close', setClosed);\n this._feedConsumer.destroy();\n this._next?.(); // Release any message currently in the queue (otherwise destroy will block).\n await closed();\n log('closed');\n }\n }\n\n /**\n * Get the block at the head of the queue without removing it.\n */\n peek(): FeedBlock<T> | undefined {\n return this._currentBlock;\n }\n\n /**\n * Pop block at the head of the queue.\n */\n async pop(): Promise<FeedBlock<T>> {\n if (!this.isOpen) {\n throw new Error(`Queue closed: ${this.feed.key.truncate()}`);\n }\n\n let block = this.peek();\n if (!block) {\n block = await this._messageTrigger.wait();\n }\n\n if (block) {\n this._next?.();\n }\n\n return block;\n }\n\n private _destroyConsumer(): void {\n if (this._feedConsumer) {\n log('queue closed', { feedKey: this._feed.key });\n this._feedConsumer = undefined;\n this._next = undefined;\n this._currentBlock = undefined;\n this._index = -1;\n }\n }\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { Event, SubscriptionList, Trigger } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, isNonNullable } from '@dxos/util';\n\nimport { AbstractFeedIterator } from './feed-iterator';\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Select next block.\n */\nexport type FeedBlockSelector<T> = (blocks: FeedBlock<T>[]) => number | undefined;\n\nexport type FeedIndex = {\n feedKey: PublicKey;\n index: number;\n};\n\nexport type FeedSetIteratorOptions = {\n // TODO(burdon): Should we remove this and assume the feeds are positioned before adding?\n start?: FeedIndex[];\n stallTimeout?: number;\n};\n\nexport const defaultFeedSetIteratorOptions = {\n stallTimeout: 1000,\n};\n\n/**\n * Iterator that reads blocks from multiple feeds, ordering them based on a traversal callback.\n */\nexport class FeedSetIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _feedQueues = new ComplexMap<PublicKey, FeedQueue<T>>(PublicKey.hash);\n\n private readonly _trigger = new Trigger({ autoReset: true });\n private readonly _subscriptions = new SubscriptionList();\n\n public readonly stalled = new Event<FeedSetIterator<T>>();\n\n constructor(\n private readonly _selector: FeedBlockSelector<T>,\n public readonly options: FeedSetIteratorOptions = defaultFeedSetIteratorOptions,\n ) {\n super();\n invariant(_selector);\n invariant(options);\n }\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n override toJSON(): { open: boolean; running: boolean; indexes: FeedIndex[] } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n indexes: this.indexes,\n };\n }\n\n get size() {\n return this._feedQueues.size;\n }\n\n get feeds(): FeedWrapper<T>[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => feedQueue.feed);\n }\n\n get indexes(): FeedIndex[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => ({\n feedKey: feedQueue.feed.key,\n index: feedQueue.index,\n }));\n }\n\n reiterateBlock(block: FeedBlock<T>): void {\n this._trigger.wake();\n }\n\n async addFeed(feed: FeedWrapper<T>): Promise<void> {\n invariant(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`);\n invariant(feed.properties.opened);\n log('feed added', { feedKey: feed.key });\n\n // Create queue and listen for updates.\n const queue = new FeedQueue<T>(feed);\n this._feedQueues.set(feed.key, queue);\n this._subscriptions.add(\n queue.updated.on(() => {\n this._trigger.wake();\n }),\n );\n\n await queue.open({\n start: this.options.start?.find((index) => index.feedKey.equals(feed.key))?.index,\n });\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n hasFeed(feedKey: PublicKey): boolean {\n return this._feedQueues.has(feedKey);\n }\n\n override async _onOpen(): Promise<void> {\n for (const queue of this._feedQueues.values()) {\n await queue.open();\n }\n }\n\n override async _onClose(): Promise<void> {\n this._subscriptions.clear();\n await Promise.all(Array.from(this._feedQueues.values()).map((queue) => queue.close()));\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n /**\n * Gets the next block from the selected queue.\n */\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n let t: NodeJS.Timeout | undefined;\n\n while (this._running) {\n // Get blocks from the head of each queue.\n const queues = Array.from(this._feedQueues.values());\n const blocks = queues.map((queue) => queue.peek()).filter(isNonNullable);\n if (blocks.length) {\n // Get the selected block from candidates.\n const idx = this._selector(blocks);\n log('selected', { idx, blocks });\n if (idx === undefined) {\n // Timeout if all candidates are rejected.\n if (t === undefined) {\n t = setTimeout(() => {\n this.stalled.emit(this);\n this._trigger.wake();\n }, this.options.stallTimeout);\n }\n } else {\n if (t !== undefined) {\n clearTimeout(t);\n t = undefined;\n }\n if (idx >= blocks.length) {\n throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);\n }\n\n // Pop from queue.\n const queue = this._feedQueues.get(blocks[idx].feedKey)!;\n log('popping', queue.toJSON());\n try {\n const message = await queue.pop();\n invariant(message === blocks[idx]);\n return message;\n } catch (err) {\n // TODO(burdon): Same queue closed twice.\n log.warn('queue closed', { feedKey: queue.feed.key });\n // console.log(Array.from(this._feedQueues.values()));\n }\n }\n }\n\n // Wait until feed added, new block, or closing.\n await this._trigger.wait();\n }\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type PublicKey } from '@dxos/keys';\n\nexport type WriteReceipt = {\n feedKey: PublicKey;\n seq: number;\n};\n\nexport type WriteOptions = {\n /**\n * Called after the write is complete.\n * Runs and completes before the mutation is read from the pipeline.\n */\n afterWrite?: (receipt: WriteReceipt) => Promise<void>;\n};\n\nexport interface FeedWriter<T extends {}> {\n /**\n * Write data to the feed.\n * Awaits `afterWrite` before returning.\n */\n write(data: T, options?: WriteOptions): Promise<WriteReceipt>;\n}\n\nexport const createFeedWriter = <T extends {}>(cb: (data: T) => Promise<WriteReceipt>): FeedWriter<T> => ({\n write: async (data: T) => {\n return cb(data);\n },\n});\n\nexport const writeMessages = async <T extends {}>(writer: FeedWriter<T>, messages: T[]): Promise<WriteReceipt[]> => {\n const receipts: WriteReceipt[] = [];\n // NOTE: Write messages sequentially.\n for (const message of messages) {\n receipts.push(await writer.write(message));\n }\n return receipts;\n};\n"],
|
|
5
|
-
"mappings": ";;;;;;;;AAIA,OAAOA,cAAc;AAErB,SAASC,WAAAA,gBAAe;AACxB,SAASC,aAAAA,kBAAiB;AAC1B,SAASC,OAAAA,YAAW;;;ACJpB,SAASC,eAAe;AACxB,SAASC,gBAAgB;AAEzB,SAASC,OAAOC,
|
|
6
|
-
"names": ["safeRace", "Trigger", "invariant", "log", "inspect", "Writable", "Event", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2020 DXOS.org\n//\n\nimport safeRace from 'race-as-promised';\n\nimport { Trigger } from '@dxos/async';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Base class for an async iterable feed.\n */\nexport abstract class AbstractFeedIterator<T> implements AsyncIterable<FeedBlock<T>> {\n private readonly _stopTrigger = new Trigger();\n\n protected _open = false;\n protected _running = false;\n\n toJSON(): { open: boolean; running: boolean } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n };\n }\n\n get isOpen() {\n return this._open;\n }\n\n get isRunning() {\n return this._running;\n }\n\n async open(): Promise<void> {\n if (!this._open) {\n log('opening...');\n await this._onOpen();\n this._open = true;\n\n await this.start();\n log('opened');\n }\n }\n\n async close(): Promise<void> {\n if (this._open) {\n log('closing...');\n await this.stop();\n\n await this._onClose();\n this._open = false;\n log('closed');\n }\n }\n\n async start(): Promise<void> {\n invariant(this._open);\n if (!this._running) {\n this._running = true;\n }\n }\n\n async stop(): Promise<void> {\n invariant(this._open);\n if (this._running) {\n this._running = false;\n this._stopTrigger.wake();\n }\n }\n\n //\n // AsyncIterable\n //\n\n [Symbol.asyncIterator]() {\n return this._generator();\n }\n\n async *_generator() {\n log('started');\n while (this._running) {\n // https://github.com/nodejs/node/issues/17469\n const block = await safeRace([this._stopTrigger.wait(), this._nextBlock()]);\n\n if (block === undefined) {\n break;\n }\n\n yield block;\n }\n\n log('stopped');\n }\n\n abstract _onOpen(): Promise<void>;\n abstract _onClose(): Promise<void>;\n abstract _nextBlock(): Promise<FeedBlock<T> | undefined>;\n}\n\n/**\n * Iterator that reads blocks from a single feed.\n */\nexport class FeedIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _queue: FeedQueue<T>;\n\n constructor(private readonly _feed: FeedWrapper<T>) {\n super();\n this._queue = new FeedQueue<T>(this._feed);\n }\n\n override async _onOpen(): Promise<void> {\n await this._queue.open();\n }\n\n override async _onClose(): Promise<void> {\n await this._queue.close();\n }\n\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n return this._queue.pop();\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { inspect } from 'node:util';\nimport { Writable } from 'streamx';\n\nimport { Event, Trigger, latch } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport type { ReadStreamOptions } from '@dxos/hypercore';\nimport { invariant } from '@dxos/invariant';\nimport { log } from '@dxos/log';\n\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\nexport const defaultReadStreamOptions: ReadStreamOptions = {\n live: true, // Keep reading until closed.\n batch: 1024, // Read in batches.\n};\n\nexport type FeedQueueOptions = {};\n\n/**\n * Async queue using an AsyncIterator created from a hypercore.\n */\nexport class FeedQueue<T extends {}> {\n public updated = new Event<FeedQueue<T>>();\n\n private readonly _messageTrigger = new Trigger<FeedBlock<T>>({\n autoReset: true,\n });\n\n private _feedConsumer?: Writable = undefined;\n private _next?: () => void;\n private _currentBlock?: FeedBlock<T> = undefined;\n private _index = -1;\n\n // prettier-ignore\n constructor(\n private readonly _feed: FeedWrapper<T>,\n private readonly _options: FeedQueueOptions = {},\n ) {}\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n toJSON() {\n return {\n feedKey: this._feed.key,\n index: this.index,\n length: this.length,\n open: this.isOpen,\n };\n }\n\n get feed() {\n return this._feed;\n }\n\n get isOpen(): boolean {\n return Boolean(this._feedConsumer);\n }\n\n get length(): number {\n return this._feed.properties.length;\n }\n\n /**\n * Index (seq) of the NEXT block to be read, or -1 if not open.\n */\n get index() {\n return this._index;\n }\n\n /**\n * Opens (or reopens) the queue.\n * @param options.start Starting index. First mutation to be read would have `seq == options.start`.\n */\n async open(options: ReadStreamOptions = {}): Promise<void> {\n if (this.isOpen) {\n // TODO(burdon): Warn if re-opening (e.g., with different starting point).\n return;\n }\n\n this._index = options.start ?? 0;\n // if (this._index !== 0) {\n // console.warn('Start index not yet supported.');\n // }\n\n log('opening', { feedKey: this._feed.key });\n\n // TODO(burdon): Open with starting range.\n const opts = Object.assign({}, defaultReadStreamOptions, options);\n const feedStream = this._feed.createReadableStream(opts);\n\n this._feedConsumer = new Writable({\n write: (data: any, next: () => void) => {\n this._next = () => {\n this._next = undefined;\n this._currentBlock = undefined;\n this._index++;\n next();\n };\n\n this._currentBlock = {\n feedKey: this._feed.key,\n seq: this._index,\n data,\n };\n\n this._messageTrigger.wake(this._currentBlock);\n this.updated.emit(this);\n },\n });\n\n const onClose = () => {\n this.feed.core.off('close', onClose);\n this._feedConsumer?.off('close', onClose);\n this._feedConsumer?.off('error', onError);\n\n this._destroyConsumer();\n };\n\n const onError = (err?: Error) => {\n if (!this.isOpen) {\n return;\n }\n if (!err) {\n return;\n }\n if (err.message === 'Writable stream closed prematurely' || err.message === 'Feed is closed') {\n return;\n }\n\n log.catch(err, { feedKey: this._feed.key });\n };\n\n // Called if feed is closed externally.\n this._feed.core.once('close', onClose);\n this._feedConsumer.on('error', onError);\n\n // Called when queue is closed. Throws exception if waiting for `pop`.\n this._feedConsumer.once('close', onClose);\n\n // Pipe readable stream into writable consumer.\n feedStream.pipe(this._feedConsumer, (err) => {\n if (err) {\n onError(err);\n }\n this._destroyConsumer();\n });\n\n log('opened');\n }\n\n /**\n * Closes the queue.\n */\n async close(): Promise<void> {\n if (this.isOpen) {\n invariant(this._feedConsumer);\n invariant(!this._feed.properties.closed);\n\n log('closing', { feedKey: this._feed.key });\n const [closed, setClosed] = latch();\n this._feedConsumer.once('close', setClosed);\n this._feedConsumer.destroy();\n this._next?.(); // Release any message currently in the queue (otherwise destroy will block).\n await closed();\n log('closed');\n }\n }\n\n /**\n * Get the block at the head of the queue without removing it.\n */\n peek(): FeedBlock<T> | undefined {\n return this._currentBlock;\n }\n\n /**\n * Pop block at the head of the queue.\n */\n async pop(): Promise<FeedBlock<T>> {\n if (!this.isOpen) {\n throw new Error(`Queue closed: ${this.feed.key.truncate()}`);\n }\n\n let block = this.peek();\n if (!block) {\n block = await this._messageTrigger.wait();\n }\n\n if (block) {\n this._next?.();\n }\n\n return block;\n }\n\n private _destroyConsumer(): void {\n if (this._feedConsumer) {\n log('queue closed', { feedKey: this._feed.key });\n this._feedConsumer = undefined;\n this._next = undefined;\n this._currentBlock = undefined;\n this._index = -1;\n }\n }\n}\n", "//\n// Copyright 2020 DXOS.org\n//\n\nimport { inspect } from 'node:util';\n\nimport { Event, SubscriptionList, Trigger } from '@dxos/async';\nimport { inspectObject } from '@dxos/debug';\nimport { invariant } from '@dxos/invariant';\nimport { PublicKey } from '@dxos/keys';\nimport { log } from '@dxos/log';\nimport { ComplexMap, isNonNullable } from '@dxos/util';\n\nimport { AbstractFeedIterator } from './feed-iterator';\nimport { FeedQueue } from './feed-queue';\nimport { type FeedWrapper } from './feed-wrapper';\nimport { type FeedBlock } from './types';\n\n/**\n * Select next block.\n */\nexport type FeedBlockSelector<T> = (blocks: FeedBlock<T>[]) => number | undefined;\n\nexport type FeedIndex = {\n feedKey: PublicKey;\n index: number;\n};\n\nexport type FeedSetIteratorOptions = {\n // TODO(burdon): Should we remove this and assume the feeds are positioned before adding?\n start?: FeedIndex[];\n stallTimeout?: number;\n};\n\nexport const defaultFeedSetIteratorOptions = {\n stallTimeout: 1000,\n};\n\n/**\n * Iterator that reads blocks from multiple feeds, ordering them based on a traversal callback.\n */\nexport class FeedSetIterator<T extends {}> extends AbstractFeedIterator<T> {\n private readonly _feedQueues = new ComplexMap<PublicKey, FeedQueue<T>>(PublicKey.hash);\n\n private readonly _trigger = new Trigger({ autoReset: true });\n private readonly _subscriptions = new SubscriptionList();\n\n public readonly stalled = new Event<FeedSetIterator<T>>();\n\n constructor(\n private readonly _selector: FeedBlockSelector<T>,\n public readonly options: FeedSetIteratorOptions = defaultFeedSetIteratorOptions,\n ) {\n super();\n invariant(_selector);\n invariant(options);\n }\n\n [inspect.custom](): string {\n return inspectObject(this);\n }\n\n override toJSON(): { open: boolean; running: boolean; indexes: FeedIndex[] } {\n return {\n open: this.isOpen,\n running: this.isRunning,\n indexes: this.indexes,\n };\n }\n\n get size() {\n return this._feedQueues.size;\n }\n\n get feeds(): FeedWrapper<T>[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => feedQueue.feed);\n }\n\n get indexes(): FeedIndex[] {\n return Array.from(this._feedQueues.values()).map((feedQueue) => ({\n feedKey: feedQueue.feed.key,\n index: feedQueue.index,\n }));\n }\n\n reiterateBlock(block: FeedBlock<T>): void {\n this._trigger.wake();\n }\n\n async addFeed(feed: FeedWrapper<T>): Promise<void> {\n invariant(!this._feedQueues.has(feed.key), `Feed already added: ${feed.key}`);\n invariant(feed.properties.opened);\n log('feed added', { feedKey: feed.key });\n\n // Create queue and listen for updates.\n const queue = new FeedQueue<T>(feed);\n this._feedQueues.set(feed.key, queue);\n this._subscriptions.add(\n queue.updated.on(() => {\n this._trigger.wake();\n }),\n );\n\n await queue.open({\n start: this.options.start?.find((index) => index.feedKey.equals(feed.key))?.index,\n });\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n hasFeed(feedKey: PublicKey): boolean {\n return this._feedQueues.has(feedKey);\n }\n\n override async _onOpen(): Promise<void> {\n for (const queue of this._feedQueues.values()) {\n await queue.open();\n }\n }\n\n override async _onClose(): Promise<void> {\n this._subscriptions.clear();\n await Promise.all(Array.from(this._feedQueues.values()).map((queue) => queue.close()));\n\n // Wake when feed added or queue updated.\n this._trigger.wake();\n }\n\n /**\n * Gets the next block from the selected queue.\n */\n override async _nextBlock(): Promise<FeedBlock<T> | undefined> {\n let t: NodeJS.Timeout | undefined;\n\n while (this._running) {\n // Get blocks from the head of each queue.\n const queues = Array.from(this._feedQueues.values());\n const blocks = queues.map((queue) => queue.peek()).filter(isNonNullable);\n if (blocks.length) {\n // Get the selected block from candidates.\n const idx = this._selector(blocks);\n log('selected', { idx, blocks });\n if (idx === undefined) {\n // Timeout if all candidates are rejected.\n if (t === undefined) {\n t = setTimeout(() => {\n this.stalled.emit(this);\n this._trigger.wake();\n }, this.options.stallTimeout);\n }\n } else {\n if (t !== undefined) {\n clearTimeout(t);\n t = undefined;\n }\n if (idx >= blocks.length) {\n throw new Error(`Index out of bounds: ${idx} of ${blocks.length}`);\n }\n\n // Pop from queue.\n const queue = this._feedQueues.get(blocks[idx].feedKey)!;\n log('popping', queue.toJSON());\n try {\n const message = await queue.pop();\n invariant(message === blocks[idx]);\n return message;\n } catch (err) {\n // TODO(burdon): Same queue closed twice.\n log.warn('queue closed', { feedKey: queue.feed.key });\n // console.log(Array.from(this._feedQueues.values()));\n }\n }\n }\n\n // Wait until feed added, new block, or closing.\n await this._trigger.wait();\n }\n }\n}\n", "//\n// Copyright 2022 DXOS.org\n//\n\nimport { type PublicKey } from '@dxos/keys';\n\nexport type WriteReceipt = {\n feedKey: PublicKey;\n seq: number;\n};\n\nexport type WriteOptions = {\n /**\n * Called after the write is complete.\n * Runs and completes before the mutation is read from the pipeline.\n */\n afterWrite?: (receipt: WriteReceipt) => Promise<void>;\n};\n\nexport interface FeedWriter<T extends {}> {\n /**\n * Write data to the feed.\n * Awaits `afterWrite` before returning.\n */\n write(data: T, options?: WriteOptions): Promise<WriteReceipt>;\n}\n\nexport const createFeedWriter = <T extends {}>(cb: (data: T) => Promise<WriteReceipt>): FeedWriter<T> => ({\n write: async (data: T) => {\n return cb(data);\n },\n});\n\nexport const writeMessages = async <T extends {}>(writer: FeedWriter<T>, messages: T[]): Promise<WriteReceipt[]> => {\n const receipts: WriteReceipt[] = [];\n // NOTE: Write messages sequentially.\n for (const message of messages) {\n receipts.push(await writer.write(message));\n }\n return receipts;\n};\n"],
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AA,GAAA,CAAA,2BAAA,EAAA,EAAA,CAAA;AACZ,mBAAA;mBACI+C,KAAK;AAA0C,YAAAnB,KAAA,KAAA,gBAAA;cACnD,SAAA,MAAA,KAAA;YACF,GAAA,EAAA,YAAA,YAAA,GAAA5B,eAAA,GAAA,KAAA,GAAA,KAAA,CAAA;UAEJ;QAEA;MACA;AAEJ,YAAA,KAAA,SAAA,KAAA;IACF;;;;;ACxJO,IAAMgD,mBAAmB,CAAeC,QAA2D;EACxGC,OAAO,OAAOC,SAAAA;AACZ,WAAOF,GAAGE,IAAAA;EACZ;AACF;AAEO,IAAMC,gBAAgB,OAAqBC,QAAuBC,aAAAA;AACvE,QAAMC,WAA2B,CAAA;AAEjC,aAAWC,WAAWF,UAAU;AAC9BC,aAASE,KAAK,MAAMJ,OAAOH,MAAMM,OAAAA,CAAAA;EACnC;AACA,SAAOD;AACT;",
|
|
6
|
+
"names": ["safeRace", "Trigger", "invariant", "log", "inspect", "Writable", "Event", "Trigger", "latch", "inspectObject", "invariant", "log", "defaultReadStreamOptions", "batch", "updated", "_messageTrigger", "autoReset", "_feedConsumer", "_next", "_currentBlock", "undefined", "_index", "_options", "custom", "toJSON", "feedKey", "index", "length", "open", "isOpen", "feed", "Object", "assign", "write", "next", "seq", "data", "onError", "_destroyConsumer", "err", "catch", "once", "onClose", "feedStream", "_feed", "closed", "setClosed", "destroy", "block", "peek", "__dxlog_file", "_open", "_running", "Trigger", "toJSON", "open", "running", "isOpen", "isRunning", "_onOpen", "log", "start", "stop", "_onClose", "_stopTrigger", "_generator", "block", "_nextBlock", "undefined", "_queue", "inspect", "Event", "SubscriptionList", "Trigger", "inspectObject", "invariant", "PublicKey", "log", "ComplexMap", "isNonNullable", "__dxlog_file", "defaultFeedSetIteratorOptions", "_feedQueues", "_trigger", "autoReset", "Trigger", "_subscriptions", "stalled", "_selector", "Event", "invariant", "options", "inspect", "custom", "toJSON", "inspectObject", "open", "running", "indexes", "size", "feeds", "feedKey", "index", "feedQueue", "reiterateBlock", "addFeed", "feed", "properties", "log", "FeedQueue", "queue", "updated", "wake", "hasFeed", "_onOpen", "Promise", "_running", "queues", "Array", "blocks", "length", "idx", "t", "undefined", "emit", "stallTimeout", "message", "warn", "createFeedWriter", "cb", "write", "data", "writeMessages", "writer", "messages", "receipts", "message", "push"]
|
|
7
7
|
}
|