@dxos/echo-pipeline 0.1.56-main.e47dfd1 → 0.1.56-main.ec576e1
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-7U2NXI2P.mjs → chunk-GELWTWOW.mjs} +694 -355
- package/dist/lib/browser/chunk-GELWTWOW.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +14 -18
- package/dist/lib/browser/testing/index.mjs.map +3 -3
- package/dist/lib/node/index.cjs +701 -362
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +698 -363
- package/dist/lib/node/testing/index.cjs.map +3 -3
- package/dist/types/src/common/feeds.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service-host.d.ts.map +1 -1
- package/dist/types/src/db-host/data-service.d.ts.map +1 -1
- package/dist/types/src/db-host/snapshot-manager.d.ts.map +1 -1
- package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
- package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
- package/dist/types/src/pipeline/pipeline-stress.test.d.ts +2 -0
- package/dist/types/src/pipeline/pipeline-stress.test.d.ts.map +1 -0
- package/dist/types/src/pipeline/pipeline.d.ts +4 -3
- package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
- package/dist/types/src/space/auth.d.ts.map +1 -1
- package/dist/types/src/space/control-pipeline.d.ts +4 -0
- package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/data-pipeline.d.ts +2 -0
- package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/dist/types/src/space/space-protocol.d.ts.map +1 -1
- package/dist/types/src/space/space.d.ts +2 -1
- package/dist/types/src/space/space.d.ts.map +1 -1
- package/dist/types/src/testing/database-test-rig.d.ts +4 -1
- package/dist/types/src/testing/database-test-rig.d.ts.map +1 -1
- package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
- package/package.json +32 -31
- package/src/common/feeds.ts +1 -2
- package/src/db-host/data-service-host.ts +10 -4
- package/src/db-host/data-service.ts +1 -2
- package/src/db-host/snapshot-manager.ts +0 -2
- package/src/metadata/metadata-store.ts +2 -2
- package/src/pipeline/message-selector.ts +1 -2
- package/src/pipeline/pipeline-stress.test.ts +226 -0
- package/src/pipeline/pipeline.test.ts +30 -206
- package/src/pipeline/pipeline.ts +50 -24
- package/src/space/auth.ts +1 -2
- package/src/space/control-pipeline.ts +47 -22
- package/src/space/data-pipeline.ts +21 -12
- package/src/space/space-manager.ts +1 -0
- package/src/space/space-protocol.ts +3 -1
- package/src/space/space.test.ts +18 -17
- package/src/space/space.ts +7 -3
- package/src/testing/database-test-rig.ts +27 -2
- package/src/testing/test-agent-builder.ts +2 -1
- package/src/tests/database-unit.test.ts +39 -0
- package/dist/lib/browser/chunk-7U2NXI2P.mjs.map +0 -7
|
@@ -7,23 +7,41 @@ var codec = schema.getCodecForType("dxos.echo.feed.FeedMessage");
|
|
|
7
7
|
var valueEncoding = createCodecEncoding(codec);
|
|
8
8
|
|
|
9
9
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
10
|
-
import invariant from "
|
|
10
|
+
import { invariant } from "@dxos/invariant";
|
|
11
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
11
12
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
12
|
-
invariant(mapper
|
|
13
|
-
|
|
13
|
+
invariant(mapper, void 0, {
|
|
14
|
+
F: __dxlog_file,
|
|
15
|
+
L: 16,
|
|
16
|
+
S: void 0,
|
|
17
|
+
A: [
|
|
18
|
+
"mapper",
|
|
19
|
+
""
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
invariant(writer, void 0, {
|
|
23
|
+
F: __dxlog_file,
|
|
24
|
+
L: 17,
|
|
25
|
+
S: void 0,
|
|
26
|
+
A: [
|
|
27
|
+
"writer",
|
|
28
|
+
""
|
|
29
|
+
]
|
|
30
|
+
});
|
|
14
31
|
return {
|
|
15
32
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
16
33
|
};
|
|
17
34
|
};
|
|
18
35
|
|
|
19
36
|
// packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts
|
|
20
|
-
import invariant2 from "tiny-invariant";
|
|
21
37
|
import { Stream } from "@dxos/codec-protobuf";
|
|
22
38
|
import { Context } from "@dxos/context";
|
|
23
39
|
import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
|
|
40
|
+
import { invariant as invariant2 } from "@dxos/invariant";
|
|
24
41
|
import { log } from "@dxos/log";
|
|
42
|
+
import { EchoEvent } from "@dxos/protocols/proto/dxos/echo/service";
|
|
25
43
|
import { ComplexMap } from "@dxos/util";
|
|
26
|
-
var
|
|
44
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
27
45
|
var DataServiceHost = class {
|
|
28
46
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
29
47
|
this._itemManager = _itemManager;
|
|
@@ -49,16 +67,31 @@ var DataServiceHost = class {
|
|
|
49
67
|
objects
|
|
50
68
|
}
|
|
51
69
|
});
|
|
70
|
+
this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
|
|
71
|
+
next({
|
|
72
|
+
action: EchoEvent.DatabaseAction.RESET,
|
|
73
|
+
batch: {
|
|
74
|
+
objects: snapshot.items
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
});
|
|
52
78
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
53
|
-
var _a;
|
|
54
79
|
const { batch, meta } = message;
|
|
55
|
-
invariant2(!meta.clientTag, "Unexpected client tag in mutation message"
|
|
80
|
+
invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
81
|
+
F: __dxlog_file2,
|
|
82
|
+
L: 68,
|
|
83
|
+
S: this,
|
|
84
|
+
A: [
|
|
85
|
+
"!(meta as any).clientTag",
|
|
86
|
+
"'Unexpected client tag in mutation message'"
|
|
87
|
+
]
|
|
88
|
+
});
|
|
56
89
|
log("message", {
|
|
57
|
-
batch,
|
|
90
|
+
batch: batch.objects?.length,
|
|
58
91
|
meta
|
|
59
92
|
}, {
|
|
60
|
-
F:
|
|
61
|
-
L:
|
|
93
|
+
F: __dxlog_file2,
|
|
94
|
+
L: 69,
|
|
62
95
|
S: this,
|
|
63
96
|
C: (f, a) => f(...a)
|
|
64
97
|
});
|
|
@@ -66,7 +99,7 @@ var DataServiceHost = class {
|
|
|
66
99
|
message.meta.feedKey,
|
|
67
100
|
message.meta.seq
|
|
68
101
|
]);
|
|
69
|
-
|
|
102
|
+
batch.objects?.forEach((object) => {
|
|
70
103
|
setMetadataOnObject(object, {
|
|
71
104
|
...meta
|
|
72
105
|
});
|
|
@@ -84,15 +117,30 @@ var DataServiceHost = class {
|
|
|
84
117
|
});
|
|
85
118
|
}
|
|
86
119
|
async write(request) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
120
|
+
invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
121
|
+
F: __dxlog_file2,
|
|
122
|
+
L: 95,
|
|
123
|
+
S: this,
|
|
124
|
+
A: [
|
|
125
|
+
"!this._ctx.disposed",
|
|
126
|
+
"'Cannot write to closed DataServiceHost'"
|
|
127
|
+
]
|
|
128
|
+
});
|
|
129
|
+
invariant2(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
130
|
+
F: __dxlog_file2,
|
|
131
|
+
L: 96,
|
|
132
|
+
S: this,
|
|
133
|
+
A: [
|
|
134
|
+
"this._writeStream",
|
|
135
|
+
"'Cannot write mutations in readonly mode'"
|
|
136
|
+
]
|
|
137
|
+
});
|
|
90
138
|
log("write", {
|
|
91
139
|
clientTag: request.clientTag,
|
|
92
|
-
objectCount:
|
|
140
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
93
141
|
}, {
|
|
94
|
-
F:
|
|
95
|
-
L:
|
|
142
|
+
F: __dxlog_file2,
|
|
143
|
+
L: 98,
|
|
96
144
|
S: this,
|
|
97
145
|
C: (f, a) => f(...a)
|
|
98
146
|
});
|
|
@@ -105,8 +153,8 @@ var DataServiceHost = class {
|
|
|
105
153
|
feedKey: receipt2.feedKey,
|
|
106
154
|
seq: receipt2.seq
|
|
107
155
|
}, {
|
|
108
|
-
F:
|
|
109
|
-
L:
|
|
156
|
+
F: __dxlog_file2,
|
|
157
|
+
L: 107,
|
|
110
158
|
S: this,
|
|
111
159
|
C: (f, a) => f(...a)
|
|
112
160
|
});
|
|
@@ -120,24 +168,18 @@ var DataServiceHost = class {
|
|
|
120
168
|
return receipt;
|
|
121
169
|
}
|
|
122
170
|
};
|
|
123
|
-
var createDataMessage = (batch) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
meta: void 0
|
|
136
|
-
};
|
|
137
|
-
})
|
|
138
|
-
}
|
|
139
|
-
};
|
|
140
|
-
};
|
|
171
|
+
var createDataMessage = (batch) => ({
|
|
172
|
+
batch: {
|
|
173
|
+
objects: batch.objects?.map((object) => ({
|
|
174
|
+
...object,
|
|
175
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
176
|
+
...mutation,
|
|
177
|
+
meta: void 0
|
|
178
|
+
})),
|
|
179
|
+
meta: void 0
|
|
180
|
+
}))
|
|
181
|
+
}
|
|
182
|
+
});
|
|
141
183
|
|
|
142
184
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
143
185
|
import { ItemDemuxer } from "@dxos/echo-db";
|
|
@@ -166,15 +208,13 @@ var DatabaseHost = class {
|
|
|
166
208
|
return this._itemDemuxer.createSnapshot();
|
|
167
209
|
}
|
|
168
210
|
createDataServiceHost() {
|
|
169
|
-
|
|
170
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
211
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
171
212
|
}
|
|
172
213
|
};
|
|
173
214
|
|
|
174
215
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
175
216
|
import { trackLeaks } from "@dxos/async";
|
|
176
217
|
import { cancelWithContext } from "@dxos/context";
|
|
177
|
-
import { timed } from "@dxos/debug";
|
|
178
218
|
import { PublicKey } from "@dxos/keys";
|
|
179
219
|
import { schema as schema2 } from "@dxos/protocols";
|
|
180
220
|
import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
|
|
@@ -219,9 +259,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
219
259
|
return PublicKey.from(id).toHex();
|
|
220
260
|
}
|
|
221
261
|
};
|
|
222
|
-
_ts_decorate([
|
|
223
|
-
timed(1e4)
|
|
224
|
-
], SnapshotManager.prototype, "load", null);
|
|
225
262
|
SnapshotManager = _ts_decorate([
|
|
226
263
|
trackLeaks("open", "close")
|
|
227
264
|
], SnapshotManager);
|
|
@@ -273,12 +310,12 @@ var SnapshotStore = class {
|
|
|
273
310
|
};
|
|
274
311
|
|
|
275
312
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
276
|
-
import invariant3 from "tiny-invariant";
|
|
277
313
|
import { raise } from "@dxos/debug";
|
|
314
|
+
import { invariant as invariant3 } from "@dxos/invariant";
|
|
278
315
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
279
316
|
import { log as log2 } from "@dxos/log";
|
|
280
317
|
import { ComplexMap as ComplexMap2 } from "@dxos/util";
|
|
281
|
-
var
|
|
318
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
282
319
|
var DataServiceSubscriptions = class {
|
|
283
320
|
constructor() {
|
|
284
321
|
this._spaces = new ComplexMap2(PublicKey2.hash);
|
|
@@ -290,12 +327,20 @@ var DataServiceSubscriptions = class {
|
|
|
290
327
|
log2("Registering space", {
|
|
291
328
|
spaceKey
|
|
292
329
|
}, {
|
|
293
|
-
F:
|
|
294
|
-
L:
|
|
330
|
+
F: __dxlog_file3,
|
|
331
|
+
L: 30,
|
|
295
332
|
S: this,
|
|
296
333
|
C: (f, a) => f(...a)
|
|
297
334
|
});
|
|
298
|
-
invariant3(!this._spaces.has(spaceKey)
|
|
335
|
+
invariant3(!this._spaces.has(spaceKey), void 0, {
|
|
336
|
+
F: __dxlog_file3,
|
|
337
|
+
L: 31,
|
|
338
|
+
S: this,
|
|
339
|
+
A: [
|
|
340
|
+
"!this._spaces.has(spaceKey)",
|
|
341
|
+
""
|
|
342
|
+
]
|
|
343
|
+
});
|
|
299
344
|
await host.open();
|
|
300
345
|
this._spaces.set(spaceKey, host);
|
|
301
346
|
}
|
|
@@ -303,13 +348,13 @@ var DataServiceSubscriptions = class {
|
|
|
303
348
|
log2("Unregistering space", {
|
|
304
349
|
spaceKey
|
|
305
350
|
}, {
|
|
306
|
-
F:
|
|
307
|
-
L:
|
|
351
|
+
F: __dxlog_file3,
|
|
352
|
+
L: 37,
|
|
308
353
|
S: this,
|
|
309
354
|
C: (f, a) => f(...a)
|
|
310
355
|
});
|
|
311
356
|
const host = this._spaces.get(spaceKey);
|
|
312
|
-
await
|
|
357
|
+
await host?.close();
|
|
313
358
|
this._spaces.delete(spaceKey);
|
|
314
359
|
}
|
|
315
360
|
getDataService(spaceKey) {
|
|
@@ -321,25 +366,47 @@ var DataServiceImpl = class {
|
|
|
321
366
|
this._subscriptions = _subscriptions;
|
|
322
367
|
}
|
|
323
368
|
subscribe(request) {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
369
|
+
invariant3(request.spaceKey, void 0, {
|
|
370
|
+
F: __dxlog_file3,
|
|
371
|
+
L: 56,
|
|
372
|
+
S: this,
|
|
373
|
+
A: [
|
|
374
|
+
"request.spaceKey",
|
|
375
|
+
""
|
|
376
|
+
]
|
|
377
|
+
});
|
|
378
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
327
379
|
return host.subscribe();
|
|
328
380
|
}
|
|
329
381
|
write(request) {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
382
|
+
invariant3(request.spaceKey, void 0, {
|
|
383
|
+
F: __dxlog_file3,
|
|
384
|
+
L: 63,
|
|
385
|
+
S: this,
|
|
386
|
+
A: [
|
|
387
|
+
"request.spaceKey",
|
|
388
|
+
""
|
|
389
|
+
]
|
|
390
|
+
});
|
|
391
|
+
invariant3(request.batch, void 0, {
|
|
392
|
+
F: __dxlog_file3,
|
|
393
|
+
L: 64,
|
|
394
|
+
S: this,
|
|
395
|
+
A: [
|
|
396
|
+
"request.batch",
|
|
397
|
+
""
|
|
398
|
+
]
|
|
399
|
+
});
|
|
400
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
|
|
334
401
|
return host.write(request);
|
|
335
402
|
}
|
|
336
403
|
};
|
|
337
404
|
|
|
338
405
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
339
406
|
import CRC32 from "crc-32";
|
|
340
|
-
import invariant4 from "tiny-invariant";
|
|
341
407
|
import { synchronized, Event } from "@dxos/async";
|
|
342
408
|
import { DataCorruptionError } from "@dxos/errors";
|
|
409
|
+
import { invariant as invariant4 } from "@dxos/invariant";
|
|
343
410
|
import { log as log3 } from "@dxos/log";
|
|
344
411
|
import { STORAGE_VERSION, schema as schema4 } from "@dxos/protocols";
|
|
345
412
|
import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
|
|
@@ -354,12 +421,12 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
354
421
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
355
422
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
356
423
|
}
|
|
357
|
-
var
|
|
424
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
358
425
|
var emptyEchoMetadata = () => ({
|
|
359
426
|
version: STORAGE_VERSION,
|
|
360
427
|
spaces: [],
|
|
361
|
-
created: new Date(),
|
|
362
|
-
updated: new Date()
|
|
428
|
+
created: /* @__PURE__ */ new Date(),
|
|
429
|
+
updated: /* @__PURE__ */ new Date()
|
|
363
430
|
});
|
|
364
431
|
var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
365
432
|
var MetadataStore = class {
|
|
@@ -373,22 +440,19 @@ var MetadataStore = class {
|
|
|
373
440
|
return this._metadata;
|
|
374
441
|
}
|
|
375
442
|
get version() {
|
|
376
|
-
|
|
377
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
443
|
+
return this._metadata.version ?? 0;
|
|
378
444
|
}
|
|
379
445
|
/**
|
|
380
446
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
381
447
|
* addSpaceFeed functions.
|
|
382
448
|
*/
|
|
383
449
|
get spaces() {
|
|
384
|
-
|
|
385
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
450
|
+
return this._metadata.spaces ?? [];
|
|
386
451
|
}
|
|
387
452
|
/**
|
|
388
453
|
* Loads metadata from persistent storage.
|
|
389
454
|
*/
|
|
390
455
|
async load() {
|
|
391
|
-
var _a;
|
|
392
456
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
393
457
|
try {
|
|
394
458
|
const { size: fileLength } = await file.stat();
|
|
@@ -401,13 +465,16 @@ var MetadataStore = class {
|
|
|
401
465
|
size: dataSize,
|
|
402
466
|
checksum
|
|
403
467
|
}, {
|
|
404
|
-
F:
|
|
468
|
+
F: __dxlog_file4,
|
|
405
469
|
L: 72,
|
|
406
470
|
S: this,
|
|
407
471
|
C: (f, a) => f(...a)
|
|
408
472
|
});
|
|
409
473
|
if (fileLength < dataSize + 8) {
|
|
410
|
-
throw new DataCorruptionError("Metadata size is smaller than expected."
|
|
474
|
+
throw new DataCorruptionError("Metadata size is smaller than expected.", {
|
|
475
|
+
fileLength,
|
|
476
|
+
dataSize
|
|
477
|
+
});
|
|
411
478
|
}
|
|
412
479
|
const data = await file.read(8, dataSize);
|
|
413
480
|
const calculatedChecksum = CRC32.buf(data);
|
|
@@ -415,15 +482,14 @@ var MetadataStore = class {
|
|
|
415
482
|
throw new DataCorruptionError("Metadata checksum is invalid.");
|
|
416
483
|
}
|
|
417
484
|
this._metadata = EchoMetadata.decode(data);
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
(_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
|
|
485
|
+
this._metadata.spaces?.forEach((space) => {
|
|
486
|
+
space.state ??= SpaceState.ACTIVE;
|
|
421
487
|
});
|
|
422
488
|
} catch (err) {
|
|
423
489
|
log3.error("failed to load metadata", {
|
|
424
490
|
err
|
|
425
491
|
}, {
|
|
426
|
-
F:
|
|
492
|
+
F: __dxlog_file4,
|
|
427
493
|
L: 92,
|
|
428
494
|
S: this,
|
|
429
495
|
C: (f, a) => f(...a)
|
|
@@ -434,12 +500,11 @@ var MetadataStore = class {
|
|
|
434
500
|
}
|
|
435
501
|
}
|
|
436
502
|
async _save() {
|
|
437
|
-
var _a;
|
|
438
503
|
const data = {
|
|
439
504
|
...this._metadata,
|
|
440
505
|
version: STORAGE_VERSION,
|
|
441
|
-
created:
|
|
442
|
-
updated: new Date()
|
|
506
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
507
|
+
updated: /* @__PURE__ */ new Date()
|
|
443
508
|
};
|
|
444
509
|
this.update.emit(data);
|
|
445
510
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -455,7 +520,7 @@ var MetadataStore = class {
|
|
|
455
520
|
size: encoded.length,
|
|
456
521
|
checksum
|
|
457
522
|
}, {
|
|
458
|
-
F:
|
|
523
|
+
F: __dxlog_file4,
|
|
459
524
|
L: 124,
|
|
460
525
|
S: this,
|
|
461
526
|
C: (f, a) => f(...a)
|
|
@@ -465,12 +530,19 @@ var MetadataStore = class {
|
|
|
465
530
|
}
|
|
466
531
|
}
|
|
467
532
|
_getSpace(spaceKey) {
|
|
468
|
-
|
|
469
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
533
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
470
534
|
return this._metadata.identity.haloSpace;
|
|
471
535
|
}
|
|
472
536
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
473
|
-
invariant4(space, "Space not found"
|
|
537
|
+
invariant4(space, "Space not found", {
|
|
538
|
+
F: __dxlog_file4,
|
|
539
|
+
L: 137,
|
|
540
|
+
S: this,
|
|
541
|
+
A: [
|
|
542
|
+
"space",
|
|
543
|
+
"'Space not found'"
|
|
544
|
+
]
|
|
545
|
+
});
|
|
474
546
|
return space;
|
|
475
547
|
}
|
|
476
548
|
/**
|
|
@@ -478,7 +550,7 @@ var MetadataStore = class {
|
|
|
478
550
|
*/
|
|
479
551
|
async clear() {
|
|
480
552
|
log3("clearing all metadata", void 0, {
|
|
481
|
-
F:
|
|
553
|
+
F: __dxlog_file4,
|
|
482
554
|
L: 145,
|
|
483
555
|
S: this,
|
|
484
556
|
C: (f, a) => f(...a)
|
|
@@ -490,14 +562,29 @@ var MetadataStore = class {
|
|
|
490
562
|
return this._metadata.identity;
|
|
491
563
|
}
|
|
492
564
|
async setIdentityRecord(record) {
|
|
493
|
-
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata"
|
|
565
|
+
invariant4(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
566
|
+
F: __dxlog_file4,
|
|
567
|
+
L: 155,
|
|
568
|
+
S: this,
|
|
569
|
+
A: [
|
|
570
|
+
"!this._metadata.identity",
|
|
571
|
+
"'Cannot overwrite existing identity in metadata'"
|
|
572
|
+
]
|
|
573
|
+
});
|
|
494
574
|
this._metadata.identity = record;
|
|
495
575
|
await this._save();
|
|
496
576
|
}
|
|
497
577
|
async addSpace(record) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
578
|
+
invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
579
|
+
F: __dxlog_file4,
|
|
580
|
+
L: 162,
|
|
581
|
+
S: this,
|
|
582
|
+
A: [
|
|
583
|
+
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
584
|
+
"'Cannot overwrite existing space in metadata'"
|
|
585
|
+
]
|
|
586
|
+
});
|
|
587
|
+
(this._metadata.spaces ??= []).push(record);
|
|
501
588
|
await this._save();
|
|
502
589
|
}
|
|
503
590
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -533,7 +620,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
|
533
620
|
|
|
534
621
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
535
622
|
import { Event as Event2 } from "@dxos/async";
|
|
536
|
-
import { timed
|
|
623
|
+
import { timed } from "@dxos/debug";
|
|
537
624
|
import { log as log4 } from "@dxos/log";
|
|
538
625
|
import { Timeframe } from "@dxos/timeframe";
|
|
539
626
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -546,7 +633,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
546
633
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
547
634
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
548
635
|
}
|
|
549
|
-
var
|
|
636
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
550
637
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
551
638
|
feedKey,
|
|
552
639
|
index
|
|
@@ -605,7 +692,7 @@ var TimeframeClock = class {
|
|
|
605
692
|
target,
|
|
606
693
|
current: this._timeframe
|
|
607
694
|
}, {
|
|
608
|
-
F:
|
|
695
|
+
F: __dxlog_file5,
|
|
609
696
|
L: 73,
|
|
610
697
|
S: this,
|
|
611
698
|
C: (f, a) => f(...a)
|
|
@@ -616,7 +703,7 @@ var TimeframeClock = class {
|
|
|
616
703
|
current: this._timeframe,
|
|
617
704
|
deps: Timeframe.dependencies(target, this._timeframe)
|
|
618
705
|
}, {
|
|
619
|
-
F:
|
|
706
|
+
F: __dxlog_file5,
|
|
620
707
|
L: 75,
|
|
621
708
|
S: this,
|
|
622
709
|
C: (f, a) => f(...a)
|
|
@@ -626,36 +713,44 @@ var TimeframeClock = class {
|
|
|
626
713
|
}
|
|
627
714
|
};
|
|
628
715
|
_ts_decorate3([
|
|
629
|
-
|
|
716
|
+
timed(5e3)
|
|
630
717
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
631
718
|
|
|
632
719
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
633
|
-
import invariant6 from "tiny-invariant";
|
|
634
720
|
import { Event as Event3, sleep, synchronized as synchronized2, Trigger } from "@dxos/async";
|
|
635
721
|
import { Context as Context2, rejectOnDispose } from "@dxos/context";
|
|
636
722
|
import { failUndefined } from "@dxos/debug";
|
|
637
723
|
import { FeedSetIterator } from "@dxos/feed-store";
|
|
724
|
+
import { invariant as invariant6 } from "@dxos/invariant";
|
|
638
725
|
import { PublicKey as PublicKey3 } from "@dxos/keys";
|
|
639
726
|
import { log as log6 } from "@dxos/log";
|
|
640
727
|
import { Timeframe as Timeframe2 } from "@dxos/timeframe";
|
|
641
728
|
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
642
729
|
|
|
643
730
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
644
|
-
import invariant5 from "
|
|
731
|
+
import { invariant as invariant5 } from "@dxos/invariant";
|
|
645
732
|
import { log as log5 } from "@dxos/log";
|
|
646
|
-
var
|
|
733
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
647
734
|
var createMessageSelector = (timeframeClock) => {
|
|
648
735
|
return (messages) => {
|
|
649
736
|
for (let i = 0; i < messages.length; i++) {
|
|
650
737
|
const { data: { timeframe } } = messages[i];
|
|
651
|
-
invariant5(timeframe
|
|
738
|
+
invariant5(timeframe, void 0, {
|
|
739
|
+
F: __dxlog_file6,
|
|
740
|
+
L: 25,
|
|
741
|
+
S: void 0,
|
|
742
|
+
A: [
|
|
743
|
+
"timeframe",
|
|
744
|
+
""
|
|
745
|
+
]
|
|
746
|
+
});
|
|
652
747
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
653
748
|
return i;
|
|
654
749
|
}
|
|
655
750
|
}
|
|
656
751
|
log5("Skipping...", void 0, {
|
|
657
|
-
F:
|
|
658
|
-
L:
|
|
752
|
+
F: __dxlog_file6,
|
|
753
|
+
L: 33,
|
|
659
754
|
S: void 0,
|
|
660
755
|
C: (f, a) => f(...a)
|
|
661
756
|
});
|
|
@@ -673,7 +768,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
673
768
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
674
769
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
675
770
|
}
|
|
676
|
-
var
|
|
771
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
677
772
|
var PipelineState = class {
|
|
678
773
|
// prettier-ignore
|
|
679
774
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -724,18 +819,17 @@ var PipelineState = class {
|
|
|
724
819
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
725
820
|
*/
|
|
726
821
|
async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
|
|
727
|
-
var _a;
|
|
728
822
|
log6("waitUntilReachedTargetTimeframe", {
|
|
729
823
|
timeout,
|
|
730
824
|
current: this.timeframe,
|
|
731
825
|
target: this.targetTimeframe
|
|
732
826
|
}, {
|
|
733
|
-
F:
|
|
734
|
-
L:
|
|
827
|
+
F: __dxlog_file7,
|
|
828
|
+
L: 125,
|
|
735
829
|
S: this,
|
|
736
830
|
C: (f, a) => f(...a)
|
|
737
831
|
});
|
|
738
|
-
|
|
832
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
739
833
|
this._timeframeClock.update.waitForCondition(() => {
|
|
740
834
|
return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
741
835
|
}),
|
|
@@ -761,8 +855,8 @@ var PipelineState = class {
|
|
|
761
855
|
target: this.targetTimeframe,
|
|
762
856
|
dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
|
|
763
857
|
}, {
|
|
764
|
-
F:
|
|
765
|
-
L:
|
|
858
|
+
F: __dxlog_file7,
|
|
859
|
+
L: 152,
|
|
766
860
|
S: this,
|
|
767
861
|
C: (f, a) => f(...a)
|
|
768
862
|
});
|
|
@@ -782,16 +876,26 @@ var Pipeline = class {
|
|
|
782
876
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
783
877
|
this._processingTrigger = new Trigger().wake();
|
|
784
878
|
this._pauseTrigger = new Trigger().wake();
|
|
879
|
+
// Pending downloads.
|
|
880
|
+
this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
|
|
785
881
|
this._isStopping = false;
|
|
786
882
|
this._isStarted = false;
|
|
787
|
-
this.
|
|
883
|
+
this._isBeingConsumed = false;
|
|
788
884
|
this._isPaused = false;
|
|
789
885
|
}
|
|
790
886
|
get state() {
|
|
791
887
|
return this._state;
|
|
792
888
|
}
|
|
793
889
|
get writer() {
|
|
794
|
-
invariant6(this._writer, "Writer not set."
|
|
890
|
+
invariant6(this._writer, "Writer not set.", {
|
|
891
|
+
F: __dxlog_file7,
|
|
892
|
+
L: 233,
|
|
893
|
+
S: this,
|
|
894
|
+
A: [
|
|
895
|
+
"this._writer",
|
|
896
|
+
"'Writer not set.'"
|
|
897
|
+
]
|
|
898
|
+
});
|
|
795
899
|
return this._writer;
|
|
796
900
|
}
|
|
797
901
|
hasFeed(feedKey) {
|
|
@@ -807,20 +911,47 @@ var Pipeline = class {
|
|
|
807
911
|
if (this._feedSetIterator) {
|
|
808
912
|
await this._feedSetIterator.addFeed(feed);
|
|
809
913
|
}
|
|
810
|
-
this.
|
|
914
|
+
if (this._isStarted && !this._isPaused) {
|
|
915
|
+
this._setFeedDownloadState(feed);
|
|
916
|
+
}
|
|
811
917
|
}
|
|
812
918
|
setWriteFeed(feed) {
|
|
813
|
-
invariant6(!this._writer, "Writer already set."
|
|
814
|
-
|
|
919
|
+
invariant6(!this._writer, "Writer already set.", {
|
|
920
|
+
F: __dxlog_file7,
|
|
921
|
+
L: 260,
|
|
922
|
+
S: this,
|
|
923
|
+
A: [
|
|
924
|
+
"!this._writer",
|
|
925
|
+
"'Writer already set.'"
|
|
926
|
+
]
|
|
927
|
+
});
|
|
928
|
+
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
929
|
+
F: __dxlog_file7,
|
|
930
|
+
L: 261,
|
|
931
|
+
S: this,
|
|
932
|
+
A: [
|
|
933
|
+
"feed.properties.writable",
|
|
934
|
+
"'Feed must be writable.'"
|
|
935
|
+
]
|
|
936
|
+
});
|
|
815
937
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
816
938
|
timeframe: this._timeframeClock.timeframe,
|
|
817
939
|
payload
|
|
818
940
|
}), feed.createFeedWriter());
|
|
819
941
|
}
|
|
820
942
|
async start() {
|
|
943
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
944
|
+
F: __dxlog_file7,
|
|
945
|
+
L: 274,
|
|
946
|
+
S: this,
|
|
947
|
+
A: [
|
|
948
|
+
"!this._isStarted",
|
|
949
|
+
"'Pipeline is already started.'"
|
|
950
|
+
]
|
|
951
|
+
});
|
|
821
952
|
log6("starting...", void 0, {
|
|
822
|
-
F:
|
|
823
|
-
L:
|
|
953
|
+
F: __dxlog_file7,
|
|
954
|
+
L: 275,
|
|
824
955
|
S: this,
|
|
825
956
|
C: (f, a) => f(...a)
|
|
826
957
|
});
|
|
@@ -828,30 +959,38 @@ var Pipeline = class {
|
|
|
828
959
|
await this._feedSetIterator.open();
|
|
829
960
|
this._isStarted = true;
|
|
830
961
|
log6("started", void 0, {
|
|
831
|
-
F:
|
|
832
|
-
L:
|
|
962
|
+
F: __dxlog_file7,
|
|
963
|
+
L: 279,
|
|
833
964
|
S: this,
|
|
834
965
|
C: (f, a) => f(...a)
|
|
835
966
|
});
|
|
967
|
+
if (!this._isPaused) {
|
|
968
|
+
for (const feed of this._feeds.values()) {
|
|
969
|
+
this._setFeedDownloadState(feed);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
836
972
|
}
|
|
837
973
|
async stop() {
|
|
838
|
-
var _a;
|
|
839
974
|
log6("stopping...", void 0, {
|
|
840
|
-
F:
|
|
841
|
-
L:
|
|
975
|
+
F: __dxlog_file7,
|
|
976
|
+
L: 290,
|
|
842
977
|
S: this,
|
|
843
978
|
C: (f, a) => f(...a)
|
|
844
979
|
});
|
|
845
980
|
this._isStopping = true;
|
|
846
|
-
|
|
981
|
+
for (const [feed, handle] of this._downloads.entries()) {
|
|
982
|
+
feed.undownload(handle);
|
|
983
|
+
}
|
|
984
|
+
this._downloads.clear();
|
|
985
|
+
await this._feedSetIterator?.close();
|
|
847
986
|
await this._processingTrigger.wait();
|
|
848
987
|
await this._state._ctx.dispose();
|
|
849
988
|
this._state._ctx = new Context2();
|
|
850
989
|
this._state._reachedTargetPromise = void 0;
|
|
851
990
|
this._isStarted = false;
|
|
852
991
|
log6("stopped", void 0, {
|
|
853
|
-
F:
|
|
854
|
-
L:
|
|
992
|
+
F: __dxlog_file7,
|
|
993
|
+
L: 302,
|
|
855
994
|
S: this,
|
|
856
995
|
C: (f, a) => f(...a)
|
|
857
996
|
});
|
|
@@ -861,12 +1000,17 @@ var Pipeline = class {
|
|
|
861
1000
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
862
1001
|
*/
|
|
863
1002
|
async setCursor(timeframe) {
|
|
864
|
-
invariant6(!this._isStarted || this._isPaused, "Invalid state."
|
|
1003
|
+
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
1004
|
+
F: __dxlog_file7,
|
|
1005
|
+
L: 311,
|
|
1006
|
+
S: this,
|
|
1007
|
+
A: [
|
|
1008
|
+
"!this._isStarted || this._isPaused",
|
|
1009
|
+
"'Invalid state.'"
|
|
1010
|
+
]
|
|
1011
|
+
});
|
|
865
1012
|
this._state._startTimeframe = timeframe;
|
|
866
1013
|
this._timeframeClock.setTimeframe(timeframe);
|
|
867
|
-
for (const feed of this._feeds.values()) {
|
|
868
|
-
this._setFeedDownloadState(feed);
|
|
869
|
-
}
|
|
870
1014
|
if (this._feedSetIterator) {
|
|
871
1015
|
await this._feedSetIterator.close();
|
|
872
1016
|
await this._initIterator();
|
|
@@ -877,7 +1021,6 @@ var Pipeline = class {
|
|
|
877
1021
|
* Calling pause while processing will cause a deadlock.
|
|
878
1022
|
*/
|
|
879
1023
|
async pause() {
|
|
880
|
-
invariant6(this._isStarted, "Pipeline is not open.");
|
|
881
1024
|
if (this._isPaused) {
|
|
882
1025
|
return;
|
|
883
1026
|
}
|
|
@@ -886,31 +1029,65 @@ var Pipeline = class {
|
|
|
886
1029
|
this._isPaused = true;
|
|
887
1030
|
}
|
|
888
1031
|
async unpause() {
|
|
889
|
-
invariant6(this.
|
|
890
|
-
|
|
1032
|
+
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1033
|
+
F: __dxlog_file7,
|
|
1034
|
+
L: 340,
|
|
1035
|
+
S: this,
|
|
1036
|
+
A: [
|
|
1037
|
+
"this._isPaused",
|
|
1038
|
+
"'Pipeline is not paused.'"
|
|
1039
|
+
]
|
|
1040
|
+
});
|
|
891
1041
|
this._pauseTrigger.wake();
|
|
892
1042
|
this._isPaused = false;
|
|
1043
|
+
for (const feed of this._feeds.values()) {
|
|
1044
|
+
this._setFeedDownloadState(feed);
|
|
1045
|
+
}
|
|
893
1046
|
}
|
|
894
1047
|
/**
|
|
895
1048
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
896
1049
|
* Updates the timeframe clock after the message has bee processed.
|
|
897
1050
|
*/
|
|
898
1051
|
async *consume() {
|
|
899
|
-
invariant6(!this.
|
|
900
|
-
|
|
901
|
-
|
|
1052
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1053
|
+
F: __dxlog_file7,
|
|
1054
|
+
L: 355,
|
|
1055
|
+
S: this,
|
|
1056
|
+
A: [
|
|
1057
|
+
"!this._isBeingConsumed",
|
|
1058
|
+
"'Pipeline is already being consumed.'"
|
|
1059
|
+
]
|
|
1060
|
+
});
|
|
1061
|
+
this._isBeingConsumed = true;
|
|
1062
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1063
|
+
F: __dxlog_file7,
|
|
1064
|
+
L: 358,
|
|
1065
|
+
S: this,
|
|
1066
|
+
A: [
|
|
1067
|
+
"this._feedSetIterator",
|
|
1068
|
+
"'Iterator not initialized.'"
|
|
1069
|
+
]
|
|
1070
|
+
});
|
|
902
1071
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
903
1072
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
904
1073
|
while (!this._isStopping) {
|
|
905
1074
|
await this._pauseTrigger.wait();
|
|
906
1075
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
907
|
-
invariant6(this._feedSetIterator, "Iterator not initialized."
|
|
1076
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1077
|
+
F: __dxlog_file7,
|
|
1078
|
+
L: 367,
|
|
1079
|
+
S: this,
|
|
1080
|
+
A: [
|
|
1081
|
+
"this._feedSetIterator",
|
|
1082
|
+
"'Iterator not initialized.'"
|
|
1083
|
+
]
|
|
1084
|
+
});
|
|
908
1085
|
lastFeedSetIterator = this._feedSetIterator;
|
|
909
1086
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
910
1087
|
}
|
|
911
1088
|
const { done, value } = await iterable.next();
|
|
912
1089
|
if (!done) {
|
|
913
|
-
const block = value
|
|
1090
|
+
const block = value ?? failUndefined();
|
|
914
1091
|
this._processingTrigger.reset();
|
|
915
1092
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
916
1093
|
yield block;
|
|
@@ -918,33 +1095,42 @@ var Pipeline = class {
|
|
|
918
1095
|
this._timeframeClock.updateTimeframe();
|
|
919
1096
|
}
|
|
920
1097
|
}
|
|
921
|
-
this.
|
|
1098
|
+
this._isBeingConsumed = false;
|
|
922
1099
|
}
|
|
923
1100
|
_setFeedDownloadState(feed) {
|
|
924
|
-
|
|
1101
|
+
let handle = this._downloads.get(feed);
|
|
1102
|
+
if (handle) {
|
|
1103
|
+
feed.undownload(handle);
|
|
1104
|
+
}
|
|
925
1105
|
const timeframe = this._state._startTimeframe;
|
|
926
|
-
const seq =
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
1106
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1107
|
+
log6("download", {
|
|
1108
|
+
feed: feed.key.truncate(),
|
|
1109
|
+
seq,
|
|
1110
|
+
length: feed.length
|
|
1111
|
+
}, {
|
|
1112
|
+
F: __dxlog_file7,
|
|
1113
|
+
L: 396,
|
|
1114
|
+
S: this,
|
|
1115
|
+
C: (f, a) => f(...a)
|
|
934
1116
|
});
|
|
935
|
-
feed.download({
|
|
1117
|
+
handle = feed.download({
|
|
936
1118
|
start: seq + 1,
|
|
937
1119
|
linear: true
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
1120
|
+
}, (err, data) => {
|
|
1121
|
+
if (err) {
|
|
1122
|
+
} else {
|
|
1123
|
+
log6.info("downloaded", {
|
|
1124
|
+
data
|
|
1125
|
+
}, {
|
|
1126
|
+
F: __dxlog_file7,
|
|
1127
|
+
L: 401,
|
|
1128
|
+
S: this,
|
|
1129
|
+
C: (f, a) => f(...a)
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
947
1132
|
});
|
|
1133
|
+
this._downloads.set(feed, handle);
|
|
948
1134
|
}
|
|
949
1135
|
async _initIterator() {
|
|
950
1136
|
this._feedSetIterator = new FeedSetIterator(createMessageSelector(this._timeframeClock), {
|
|
@@ -953,8 +1139,8 @@ var Pipeline = class {
|
|
|
953
1139
|
});
|
|
954
1140
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
955
1141
|
log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
956
|
-
F:
|
|
957
|
-
L:
|
|
1142
|
+
F: __dxlog_file7,
|
|
1143
|
+
L: 415,
|
|
958
1144
|
S: this,
|
|
959
1145
|
C: (f, a) => f(...a)
|
|
960
1146
|
});
|
|
@@ -982,14 +1168,14 @@ _ts_decorate4([
|
|
|
982
1168
|
], Pipeline.prototype, "unpause", null);
|
|
983
1169
|
|
|
984
1170
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
985
|
-
import invariant7 from "tiny-invariant";
|
|
986
1171
|
import { runInContext, scheduleTask } from "@dxos/async";
|
|
987
1172
|
import { Context as Context3 } from "@dxos/context";
|
|
988
1173
|
import { randomBytes } from "@dxos/crypto";
|
|
1174
|
+
import { invariant as invariant7 } from "@dxos/invariant";
|
|
989
1175
|
import { log as log7 } from "@dxos/log";
|
|
990
1176
|
import { schema as schema5 } from "@dxos/protocols";
|
|
991
1177
|
import { RpcExtension } from "@dxos/teleport";
|
|
992
|
-
var
|
|
1178
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
993
1179
|
var AuthExtension = class extends RpcExtension {
|
|
994
1180
|
constructor(_authParams) {
|
|
995
1181
|
super({
|
|
@@ -1005,8 +1191,8 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1005
1191
|
this._ctx = new Context3({
|
|
1006
1192
|
onError: (err) => {
|
|
1007
1193
|
log7.catch(err, void 0, {
|
|
1008
|
-
F:
|
|
1009
|
-
L:
|
|
1194
|
+
F: __dxlog_file8,
|
|
1195
|
+
L: 28,
|
|
1010
1196
|
S: this,
|
|
1011
1197
|
C: (f, a) => f(...a)
|
|
1012
1198
|
});
|
|
@@ -1027,8 +1213,8 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1027
1213
|
};
|
|
1028
1214
|
} catch (err) {
|
|
1029
1215
|
log7.error("failed to generate auth credentials", err, {
|
|
1030
|
-
F:
|
|
1031
|
-
L:
|
|
1216
|
+
F: __dxlog_file8,
|
|
1217
|
+
L: 55,
|
|
1032
1218
|
S: this,
|
|
1033
1219
|
C: (f, a) => f(...a)
|
|
1034
1220
|
});
|
|
@@ -1046,14 +1232,30 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1046
1232
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1047
1233
|
challenge
|
|
1048
1234
|
});
|
|
1049
|
-
invariant7(
|
|
1235
|
+
invariant7(credential?.length > 0, "invalid credential", {
|
|
1236
|
+
F: __dxlog_file8,
|
|
1237
|
+
L: 69,
|
|
1238
|
+
S: this,
|
|
1239
|
+
A: [
|
|
1240
|
+
"credential?.length > 0",
|
|
1241
|
+
"'invalid credential'"
|
|
1242
|
+
]
|
|
1243
|
+
});
|
|
1050
1244
|
const success = await this._authParams.verifier(challenge, credential);
|
|
1051
|
-
invariant7(success, "credential not verified"
|
|
1245
|
+
invariant7(success, "credential not verified", {
|
|
1246
|
+
F: __dxlog_file8,
|
|
1247
|
+
L: 71,
|
|
1248
|
+
S: this,
|
|
1249
|
+
A: [
|
|
1250
|
+
"success",
|
|
1251
|
+
"'credential not verified'"
|
|
1252
|
+
]
|
|
1253
|
+
});
|
|
1052
1254
|
runInContext(this._ctx, () => this._authParams.onAuthSuccess());
|
|
1053
1255
|
} catch (err) {
|
|
1054
1256
|
log7("auth failed", err, {
|
|
1055
|
-
F:
|
|
1056
|
-
L:
|
|
1257
|
+
F: __dxlog_file8,
|
|
1258
|
+
L: 74,
|
|
1057
1259
|
S: this,
|
|
1058
1260
|
C: (f, a) => f(...a)
|
|
1059
1261
|
});
|
|
@@ -1069,14 +1271,15 @@ var AuthExtension = class extends RpcExtension {
|
|
|
1069
1271
|
};
|
|
1070
1272
|
|
|
1071
1273
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1072
|
-
import invariant8 from "tiny-invariant";
|
|
1073
1274
|
import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
|
|
1074
1275
|
import { Context as Context4 } from "@dxos/context";
|
|
1075
1276
|
import { checkCredentialType } from "@dxos/credentials";
|
|
1076
|
-
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1277
|
+
import { getStateMachineFromItem, ItemManager, TYPE_PROPERTIES } from "@dxos/echo-db";
|
|
1077
1278
|
import { CancelledError } from "@dxos/errors";
|
|
1078
|
-
import {
|
|
1279
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1280
|
+
import { log as log8, omit } from "@dxos/log";
|
|
1079
1281
|
import { Timeframe as Timeframe3 } from "@dxos/timeframe";
|
|
1282
|
+
import { TimeSeriesCounter, TimeUsageCounter, trace } from "@dxos/tracing";
|
|
1080
1283
|
import { tracer } from "@dxos/util";
|
|
1081
1284
|
function _ts_decorate5(decorators, target, key, desc) {
|
|
1082
1285
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -1088,7 +1291,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1088
1291
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1089
1292
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1090
1293
|
}
|
|
1091
|
-
var
|
|
1294
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1092
1295
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1093
1296
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1094
1297
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
@@ -1103,6 +1306,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1103
1306
|
this._lastTimeframeSaveTime = 0;
|
|
1104
1307
|
this._lastSnapshotSaveTime = 0;
|
|
1105
1308
|
this._lastProcessedEpoch = -1;
|
|
1309
|
+
this._usage = new TimeUsageCounter();
|
|
1310
|
+
this._mutations = new TimeSeriesCounter();
|
|
1106
1311
|
this.currentEpoch = void 0;
|
|
1107
1312
|
this.appliedEpoch = void 0;
|
|
1108
1313
|
this.onNewEpoch = new Event4();
|
|
@@ -1114,13 +1319,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1114
1319
|
return this._pipeline;
|
|
1115
1320
|
}
|
|
1116
1321
|
get pipelineState() {
|
|
1117
|
-
|
|
1118
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1322
|
+
return this._pipeline?.state;
|
|
1119
1323
|
}
|
|
1120
1324
|
setTargetTimeframe(timeframe) {
|
|
1121
|
-
var _a;
|
|
1122
1325
|
this._targetTimeframe = timeframe;
|
|
1123
|
-
|
|
1326
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1124
1327
|
}
|
|
1125
1328
|
async processCredential(credential) {
|
|
1126
1329
|
if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1137,15 +1340,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1137
1340
|
}
|
|
1138
1341
|
this._pipeline = new Pipeline();
|
|
1139
1342
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1140
|
-
await this._pipeline.start();
|
|
1141
1343
|
await this._pipeline.pause();
|
|
1344
|
+
await this._pipeline.start();
|
|
1142
1345
|
if (this._targetTimeframe) {
|
|
1143
1346
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1144
1347
|
}
|
|
1145
1348
|
const feedWriter = {
|
|
1146
1349
|
write: (data, options) => {
|
|
1147
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1148
|
-
|
|
1350
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1351
|
+
F: __dxlog_file9,
|
|
1352
|
+
L: 154,
|
|
1353
|
+
S: this,
|
|
1354
|
+
A: [
|
|
1355
|
+
"this._pipeline",
|
|
1356
|
+
"'Pipeline is not initialized.'"
|
|
1357
|
+
]
|
|
1358
|
+
});
|
|
1359
|
+
invariant8(this.currentEpoch, "Epoch is not initialized.", {
|
|
1360
|
+
F: __dxlog_file9,
|
|
1361
|
+
L: 155,
|
|
1362
|
+
S: this,
|
|
1363
|
+
A: [
|
|
1364
|
+
"this.currentEpoch",
|
|
1365
|
+
"'Epoch is not initialized.'"
|
|
1366
|
+
]
|
|
1367
|
+
});
|
|
1149
1368
|
return this._pipeline.writer.write({
|
|
1150
1369
|
data
|
|
1151
1370
|
}, options);
|
|
@@ -1160,19 +1379,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1160
1379
|
this._isOpen = true;
|
|
1161
1380
|
}
|
|
1162
1381
|
async close() {
|
|
1163
|
-
var _a, _b, _c;
|
|
1164
1382
|
if (!this._isOpen) {
|
|
1165
1383
|
return;
|
|
1166
1384
|
}
|
|
1167
1385
|
log8("close", void 0, {
|
|
1168
|
-
F:
|
|
1169
|
-
L:
|
|
1386
|
+
F: __dxlog_file9,
|
|
1387
|
+
L: 179,
|
|
1170
1388
|
S: this,
|
|
1171
1389
|
C: (f, a) => f(...a)
|
|
1172
1390
|
});
|
|
1173
1391
|
this._isOpen = false;
|
|
1174
1392
|
await this._ctx.dispose();
|
|
1175
|
-
await
|
|
1393
|
+
await this._pipeline?.stop();
|
|
1176
1394
|
try {
|
|
1177
1395
|
await this._saveCache();
|
|
1178
1396
|
if (this._pipeline) {
|
|
@@ -1180,14 +1398,14 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1180
1398
|
}
|
|
1181
1399
|
} catch (err) {
|
|
1182
1400
|
log8.catch(err, void 0, {
|
|
1183
|
-
F:
|
|
1184
|
-
L:
|
|
1401
|
+
F: __dxlog_file9,
|
|
1402
|
+
L: 192,
|
|
1185
1403
|
S: this,
|
|
1186
1404
|
C: (f, a) => f(...a)
|
|
1187
1405
|
});
|
|
1188
1406
|
}
|
|
1189
|
-
await
|
|
1190
|
-
await
|
|
1407
|
+
await this.databaseHost?.close();
|
|
1408
|
+
await this.itemManager?.destroy();
|
|
1191
1409
|
this._ctx = new Context4();
|
|
1192
1410
|
this._pipeline = void 0;
|
|
1193
1411
|
this._targetTimeframe = void 0;
|
|
@@ -1203,15 +1421,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1203
1421
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1204
1422
|
await waitForOneEpoch;
|
|
1205
1423
|
}
|
|
1206
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1424
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1425
|
+
F: __dxlog_file9,
|
|
1426
|
+
L: 215,
|
|
1427
|
+
S: this,
|
|
1428
|
+
A: [
|
|
1429
|
+
"this._pipeline",
|
|
1430
|
+
"'Pipeline is not initialized.'"
|
|
1431
|
+
]
|
|
1432
|
+
});
|
|
1207
1433
|
for await (const msg of this._pipeline.consume()) {
|
|
1434
|
+
const span = this._usage.beginRecording();
|
|
1435
|
+
this._mutations.inc();
|
|
1208
1436
|
const { feedKey, seq, data } = msg;
|
|
1209
1437
|
log8("processing message", {
|
|
1210
1438
|
feedKey,
|
|
1211
1439
|
seq
|
|
1212
1440
|
}, {
|
|
1213
|
-
F:
|
|
1214
|
-
L:
|
|
1441
|
+
F: __dxlog_file9,
|
|
1442
|
+
L: 221,
|
|
1215
1443
|
S: this,
|
|
1216
1444
|
C: (f, a) => f(...a)
|
|
1217
1445
|
});
|
|
@@ -1222,8 +1450,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1222
1450
|
log8.warn("Could not find feed", {
|
|
1223
1451
|
feedKey
|
|
1224
1452
|
}, {
|
|
1225
|
-
F:
|
|
1226
|
-
L:
|
|
1453
|
+
F: __dxlog_file9,
|
|
1454
|
+
L: 227,
|
|
1227
1455
|
S: this,
|
|
1228
1456
|
C: (f, a) => f(...a)
|
|
1229
1457
|
});
|
|
@@ -1245,8 +1473,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1245
1473
|
seq,
|
|
1246
1474
|
spaceKey: this._params.spaceKey.toHex()
|
|
1247
1475
|
}, {
|
|
1248
|
-
F:
|
|
1249
|
-
L:
|
|
1476
|
+
F: __dxlog_file9,
|
|
1477
|
+
L: 244,
|
|
1250
1478
|
S: this,
|
|
1251
1479
|
C: (f, a) => f(...a)
|
|
1252
1480
|
});
|
|
@@ -1254,16 +1482,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1254
1482
|
}
|
|
1255
1483
|
} catch (err) {
|
|
1256
1484
|
log8.catch(err, void 0, {
|
|
1257
|
-
F:
|
|
1258
|
-
L:
|
|
1485
|
+
F: __dxlog_file9,
|
|
1486
|
+
L: 254,
|
|
1259
1487
|
S: this,
|
|
1260
1488
|
C: (f, a) => f(...a)
|
|
1261
1489
|
});
|
|
1262
1490
|
}
|
|
1491
|
+
span.end();
|
|
1263
1492
|
}
|
|
1264
1493
|
}
|
|
1265
1494
|
_createSnapshot() {
|
|
1266
|
-
invariant8(this.databaseHost, "Database backend is not initialized."
|
|
1495
|
+
invariant8(this.databaseHost, "Database backend is not initialized.", {
|
|
1496
|
+
F: __dxlog_file9,
|
|
1497
|
+
L: 262,
|
|
1498
|
+
S: this,
|
|
1499
|
+
A: [
|
|
1500
|
+
"this.databaseHost",
|
|
1501
|
+
"'Database backend is not initialized.'"
|
|
1502
|
+
]
|
|
1503
|
+
});
|
|
1267
1504
|
return {
|
|
1268
1505
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1269
1506
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1271,26 +1508,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1271
1508
|
};
|
|
1272
1509
|
}
|
|
1273
1510
|
async _saveTargetTimeframe(timeframe) {
|
|
1274
|
-
|
|
1275
|
-
const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
|
|
1511
|
+
const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
|
|
1276
1512
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1277
1513
|
this._targetTimeframe = newTimeframe;
|
|
1278
1514
|
}
|
|
1279
1515
|
async _saveCache() {
|
|
1280
|
-
var _a;
|
|
1281
1516
|
const cache = {};
|
|
1282
1517
|
try {
|
|
1283
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1284
|
-
|
|
1285
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1286
|
-
});
|
|
1518
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1519
|
+
(getStateMachineFromItem(item)?.snapshot()).type === TYPE_PROPERTIES);
|
|
1287
1520
|
if (propertiesItem) {
|
|
1288
|
-
cache.properties =
|
|
1521
|
+
cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
|
|
1289
1522
|
}
|
|
1290
1523
|
} catch (err) {
|
|
1291
1524
|
log8.warn("Failed to cache properties", err, {
|
|
1292
|
-
F:
|
|
1293
|
-
L:
|
|
1525
|
+
F: __dxlog_file9,
|
|
1526
|
+
L: 291,
|
|
1294
1527
|
S: this,
|
|
1295
1528
|
C: (f, a) => f(...a)
|
|
1296
1529
|
});
|
|
@@ -1307,24 +1540,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1307
1540
|
}
|
|
1308
1541
|
}
|
|
1309
1542
|
async _processEpochInSeparateTask(epoch) {
|
|
1310
|
-
var _a;
|
|
1311
1543
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1312
1544
|
return;
|
|
1313
1545
|
}
|
|
1314
|
-
await
|
|
1546
|
+
await this._epochCtx?.dispose();
|
|
1315
1547
|
const ctx = new Context4({
|
|
1316
1548
|
onError: (err) => {
|
|
1317
1549
|
if (err instanceof CancelledError) {
|
|
1318
1550
|
log8("Epoch processing cancelled.", void 0, {
|
|
1319
|
-
F:
|
|
1320
|
-
L:
|
|
1551
|
+
F: __dxlog_file9,
|
|
1552
|
+
L: 323,
|
|
1321
1553
|
S: this,
|
|
1322
1554
|
C: (f, a) => f(...a)
|
|
1323
1555
|
});
|
|
1324
1556
|
} else {
|
|
1325
1557
|
log8.catch(err, void 0, {
|
|
1326
|
-
F:
|
|
1327
|
-
L:
|
|
1558
|
+
F: __dxlog_file9,
|
|
1559
|
+
L: 325,
|
|
1328
1560
|
S: this,
|
|
1329
1561
|
C: (f, a) => f(...a)
|
|
1330
1562
|
});
|
|
@@ -1336,28 +1568,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1336
1568
|
if (!this._isOpen) {
|
|
1337
1569
|
return;
|
|
1338
1570
|
}
|
|
1339
|
-
log8("process epoch", {
|
|
1340
|
-
epoch
|
|
1341
|
-
}, {
|
|
1342
|
-
F: __dxlog_file8,
|
|
1343
|
-
L: 322,
|
|
1344
|
-
S: this,
|
|
1345
|
-
C: (f, a) => f(...a)
|
|
1346
|
-
});
|
|
1347
1571
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1348
1572
|
this.appliedEpoch = epoch;
|
|
1349
1573
|
this.onNewEpoch.emit(epoch);
|
|
1350
1574
|
});
|
|
1351
1575
|
}
|
|
1352
1576
|
async _processEpoch(ctx, epoch) {
|
|
1353
|
-
invariant8(this._isOpen, "Space is closed."
|
|
1354
|
-
|
|
1577
|
+
invariant8(this._isOpen, "Space is closed.", {
|
|
1578
|
+
F: __dxlog_file9,
|
|
1579
|
+
L: 344,
|
|
1580
|
+
S: this,
|
|
1581
|
+
A: [
|
|
1582
|
+
"this._isOpen",
|
|
1583
|
+
"'Space is closed.'"
|
|
1584
|
+
]
|
|
1585
|
+
});
|
|
1586
|
+
invariant8(this._pipeline, void 0, {
|
|
1587
|
+
F: __dxlog_file9,
|
|
1588
|
+
L: 345,
|
|
1589
|
+
S: this,
|
|
1590
|
+
A: [
|
|
1591
|
+
"this._pipeline",
|
|
1592
|
+
""
|
|
1593
|
+
]
|
|
1594
|
+
});
|
|
1355
1595
|
this._lastProcessedEpoch = epoch.number;
|
|
1356
|
-
log8("
|
|
1357
|
-
epoch
|
|
1596
|
+
log8("processing", {
|
|
1597
|
+
epoch: omit(epoch, "proof")
|
|
1358
1598
|
}, {
|
|
1359
|
-
F:
|
|
1360
|
-
L:
|
|
1599
|
+
F: __dxlog_file9,
|
|
1600
|
+
L: 348,
|
|
1361
1601
|
S: this,
|
|
1362
1602
|
C: (f, a) => f(...a)
|
|
1363
1603
|
});
|
|
@@ -1365,9 +1605,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1365
1605
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1366
1606
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1367
1607
|
}
|
|
1368
|
-
log8("restarting pipeline
|
|
1369
|
-
F:
|
|
1370
|
-
L:
|
|
1608
|
+
log8("restarting pipeline from epoch", void 0, {
|
|
1609
|
+
F: __dxlog_file9,
|
|
1610
|
+
L: 354,
|
|
1371
1611
|
S: this,
|
|
1372
1612
|
C: (f, a) => f(...a)
|
|
1373
1613
|
});
|
|
@@ -1376,12 +1616,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1376
1616
|
await this._pipeline.unpause();
|
|
1377
1617
|
}
|
|
1378
1618
|
async waitUntilTimeframe(timeframe) {
|
|
1379
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1619
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1620
|
+
F: __dxlog_file9,
|
|
1621
|
+
L: 361,
|
|
1622
|
+
S: this,
|
|
1623
|
+
A: [
|
|
1624
|
+
"this._pipeline",
|
|
1625
|
+
"'Pipeline is not initialized.'"
|
|
1626
|
+
]
|
|
1627
|
+
});
|
|
1380
1628
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1381
1629
|
}
|
|
1382
1630
|
async createEpoch() {
|
|
1383
|
-
invariant8(this._pipeline
|
|
1384
|
-
|
|
1631
|
+
invariant8(this._pipeline, void 0, {
|
|
1632
|
+
F: __dxlog_file9,
|
|
1633
|
+
L: 367,
|
|
1634
|
+
S: this,
|
|
1635
|
+
A: [
|
|
1636
|
+
"this._pipeline",
|
|
1637
|
+
""
|
|
1638
|
+
]
|
|
1639
|
+
});
|
|
1640
|
+
invariant8(this.currentEpoch, void 0, {
|
|
1641
|
+
F: __dxlog_file9,
|
|
1642
|
+
L: 368,
|
|
1643
|
+
S: this,
|
|
1644
|
+
A: [
|
|
1645
|
+
"this.currentEpoch",
|
|
1646
|
+
""
|
|
1647
|
+
]
|
|
1648
|
+
});
|
|
1385
1649
|
await this._pipeline.pause();
|
|
1386
1650
|
const snapshot = await this._createSnapshot();
|
|
1387
1651
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1398,6 +1662,12 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1398
1662
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1399
1663
|
}
|
|
1400
1664
|
};
|
|
1665
|
+
_ts_decorate5([
|
|
1666
|
+
trace.metricsCounter()
|
|
1667
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1668
|
+
_ts_decorate5([
|
|
1669
|
+
trace.metricsCounter()
|
|
1670
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1401
1671
|
_ts_decorate5([
|
|
1402
1672
|
synchronized3
|
|
1403
1673
|
], DataPipeline.prototype, "open", null);
|
|
@@ -1411,29 +1681,45 @@ _ts_decorate5([
|
|
|
1411
1681
|
synchronized3
|
|
1412
1682
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1413
1683
|
DataPipeline = _ts_decorate5([
|
|
1414
|
-
trackLeaks2("open", "close")
|
|
1684
|
+
trackLeaks2("open", "close"),
|
|
1685
|
+
trace.resource()
|
|
1415
1686
|
], DataPipeline);
|
|
1416
1687
|
|
|
1417
1688
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1418
|
-
import invariant9 from "tiny-invariant";
|
|
1419
1689
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1690
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1420
1691
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1421
1692
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1693
|
+
import { trace as trace3 } from "@dxos/tracing";
|
|
1422
1694
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1423
1695
|
|
|
1424
1696
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1697
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1425
1698
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1426
1699
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1427
1700
|
import { log as log9 } from "@dxos/log";
|
|
1428
1701
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1429
1702
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1703
|
+
import { TimeSeriesCounter as TimeSeriesCounter2, TimeUsageCounter as TimeUsageCounter2, trace as trace2 } from "@dxos/tracing";
|
|
1430
1704
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1431
|
-
|
|
1705
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1706
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1707
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1708
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1709
|
+
else
|
|
1710
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1711
|
+
if (d = decorators[i])
|
|
1712
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1713
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1714
|
+
}
|
|
1715
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1432
1716
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1433
|
-
var ControlPipeline = class {
|
|
1717
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1434
1718
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1435
1719
|
this._lastTimeframeSaveTime = Date.now();
|
|
1436
1720
|
this.onFeedAdmitted = new Callback();
|
|
1721
|
+
this._usage = new TimeUsageCounter2();
|
|
1722
|
+
this._mutations = new TimeSeriesCounter2();
|
|
1437
1723
|
this._spaceKey = spaceKey;
|
|
1438
1724
|
this._metadata = metadataStore;
|
|
1439
1725
|
this._pipeline = new Pipeline();
|
|
@@ -1443,8 +1729,8 @@ var ControlPipeline = class {
|
|
|
1443
1729
|
log9("feed admitted", {
|
|
1444
1730
|
key: info.key
|
|
1445
1731
|
}, {
|
|
1446
|
-
F:
|
|
1447
|
-
L:
|
|
1732
|
+
F: __dxlog_file10,
|
|
1733
|
+
L: 61,
|
|
1448
1734
|
S: this,
|
|
1449
1735
|
C: (f, a) => f(...a)
|
|
1450
1736
|
});
|
|
@@ -1454,8 +1740,8 @@ var ControlPipeline = class {
|
|
|
1454
1740
|
await this._pipeline.addFeed(feed);
|
|
1455
1741
|
} catch (err) {
|
|
1456
1742
|
log9.catch(err, void 0, {
|
|
1457
|
-
F:
|
|
1458
|
-
L:
|
|
1743
|
+
F: __dxlog_file10,
|
|
1744
|
+
L: 69,
|
|
1459
1745
|
S: this,
|
|
1460
1746
|
C: (f, a) => f(...a)
|
|
1461
1747
|
});
|
|
@@ -1477,58 +1763,67 @@ var ControlPipeline = class {
|
|
|
1477
1763
|
}
|
|
1478
1764
|
async start() {
|
|
1479
1765
|
log9("starting...", void 0, {
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1766
|
+
F: __dxlog_file10,
|
|
1767
|
+
L: 93,
|
|
1482
1768
|
S: this,
|
|
1483
1769
|
C: (f, a) => f(...a)
|
|
1484
1770
|
});
|
|
1485
1771
|
setTimeout(async () => {
|
|
1486
|
-
|
|
1487
|
-
try {
|
|
1488
|
-
log9("processing", {
|
|
1489
|
-
key: msg.feedKey,
|
|
1490
|
-
seq: msg.seq
|
|
1491
|
-
}, {
|
|
1492
|
-
F: __dxlog_file9,
|
|
1493
|
-
L: 88,
|
|
1494
|
-
S: this,
|
|
1495
|
-
C: (f, a) => f(...a)
|
|
1496
|
-
});
|
|
1497
|
-
if (msg.data.payload.credential) {
|
|
1498
|
-
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1499
|
-
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1500
|
-
timer.end();
|
|
1501
|
-
if (!result) {
|
|
1502
|
-
log9.warn("processing failed", {
|
|
1503
|
-
msg
|
|
1504
|
-
}, {
|
|
1505
|
-
F: __dxlog_file9,
|
|
1506
|
-
L: 98,
|
|
1507
|
-
S: this,
|
|
1508
|
-
C: (f, a) => f(...a)
|
|
1509
|
-
});
|
|
1510
|
-
} else {
|
|
1511
|
-
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1512
|
-
}
|
|
1513
|
-
}
|
|
1514
|
-
} catch (err) {
|
|
1515
|
-
log9.catch(err, void 0, {
|
|
1516
|
-
F: __dxlog_file9,
|
|
1517
|
-
L: 104,
|
|
1518
|
-
S: this,
|
|
1519
|
-
C: (f, a) => f(...a)
|
|
1520
|
-
});
|
|
1521
|
-
}
|
|
1522
|
-
}
|
|
1772
|
+
void this._consumePipeline(new Context5());
|
|
1523
1773
|
});
|
|
1524
1774
|
await this._pipeline.start();
|
|
1525
1775
|
log9("started", void 0, {
|
|
1526
|
-
F:
|
|
1527
|
-
L:
|
|
1776
|
+
F: __dxlog_file10,
|
|
1777
|
+
L: 99,
|
|
1528
1778
|
S: this,
|
|
1529
1779
|
C: (f, a) => f(...a)
|
|
1530
1780
|
});
|
|
1531
1781
|
}
|
|
1782
|
+
async _consumePipeline(ctx) {
|
|
1783
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1784
|
+
const span = this._usage.beginRecording();
|
|
1785
|
+
this._mutations.inc();
|
|
1786
|
+
try {
|
|
1787
|
+
await this._processMessage(ctx, msg);
|
|
1788
|
+
} catch (err) {
|
|
1789
|
+
log9.catch(err, void 0, {
|
|
1790
|
+
F: __dxlog_file10,
|
|
1791
|
+
L: 111,
|
|
1792
|
+
S: this,
|
|
1793
|
+
C: (f, a) => f(...a)
|
|
1794
|
+
});
|
|
1795
|
+
}
|
|
1796
|
+
span.end();
|
|
1797
|
+
}
|
|
1798
|
+
}
|
|
1799
|
+
async _processMessage(ctx, msg) {
|
|
1800
|
+
log9("processing", {
|
|
1801
|
+
key: msg.feedKey,
|
|
1802
|
+
seq: msg.seq
|
|
1803
|
+
}, {
|
|
1804
|
+
F: __dxlog_file10,
|
|
1805
|
+
L: 121,
|
|
1806
|
+
S: this,
|
|
1807
|
+
C: (f, a) => f(...a)
|
|
1808
|
+
});
|
|
1809
|
+
if (msg.data.payload.credential) {
|
|
1810
|
+
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1811
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1812
|
+
timer.end();
|
|
1813
|
+
if (!result) {
|
|
1814
|
+
log9.warn("processing failed", {
|
|
1815
|
+
msg
|
|
1816
|
+
}, {
|
|
1817
|
+
F: __dxlog_file10,
|
|
1818
|
+
L: 131,
|
|
1819
|
+
S: this,
|
|
1820
|
+
C: (f, a) => f(...a)
|
|
1821
|
+
});
|
|
1822
|
+
} else {
|
|
1823
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1824
|
+
}
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1532
1827
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1533
1828
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
|
|
1534
1829
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -1537,39 +1832,53 @@ var ControlPipeline = class {
|
|
|
1537
1832
|
}
|
|
1538
1833
|
async stop() {
|
|
1539
1834
|
log9("stopping...", void 0, {
|
|
1540
|
-
F:
|
|
1541
|
-
L:
|
|
1835
|
+
F: __dxlog_file10,
|
|
1836
|
+
L: 149,
|
|
1542
1837
|
S: this,
|
|
1543
1838
|
C: (f, a) => f(...a)
|
|
1544
1839
|
});
|
|
1545
1840
|
await this._pipeline.stop();
|
|
1546
1841
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1547
1842
|
log9("stopped", void 0, {
|
|
1548
|
-
F:
|
|
1549
|
-
L:
|
|
1843
|
+
F: __dxlog_file10,
|
|
1844
|
+
L: 152,
|
|
1550
1845
|
S: this,
|
|
1551
1846
|
C: (f, a) => f(...a)
|
|
1552
1847
|
});
|
|
1553
1848
|
}
|
|
1554
1849
|
async _saveTargetTimeframe(timeframe) {
|
|
1555
|
-
var _a;
|
|
1556
1850
|
try {
|
|
1557
|
-
const newTimeframe = Timeframe4.merge(
|
|
1851
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1558
1852
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1559
1853
|
this._targetTimeframe = newTimeframe;
|
|
1560
1854
|
} catch (err) {
|
|
1561
1855
|
log9(err, void 0, {
|
|
1562
|
-
F:
|
|
1563
|
-
L:
|
|
1856
|
+
F: __dxlog_file10,
|
|
1857
|
+
L: 161,
|
|
1564
1858
|
S: this,
|
|
1565
1859
|
C: (f, a) => f(...a)
|
|
1566
1860
|
});
|
|
1567
1861
|
}
|
|
1568
1862
|
}
|
|
1569
1863
|
};
|
|
1864
|
+
_ts_decorate6([
|
|
1865
|
+
trace2.metricsCounter()
|
|
1866
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1867
|
+
_ts_decorate6([
|
|
1868
|
+
trace2.metricsCounter()
|
|
1869
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1870
|
+
_ts_decorate6([
|
|
1871
|
+
trace2.span()
|
|
1872
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1873
|
+
_ts_decorate6([
|
|
1874
|
+
trace2.span()
|
|
1875
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1876
|
+
ControlPipeline = _ts_decorate6([
|
|
1877
|
+
trace2.resource()
|
|
1878
|
+
], ControlPipeline);
|
|
1570
1879
|
|
|
1571
1880
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1572
|
-
function
|
|
1881
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1573
1882
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1574
1883
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1575
1884
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1579,14 +1888,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1579
1888
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1580
1889
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1581
1890
|
}
|
|
1582
|
-
var
|
|
1891
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1583
1892
|
var Space = class Space2 {
|
|
1584
1893
|
constructor(params) {
|
|
1585
1894
|
this._addFeedLock = new Lock();
|
|
1586
1895
|
this.onCredentialProcessed = new Callback2();
|
|
1587
1896
|
this.stateUpdate = new Event5();
|
|
1588
1897
|
this._isOpen = false;
|
|
1589
|
-
invariant9(params.spaceKey && params.feedProvider
|
|
1898
|
+
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1899
|
+
F: __dxlog_file11,
|
|
1900
|
+
L: 73,
|
|
1901
|
+
S: this,
|
|
1902
|
+
A: [
|
|
1903
|
+
"params.spaceKey && params.feedProvider",
|
|
1904
|
+
""
|
|
1905
|
+
]
|
|
1906
|
+
});
|
|
1590
1907
|
this._key = params.spaceKey;
|
|
1591
1908
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1592
1909
|
this._feedProvider = params.feedProvider;
|
|
@@ -1621,8 +1938,8 @@ var Space = class Space2 {
|
|
|
1621
1938
|
log10("onCredentialProcessed", {
|
|
1622
1939
|
credential
|
|
1623
1940
|
}, {
|
|
1624
|
-
F:
|
|
1625
|
-
L:
|
|
1941
|
+
F: __dxlog_file11,
|
|
1942
|
+
L: 109,
|
|
1626
1943
|
S: this,
|
|
1627
1944
|
C: (f, a) => f(...a)
|
|
1628
1945
|
});
|
|
@@ -1664,12 +1981,10 @@ var Space = class Space2 {
|
|
|
1664
1981
|
return this._genesisFeedKey;
|
|
1665
1982
|
}
|
|
1666
1983
|
get controlFeedKey() {
|
|
1667
|
-
|
|
1668
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1984
|
+
return this._controlFeed?.key;
|
|
1669
1985
|
}
|
|
1670
1986
|
get dataFeedKey() {
|
|
1671
|
-
|
|
1672
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1987
|
+
return this._dataFeed?.key;
|
|
1673
1988
|
}
|
|
1674
1989
|
get spaceState() {
|
|
1675
1990
|
return this._controlPipeline.spaceState;
|
|
@@ -1687,16 +2002,31 @@ var Space = class Space2 {
|
|
|
1687
2002
|
return this._snapshotManager;
|
|
1688
2003
|
}
|
|
1689
2004
|
setControlFeed(feed) {
|
|
1690
|
-
invariant9(!this._controlFeed, "Control feed already set."
|
|
2005
|
+
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
2006
|
+
F: __dxlog_file11,
|
|
2007
|
+
L: 184,
|
|
2008
|
+
S: this,
|
|
2009
|
+
A: [
|
|
2010
|
+
"!this._controlFeed",
|
|
2011
|
+
"'Control feed already set.'"
|
|
2012
|
+
]
|
|
2013
|
+
});
|
|
1691
2014
|
this._controlFeed = feed;
|
|
1692
2015
|
this._controlPipeline.setWriteFeed(feed);
|
|
1693
2016
|
return this;
|
|
1694
2017
|
}
|
|
1695
2018
|
setDataFeed(feed) {
|
|
1696
|
-
|
|
1697
|
-
|
|
2019
|
+
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
2020
|
+
F: __dxlog_file11,
|
|
2021
|
+
L: 191,
|
|
2022
|
+
S: this,
|
|
2023
|
+
A: [
|
|
2024
|
+
"!this._dataFeed",
|
|
2025
|
+
"'Data feed already set.'"
|
|
2026
|
+
]
|
|
2027
|
+
});
|
|
1698
2028
|
this._dataFeed = feed;
|
|
1699
|
-
|
|
2029
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1700
2030
|
return this;
|
|
1701
2031
|
}
|
|
1702
2032
|
/**
|
|
@@ -1711,10 +2041,10 @@ var Space = class Space2 {
|
|
|
1711
2041
|
// getDataFeeds(): FeedInfo[] {
|
|
1712
2042
|
// return this._dataPipeline?.getFeeds();
|
|
1713
2043
|
// }
|
|
1714
|
-
async open() {
|
|
2044
|
+
async open(ctx) {
|
|
1715
2045
|
log10("opening...", void 0, {
|
|
1716
|
-
F:
|
|
1717
|
-
L:
|
|
2046
|
+
F: __dxlog_file11,
|
|
2047
|
+
L: 213,
|
|
1718
2048
|
S: this,
|
|
1719
2049
|
C: (f, a) => f(...a)
|
|
1720
2050
|
});
|
|
@@ -1726,8 +2056,8 @@ var Space = class Space2 {
|
|
|
1726
2056
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1727
2057
|
this._isOpen = true;
|
|
1728
2058
|
log10("opened", void 0, {
|
|
1729
|
-
F:
|
|
1730
|
-
L:
|
|
2059
|
+
F: __dxlog_file11,
|
|
2060
|
+
L: 224,
|
|
1731
2061
|
S: this,
|
|
1732
2062
|
C: (f, a) => f(...a)
|
|
1733
2063
|
});
|
|
@@ -1736,8 +2066,8 @@ var Space = class Space2 {
|
|
|
1736
2066
|
log10("closing...", {
|
|
1737
2067
|
key: this._key
|
|
1738
2068
|
}, {
|
|
1739
|
-
F:
|
|
1740
|
-
L:
|
|
2069
|
+
F: __dxlog_file11,
|
|
2070
|
+
L: 229,
|
|
1741
2071
|
S: this,
|
|
1742
2072
|
C: (f, a) => f(...a)
|
|
1743
2073
|
});
|
|
@@ -1750,37 +2080,48 @@ var Space = class Space2 {
|
|
|
1750
2080
|
await this._controlPipeline.stop();
|
|
1751
2081
|
this._isOpen = false;
|
|
1752
2082
|
log10("closed", void 0, {
|
|
1753
|
-
F:
|
|
1754
|
-
L:
|
|
2083
|
+
F: __dxlog_file11,
|
|
2084
|
+
L: 242,
|
|
1755
2085
|
S: this,
|
|
1756
2086
|
C: (f, a) => f(...a)
|
|
1757
2087
|
});
|
|
1758
2088
|
}
|
|
1759
2089
|
async initializeDataPipeline() {
|
|
1760
2090
|
log10("initializeDataPipeline", void 0, {
|
|
1761
|
-
F:
|
|
1762
|
-
L:
|
|
2091
|
+
F: __dxlog_file11,
|
|
2092
|
+
L: 247,
|
|
1763
2093
|
S: this,
|
|
1764
2094
|
C: (f, a) => f(...a)
|
|
1765
2095
|
});
|
|
1766
|
-
invariant9(this._isOpen, "Space must be open to initialize data pipeline."
|
|
2096
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2097
|
+
F: __dxlog_file11,
|
|
2098
|
+
L: 248,
|
|
2099
|
+
S: this,
|
|
2100
|
+
A: [
|
|
2101
|
+
"this._isOpen",
|
|
2102
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2103
|
+
]
|
|
2104
|
+
});
|
|
1767
2105
|
await this._dataPipeline.open();
|
|
1768
2106
|
}
|
|
1769
2107
|
};
|
|
1770
|
-
|
|
1771
|
-
logInfo
|
|
2108
|
+
_ts_decorate7([
|
|
2109
|
+
logInfo,
|
|
2110
|
+
trace3.info()
|
|
1772
2111
|
], Space.prototype, "key", null);
|
|
1773
|
-
|
|
1774
|
-
synchronized4
|
|
2112
|
+
_ts_decorate7([
|
|
2113
|
+
synchronized4,
|
|
2114
|
+
trace3.span()
|
|
1775
2115
|
], Space.prototype, "open", null);
|
|
1776
|
-
|
|
2116
|
+
_ts_decorate7([
|
|
1777
2117
|
synchronized4
|
|
1778
2118
|
], Space.prototype, "close", null);
|
|
1779
|
-
|
|
2119
|
+
_ts_decorate7([
|
|
1780
2120
|
synchronized4
|
|
1781
2121
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1782
|
-
Space =
|
|
1783
|
-
trackLeaks3("open", "close")
|
|
2122
|
+
Space = _ts_decorate7([
|
|
2123
|
+
trackLeaks3("open", "close"),
|
|
2124
|
+
trace3.resource()
|
|
1784
2125
|
], Space);
|
|
1785
2126
|
|
|
1786
2127
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -1792,7 +2133,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
1792
2133
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
1793
2134
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1794
2135
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1795
|
-
function
|
|
2136
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1796
2137
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1797
2138
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1798
2139
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1802,7 +2143,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1802
2143
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1803
2144
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1804
2145
|
}
|
|
1805
|
-
var
|
|
2146
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1806
2147
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1807
2148
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1808
2149
|
var SpaceProtocol = class {
|
|
@@ -1832,8 +2173,8 @@ var SpaceProtocol = class {
|
|
|
1832
2173
|
log11("addFeed", {
|
|
1833
2174
|
key: feed.key
|
|
1834
2175
|
}, {
|
|
1835
|
-
F:
|
|
1836
|
-
L:
|
|
2176
|
+
F: __dxlog_file12,
|
|
2177
|
+
L: 96,
|
|
1837
2178
|
S: this,
|
|
1838
2179
|
C: (f, a) => f(...a)
|
|
1839
2180
|
});
|
|
@@ -1842,6 +2183,7 @@ var SpaceProtocol = class {
|
|
|
1842
2183
|
session.replicator.addFeed(feed);
|
|
1843
2184
|
}
|
|
1844
2185
|
}
|
|
2186
|
+
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
1845
2187
|
async start() {
|
|
1846
2188
|
if (this._connection) {
|
|
1847
2189
|
return;
|
|
@@ -1854,8 +2196,8 @@ var SpaceProtocol = class {
|
|
|
1854
2196
|
};
|
|
1855
2197
|
await this.blobSync.open();
|
|
1856
2198
|
log11("starting...", void 0, {
|
|
1857
|
-
F:
|
|
1858
|
-
L:
|
|
2199
|
+
F: __dxlog_file12,
|
|
2200
|
+
L: 122,
|
|
1859
2201
|
S: this,
|
|
1860
2202
|
C: (f, a) => f(...a)
|
|
1861
2203
|
});
|
|
@@ -1865,11 +2207,11 @@ var SpaceProtocol = class {
|
|
|
1865
2207
|
peerId: this._swarmIdentity.peerKey,
|
|
1866
2208
|
topic,
|
|
1867
2209
|
topology: new MMSTTopology(topologyConfig),
|
|
1868
|
-
label: `
|
|
2210
|
+
label: `space swarm ${topic.truncate()}`
|
|
1869
2211
|
});
|
|
1870
2212
|
log11("started", void 0, {
|
|
1871
|
-
F:
|
|
1872
|
-
L:
|
|
2213
|
+
F: __dxlog_file12,
|
|
2214
|
+
L: 132,
|
|
1873
2215
|
S: this,
|
|
1874
2216
|
C: (f, a) => f(...a)
|
|
1875
2217
|
});
|
|
@@ -1878,15 +2220,15 @@ var SpaceProtocol = class {
|
|
|
1878
2220
|
await this.blobSync.close();
|
|
1879
2221
|
if (this._connection) {
|
|
1880
2222
|
log11("stopping...", void 0, {
|
|
1881
|
-
F:
|
|
1882
|
-
L:
|
|
2223
|
+
F: __dxlog_file12,
|
|
2224
|
+
L: 139,
|
|
1883
2225
|
S: this,
|
|
1884
2226
|
C: (f, a) => f(...a)
|
|
1885
2227
|
});
|
|
1886
2228
|
await this._connection.close();
|
|
1887
2229
|
log11("stopped", void 0, {
|
|
1888
|
-
F:
|
|
1889
|
-
L:
|
|
2230
|
+
F: __dxlog_file12,
|
|
2231
|
+
L: 141,
|
|
1890
2232
|
S: this,
|
|
1891
2233
|
C: (f, a) => f(...a)
|
|
1892
2234
|
});
|
|
@@ -1909,10 +2251,10 @@ var SpaceProtocol = class {
|
|
|
1909
2251
|
};
|
|
1910
2252
|
}
|
|
1911
2253
|
};
|
|
1912
|
-
|
|
2254
|
+
_ts_decorate8([
|
|
1913
2255
|
logInfo2
|
|
1914
2256
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
1915
|
-
|
|
2257
|
+
_ts_decorate8([
|
|
1916
2258
|
logInfo2
|
|
1917
2259
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
1918
2260
|
var AuthStatus;
|
|
@@ -1951,20 +2293,18 @@ var SpaceProtocolSession = class {
|
|
|
1951
2293
|
provider: this._swarmIdentity.credentialProvider,
|
|
1952
2294
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1953
2295
|
onAuthSuccess: () => {
|
|
1954
|
-
var _a;
|
|
1955
2296
|
log11("Peer authenticated", void 0, {
|
|
1956
|
-
F:
|
|
1957
|
-
L:
|
|
2297
|
+
F: __dxlog_file12,
|
|
2298
|
+
L: 238,
|
|
1958
2299
|
S: this,
|
|
1959
2300
|
C: (f, a) => f(...a)
|
|
1960
2301
|
});
|
|
1961
2302
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1962
|
-
|
|
2303
|
+
this._onSessionAuth?.(this._teleport);
|
|
1963
2304
|
},
|
|
1964
2305
|
onAuthFailure: () => {
|
|
1965
|
-
var _a;
|
|
1966
2306
|
this._authStatus = AuthStatus.FAILURE;
|
|
1967
|
-
|
|
2307
|
+
this._onAuthFailure?.(this._teleport);
|
|
1968
2308
|
}
|
|
1969
2309
|
}));
|
|
1970
2310
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -1974,10 +2314,10 @@ var SpaceProtocolSession = class {
|
|
|
1974
2314
|
await this._teleport.close();
|
|
1975
2315
|
}
|
|
1976
2316
|
};
|
|
1977
|
-
|
|
2317
|
+
_ts_decorate8([
|
|
1978
2318
|
logInfo2
|
|
1979
2319
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
1980
|
-
|
|
2320
|
+
_ts_decorate8([
|
|
1981
2321
|
logInfo2
|
|
1982
2322
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
1983
2323
|
|
|
@@ -1986,9 +2326,9 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
1986
2326
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1987
2327
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1988
2328
|
import { log as log12 } from "@dxos/log";
|
|
1989
|
-
import { trace } from "@dxos/protocols";
|
|
2329
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
1990
2330
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1991
|
-
function
|
|
2331
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1992
2332
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1993
2333
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1994
2334
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1998,7 +2338,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1998
2338
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1999
2339
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2000
2340
|
}
|
|
2001
|
-
var
|
|
2341
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2002
2342
|
var SpaceManager = class SpaceManager2 {
|
|
2003
2343
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2004
2344
|
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
@@ -2022,11 +2362,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2022
2362
|
].map((space) => space.close()));
|
|
2023
2363
|
}
|
|
2024
2364
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2025
|
-
|
|
2026
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2365
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2027
2366
|
id: this._instanceId
|
|
2028
2367
|
}), {
|
|
2029
|
-
F:
|
|
2368
|
+
F: __dxlog_file13,
|
|
2030
2369
|
L: 97,
|
|
2031
2370
|
S: this,
|
|
2032
2371
|
C: (f, a) => f(...a)
|
|
@@ -2034,12 +2373,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2034
2373
|
log12("constructing space...", {
|
|
2035
2374
|
spaceKey: metadata.genesisFeedKey
|
|
2036
2375
|
}, {
|
|
2037
|
-
F:
|
|
2376
|
+
F: __dxlog_file13,
|
|
2038
2377
|
L: 98,
|
|
2039
2378
|
S: this,
|
|
2040
2379
|
C: (f, a) => f(...a)
|
|
2041
2380
|
});
|
|
2042
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2381
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2043
2382
|
const spaceKey = metadata.key;
|
|
2044
2383
|
const protocol = new SpaceProtocol({
|
|
2045
2384
|
topic: spaceKey,
|
|
@@ -2061,24 +2400,24 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2061
2400
|
memberKey
|
|
2062
2401
|
});
|
|
2063
2402
|
this._spaces.set(space.key, space);
|
|
2064
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2403
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
2065
2404
|
id: this._instanceId
|
|
2066
2405
|
}), {
|
|
2067
|
-
F:
|
|
2068
|
-
L:
|
|
2406
|
+
F: __dxlog_file13,
|
|
2407
|
+
L: 126,
|
|
2069
2408
|
S: this,
|
|
2070
2409
|
C: (f, a) => f(...a)
|
|
2071
2410
|
});
|
|
2072
2411
|
return space;
|
|
2073
2412
|
}
|
|
2074
2413
|
};
|
|
2075
|
-
|
|
2414
|
+
_ts_decorate9([
|
|
2076
2415
|
synchronized5
|
|
2077
2416
|
], SpaceManager.prototype, "open", null);
|
|
2078
|
-
|
|
2417
|
+
_ts_decorate9([
|
|
2079
2418
|
synchronized5
|
|
2080
2419
|
], SpaceManager.prototype, "close", null);
|
|
2081
|
-
SpaceManager =
|
|
2420
|
+
SpaceManager = _ts_decorate9([
|
|
2082
2421
|
trackLeaks4("open", "close")
|
|
2083
2422
|
], SpaceManager);
|
|
2084
2423
|
|
|
@@ -2108,4 +2447,4 @@ export {
|
|
|
2108
2447
|
SpaceProtocolSession,
|
|
2109
2448
|
SpaceManager
|
|
2110
2449
|
};
|
|
2111
|
-
//# sourceMappingURL=chunk-
|
|
2450
|
+
//# sourceMappingURL=chunk-GELWTWOW.mjs.map
|