@dxos/echo-pipeline 0.1.56-main.83e9b8a → 0.1.56-main.8d1cf70
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-FCDYN74V.mjs} +669 -323
- package/dist/lib/browser/chunk-FCDYN74V.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 +677 -331
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +674 -332
- 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.d.ts +1 -1
- 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.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 +9 -3
- 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.test.ts +37 -1
- package/src/pipeline/pipeline.ts +36 -14
- package/src/space/auth.ts +1 -2
- package/src/space/control-pipeline.ts +47 -22
- package/src/space/data-pipeline.ts +16 -4
- 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
90
|
batch,
|
|
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
|
-
import { ComplexMap as ComplexMap3 } from "@dxos/util";
|
|
728
|
+
import { ComplexMap as ComplexMap3, getPrototypeSpecificInstanceId } 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
|
});
|
|
@@ -784,14 +878,22 @@ var Pipeline = class {
|
|
|
784
878
|
this._pauseTrigger = new Trigger().wake();
|
|
785
879
|
this._isStopping = false;
|
|
786
880
|
this._isStarted = false;
|
|
787
|
-
this.
|
|
881
|
+
this._isBeingConsumed = false;
|
|
788
882
|
this._isPaused = false;
|
|
789
883
|
}
|
|
790
884
|
get state() {
|
|
791
885
|
return this._state;
|
|
792
886
|
}
|
|
793
887
|
get writer() {
|
|
794
|
-
invariant6(this._writer, "Writer not set."
|
|
888
|
+
invariant6(this._writer, "Writer not set.", {
|
|
889
|
+
F: __dxlog_file7,
|
|
890
|
+
L: 230,
|
|
891
|
+
S: this,
|
|
892
|
+
A: [
|
|
893
|
+
"this._writer",
|
|
894
|
+
"'Writer not set.'"
|
|
895
|
+
]
|
|
896
|
+
});
|
|
795
897
|
return this._writer;
|
|
796
898
|
}
|
|
797
899
|
hasFeed(feedKey) {
|
|
@@ -807,20 +909,47 @@ var Pipeline = class {
|
|
|
807
909
|
if (this._feedSetIterator) {
|
|
808
910
|
await this._feedSetIterator.addFeed(feed);
|
|
809
911
|
}
|
|
810
|
-
this.
|
|
912
|
+
if (this._isStarted && !this._isPaused) {
|
|
913
|
+
this._setFeedDownloadState(feed);
|
|
914
|
+
}
|
|
811
915
|
}
|
|
812
916
|
setWriteFeed(feed) {
|
|
813
|
-
invariant6(!this._writer, "Writer already set."
|
|
814
|
-
|
|
917
|
+
invariant6(!this._writer, "Writer already set.", {
|
|
918
|
+
F: __dxlog_file7,
|
|
919
|
+
L: 257,
|
|
920
|
+
S: this,
|
|
921
|
+
A: [
|
|
922
|
+
"!this._writer",
|
|
923
|
+
"'Writer already set.'"
|
|
924
|
+
]
|
|
925
|
+
});
|
|
926
|
+
invariant6(feed.properties.writable, "Feed must be writable.", {
|
|
927
|
+
F: __dxlog_file7,
|
|
928
|
+
L: 258,
|
|
929
|
+
S: this,
|
|
930
|
+
A: [
|
|
931
|
+
"feed.properties.writable",
|
|
932
|
+
"'Feed must be writable.'"
|
|
933
|
+
]
|
|
934
|
+
});
|
|
815
935
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
816
936
|
timeframe: this._timeframeClock.timeframe,
|
|
817
937
|
payload
|
|
818
938
|
}), feed.createFeedWriter());
|
|
819
939
|
}
|
|
820
940
|
async start() {
|
|
941
|
+
invariant6(!this._isStarted, "Pipeline is already started.", {
|
|
942
|
+
F: __dxlog_file7,
|
|
943
|
+
L: 271,
|
|
944
|
+
S: this,
|
|
945
|
+
A: [
|
|
946
|
+
"!this._isStarted",
|
|
947
|
+
"'Pipeline is already started.'"
|
|
948
|
+
]
|
|
949
|
+
});
|
|
821
950
|
log6("starting...", void 0, {
|
|
822
|
-
F:
|
|
823
|
-
L:
|
|
951
|
+
F: __dxlog_file7,
|
|
952
|
+
L: 272,
|
|
824
953
|
S: this,
|
|
825
954
|
C: (f, a) => f(...a)
|
|
826
955
|
});
|
|
@@ -828,30 +957,34 @@ var Pipeline = class {
|
|
|
828
957
|
await this._feedSetIterator.open();
|
|
829
958
|
this._isStarted = true;
|
|
830
959
|
log6("started", void 0, {
|
|
831
|
-
F:
|
|
832
|
-
L:
|
|
960
|
+
F: __dxlog_file7,
|
|
961
|
+
L: 276,
|
|
833
962
|
S: this,
|
|
834
963
|
C: (f, a) => f(...a)
|
|
835
964
|
});
|
|
965
|
+
if (!this._isPaused) {
|
|
966
|
+
for (const feed of this._feeds.values()) {
|
|
967
|
+
this._setFeedDownloadState(feed);
|
|
968
|
+
}
|
|
969
|
+
}
|
|
836
970
|
}
|
|
837
971
|
async stop() {
|
|
838
|
-
var _a;
|
|
839
972
|
log6("stopping...", void 0, {
|
|
840
|
-
F:
|
|
841
|
-
L:
|
|
973
|
+
F: __dxlog_file7,
|
|
974
|
+
L: 287,
|
|
842
975
|
S: this,
|
|
843
976
|
C: (f, a) => f(...a)
|
|
844
977
|
});
|
|
845
978
|
this._isStopping = true;
|
|
846
|
-
await
|
|
979
|
+
await this._feedSetIterator?.close();
|
|
847
980
|
await this._processingTrigger.wait();
|
|
848
981
|
await this._state._ctx.dispose();
|
|
849
982
|
this._state._ctx = new Context2();
|
|
850
983
|
this._state._reachedTargetPromise = void 0;
|
|
851
984
|
this._isStarted = false;
|
|
852
985
|
log6("stopped", void 0, {
|
|
853
|
-
F:
|
|
854
|
-
L:
|
|
986
|
+
F: __dxlog_file7,
|
|
987
|
+
L: 295,
|
|
855
988
|
S: this,
|
|
856
989
|
C: (f, a) => f(...a)
|
|
857
990
|
});
|
|
@@ -861,12 +994,17 @@ var Pipeline = class {
|
|
|
861
994
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
862
995
|
*/
|
|
863
996
|
async setCursor(timeframe) {
|
|
864
|
-
invariant6(!this._isStarted || this._isPaused, "Invalid state."
|
|
997
|
+
invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
998
|
+
F: __dxlog_file7,
|
|
999
|
+
L: 304,
|
|
1000
|
+
S: this,
|
|
1001
|
+
A: [
|
|
1002
|
+
"!this._isStarted || this._isPaused",
|
|
1003
|
+
"'Invalid state.'"
|
|
1004
|
+
]
|
|
1005
|
+
});
|
|
865
1006
|
this._state._startTimeframe = timeframe;
|
|
866
1007
|
this._timeframeClock.setTimeframe(timeframe);
|
|
867
|
-
for (const feed of this._feeds.values()) {
|
|
868
|
-
this._setFeedDownloadState(feed);
|
|
869
|
-
}
|
|
870
1008
|
if (this._feedSetIterator) {
|
|
871
1009
|
await this._feedSetIterator.close();
|
|
872
1010
|
await this._initIterator();
|
|
@@ -877,7 +1015,6 @@ var Pipeline = class {
|
|
|
877
1015
|
* Calling pause while processing will cause a deadlock.
|
|
878
1016
|
*/
|
|
879
1017
|
async pause() {
|
|
880
|
-
invariant6(this._isStarted, "Pipeline is not open.");
|
|
881
1018
|
if (this._isPaused) {
|
|
882
1019
|
return;
|
|
883
1020
|
}
|
|
@@ -886,31 +1023,65 @@ var Pipeline = class {
|
|
|
886
1023
|
this._isPaused = true;
|
|
887
1024
|
}
|
|
888
1025
|
async unpause() {
|
|
889
|
-
invariant6(this.
|
|
890
|
-
|
|
1026
|
+
invariant6(this._isPaused, "Pipeline is not paused.", {
|
|
1027
|
+
F: __dxlog_file7,
|
|
1028
|
+
L: 334,
|
|
1029
|
+
S: this,
|
|
1030
|
+
A: [
|
|
1031
|
+
"this._isPaused",
|
|
1032
|
+
"'Pipeline is not paused.'"
|
|
1033
|
+
]
|
|
1034
|
+
});
|
|
891
1035
|
this._pauseTrigger.wake();
|
|
892
1036
|
this._isPaused = false;
|
|
1037
|
+
for (const feed of this._feeds.values()) {
|
|
1038
|
+
this._setFeedDownloadState(feed);
|
|
1039
|
+
}
|
|
893
1040
|
}
|
|
894
1041
|
/**
|
|
895
1042
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
896
1043
|
* Updates the timeframe clock after the message has bee processed.
|
|
897
1044
|
*/
|
|
898
1045
|
async *consume() {
|
|
899
|
-
invariant6(!this.
|
|
900
|
-
|
|
901
|
-
|
|
1046
|
+
invariant6(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1047
|
+
F: __dxlog_file7,
|
|
1048
|
+
L: 349,
|
|
1049
|
+
S: this,
|
|
1050
|
+
A: [
|
|
1051
|
+
"!this._isBeingConsumed",
|
|
1052
|
+
"'Pipeline is already being consumed.'"
|
|
1053
|
+
]
|
|
1054
|
+
});
|
|
1055
|
+
this._isBeingConsumed = true;
|
|
1056
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1057
|
+
F: __dxlog_file7,
|
|
1058
|
+
L: 352,
|
|
1059
|
+
S: this,
|
|
1060
|
+
A: [
|
|
1061
|
+
"this._feedSetIterator",
|
|
1062
|
+
"'Iterator not initialized.'"
|
|
1063
|
+
]
|
|
1064
|
+
});
|
|
902
1065
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
903
1066
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
904
1067
|
while (!this._isStopping) {
|
|
905
1068
|
await this._pauseTrigger.wait();
|
|
906
1069
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
907
|
-
invariant6(this._feedSetIterator, "Iterator not initialized."
|
|
1070
|
+
invariant6(this._feedSetIterator, "Iterator not initialized.", {
|
|
1071
|
+
F: __dxlog_file7,
|
|
1072
|
+
L: 361,
|
|
1073
|
+
S: this,
|
|
1074
|
+
A: [
|
|
1075
|
+
"this._feedSetIterator",
|
|
1076
|
+
"'Iterator not initialized.'"
|
|
1077
|
+
]
|
|
1078
|
+
});
|
|
908
1079
|
lastFeedSetIterator = this._feedSetIterator;
|
|
909
1080
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
910
1081
|
}
|
|
911
1082
|
const { done, value } = await iterable.next();
|
|
912
1083
|
if (!done) {
|
|
913
|
-
const block = value
|
|
1084
|
+
const block = value ?? failUndefined();
|
|
914
1085
|
this._processingTrigger.reset();
|
|
915
1086
|
this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
|
|
916
1087
|
yield block;
|
|
@@ -918,16 +1089,31 @@ var Pipeline = class {
|
|
|
918
1089
|
this._timeframeClock.updateTimeframe();
|
|
919
1090
|
}
|
|
920
1091
|
}
|
|
921
|
-
this.
|
|
1092
|
+
this._isBeingConsumed = false;
|
|
922
1093
|
}
|
|
923
1094
|
_setFeedDownloadState(feed) {
|
|
924
|
-
var _a;
|
|
925
1095
|
const timeframe = this._state._startTimeframe;
|
|
926
|
-
const seq =
|
|
1096
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1097
|
+
log6("setFeedDownloadState", {
|
|
1098
|
+
feed: feed.key,
|
|
1099
|
+
feedInstance: getPrototypeSpecificInstanceId(feed),
|
|
1100
|
+
seq,
|
|
1101
|
+
isBeingConsumed: this._isBeingConsumed,
|
|
1102
|
+
isStarted: this._isStarted,
|
|
1103
|
+
isPaused: this._isPaused
|
|
1104
|
+
}, {
|
|
1105
|
+
F: __dxlog_file7,
|
|
1106
|
+
L: 386,
|
|
1107
|
+
S: this,
|
|
1108
|
+
C: (f, a) => f(...a)
|
|
1109
|
+
});
|
|
1110
|
+
if (!this._isStarted || this._isPaused) {
|
|
1111
|
+
console.log(new Error().stack);
|
|
1112
|
+
}
|
|
927
1113
|
feed.undownload({
|
|
928
1114
|
callback: () => log6("undownload", void 0, {
|
|
929
|
-
F:
|
|
930
|
-
L:
|
|
1115
|
+
F: __dxlog_file7,
|
|
1116
|
+
L: 398,
|
|
931
1117
|
S: this,
|
|
932
1118
|
C: (f, a) => f(...a)
|
|
933
1119
|
})
|
|
@@ -939,8 +1125,8 @@ var Pipeline = class {
|
|
|
939
1125
|
log6("failed to download feed", {
|
|
940
1126
|
err
|
|
941
1127
|
}, {
|
|
942
|
-
F:
|
|
943
|
-
L:
|
|
1128
|
+
F: __dxlog_file7,
|
|
1129
|
+
L: 400,
|
|
944
1130
|
S: this,
|
|
945
1131
|
C: (f, a) => f(...a)
|
|
946
1132
|
});
|
|
@@ -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: 411,
|
|
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
1277
|
import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
|
|
1077
1278
|
import { CancelledError } from "@dxos/errors";
|
|
1279
|
+
import { invariant as invariant8 } from "@dxos/invariant";
|
|
1078
1280
|
import { log as log8 } 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 === "dxos.sdk.client.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
|
});
|
|
@@ -1339,8 +1571,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1339
1571
|
log8("process epoch", {
|
|
1340
1572
|
epoch
|
|
1341
1573
|
}, {
|
|
1342
|
-
F:
|
|
1343
|
-
L:
|
|
1574
|
+
F: __dxlog_file9,
|
|
1575
|
+
L: 335,
|
|
1344
1576
|
S: this,
|
|
1345
1577
|
C: (f, a) => f(...a)
|
|
1346
1578
|
});
|
|
@@ -1350,14 +1582,30 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1350
1582
|
});
|
|
1351
1583
|
}
|
|
1352
1584
|
async _processEpoch(ctx, epoch) {
|
|
1353
|
-
invariant8(this._isOpen, "Space is closed."
|
|
1354
|
-
|
|
1585
|
+
invariant8(this._isOpen, "Space is closed.", {
|
|
1586
|
+
F: __dxlog_file9,
|
|
1587
|
+
L: 345,
|
|
1588
|
+
S: this,
|
|
1589
|
+
A: [
|
|
1590
|
+
"this._isOpen",
|
|
1591
|
+
"'Space is closed.'"
|
|
1592
|
+
]
|
|
1593
|
+
});
|
|
1594
|
+
invariant8(this._pipeline, void 0, {
|
|
1595
|
+
F: __dxlog_file9,
|
|
1596
|
+
L: 346,
|
|
1597
|
+
S: this,
|
|
1598
|
+
A: [
|
|
1599
|
+
"this._pipeline",
|
|
1600
|
+
""
|
|
1601
|
+
]
|
|
1602
|
+
});
|
|
1355
1603
|
this._lastProcessedEpoch = epoch.number;
|
|
1356
1604
|
log8("Processing epoch", {
|
|
1357
1605
|
epoch
|
|
1358
1606
|
}, {
|
|
1359
|
-
F:
|
|
1360
|
-
L:
|
|
1607
|
+
F: __dxlog_file9,
|
|
1608
|
+
L: 349,
|
|
1361
1609
|
S: this,
|
|
1362
1610
|
C: (f, a) => f(...a)
|
|
1363
1611
|
});
|
|
@@ -1366,8 +1614,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1366
1614
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1367
1615
|
}
|
|
1368
1616
|
log8("restarting pipeline for epoch", void 0, {
|
|
1369
|
-
F:
|
|
1370
|
-
L:
|
|
1617
|
+
F: __dxlog_file9,
|
|
1618
|
+
L: 356,
|
|
1371
1619
|
S: this,
|
|
1372
1620
|
C: (f, a) => f(...a)
|
|
1373
1621
|
});
|
|
@@ -1376,12 +1624,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1376
1624
|
await this._pipeline.unpause();
|
|
1377
1625
|
}
|
|
1378
1626
|
async waitUntilTimeframe(timeframe) {
|
|
1379
|
-
invariant8(this._pipeline, "Pipeline is not initialized."
|
|
1627
|
+
invariant8(this._pipeline, "Pipeline is not initialized.", {
|
|
1628
|
+
F: __dxlog_file9,
|
|
1629
|
+
L: 364,
|
|
1630
|
+
S: this,
|
|
1631
|
+
A: [
|
|
1632
|
+
"this._pipeline",
|
|
1633
|
+
"'Pipeline is not initialized.'"
|
|
1634
|
+
]
|
|
1635
|
+
});
|
|
1380
1636
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1381
1637
|
}
|
|
1382
1638
|
async createEpoch() {
|
|
1383
|
-
invariant8(this._pipeline
|
|
1384
|
-
|
|
1639
|
+
invariant8(this._pipeline, void 0, {
|
|
1640
|
+
F: __dxlog_file9,
|
|
1641
|
+
L: 370,
|
|
1642
|
+
S: this,
|
|
1643
|
+
A: [
|
|
1644
|
+
"this._pipeline",
|
|
1645
|
+
""
|
|
1646
|
+
]
|
|
1647
|
+
});
|
|
1648
|
+
invariant8(this.currentEpoch, void 0, {
|
|
1649
|
+
F: __dxlog_file9,
|
|
1650
|
+
L: 371,
|
|
1651
|
+
S: this,
|
|
1652
|
+
A: [
|
|
1653
|
+
"this.currentEpoch",
|
|
1654
|
+
""
|
|
1655
|
+
]
|
|
1656
|
+
});
|
|
1385
1657
|
await this._pipeline.pause();
|
|
1386
1658
|
const snapshot = await this._createSnapshot();
|
|
1387
1659
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1398,6 +1670,12 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1398
1670
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1399
1671
|
}
|
|
1400
1672
|
};
|
|
1673
|
+
_ts_decorate5([
|
|
1674
|
+
trace.metricsCounter()
|
|
1675
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1676
|
+
_ts_decorate5([
|
|
1677
|
+
trace.metricsCounter()
|
|
1678
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1401
1679
|
_ts_decorate5([
|
|
1402
1680
|
synchronized3
|
|
1403
1681
|
], DataPipeline.prototype, "open", null);
|
|
@@ -1411,29 +1689,45 @@ _ts_decorate5([
|
|
|
1411
1689
|
synchronized3
|
|
1412
1690
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1413
1691
|
DataPipeline = _ts_decorate5([
|
|
1414
|
-
trackLeaks2("open", "close")
|
|
1692
|
+
trackLeaks2("open", "close"),
|
|
1693
|
+
trace.resource()
|
|
1415
1694
|
], DataPipeline);
|
|
1416
1695
|
|
|
1417
1696
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1418
|
-
import invariant9 from "tiny-invariant";
|
|
1419
1697
|
import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
|
|
1698
|
+
import { invariant as invariant9 } from "@dxos/invariant";
|
|
1420
1699
|
import { log as log10, logInfo } from "@dxos/log";
|
|
1421
1700
|
import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1701
|
+
import { trace as trace3 } from "@dxos/tracing";
|
|
1422
1702
|
import { Callback as Callback2 } from "@dxos/util";
|
|
1423
1703
|
|
|
1424
1704
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1705
|
+
import { Context as Context5 } from "@dxos/context";
|
|
1425
1706
|
import { SpaceStateMachine } from "@dxos/credentials";
|
|
1426
1707
|
import { PublicKey as PublicKey4 } from "@dxos/keys";
|
|
1427
1708
|
import { log as log9 } from "@dxos/log";
|
|
1428
1709
|
import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
|
|
1429
1710
|
import { Timeframe as Timeframe4 } from "@dxos/timeframe";
|
|
1711
|
+
import { TimeSeriesCounter as TimeSeriesCounter2, TimeUsageCounter as TimeUsageCounter2, trace as trace2 } from "@dxos/tracing";
|
|
1430
1712
|
import { Callback, tracer as tracer2 } from "@dxos/util";
|
|
1431
|
-
|
|
1713
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1714
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1715
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1716
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1717
|
+
else
|
|
1718
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1719
|
+
if (d = decorators[i])
|
|
1720
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1721
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1722
|
+
}
|
|
1723
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1432
1724
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1433
|
-
var ControlPipeline = class {
|
|
1725
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1434
1726
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1435
1727
|
this._lastTimeframeSaveTime = Date.now();
|
|
1436
1728
|
this.onFeedAdmitted = new Callback();
|
|
1729
|
+
this._usage = new TimeUsageCounter2();
|
|
1730
|
+
this._mutations = new TimeSeriesCounter2();
|
|
1437
1731
|
this._spaceKey = spaceKey;
|
|
1438
1732
|
this._metadata = metadataStore;
|
|
1439
1733
|
this._pipeline = new Pipeline();
|
|
@@ -1443,8 +1737,8 @@ var ControlPipeline = class {
|
|
|
1443
1737
|
log9("feed admitted", {
|
|
1444
1738
|
key: info.key
|
|
1445
1739
|
}, {
|
|
1446
|
-
F:
|
|
1447
|
-
L:
|
|
1740
|
+
F: __dxlog_file10,
|
|
1741
|
+
L: 61,
|
|
1448
1742
|
S: this,
|
|
1449
1743
|
C: (f, a) => f(...a)
|
|
1450
1744
|
});
|
|
@@ -1454,8 +1748,8 @@ var ControlPipeline = class {
|
|
|
1454
1748
|
await this._pipeline.addFeed(feed);
|
|
1455
1749
|
} catch (err) {
|
|
1456
1750
|
log9.catch(err, void 0, {
|
|
1457
|
-
F:
|
|
1458
|
-
L:
|
|
1751
|
+
F: __dxlog_file10,
|
|
1752
|
+
L: 69,
|
|
1459
1753
|
S: this,
|
|
1460
1754
|
C: (f, a) => f(...a)
|
|
1461
1755
|
});
|
|
@@ -1477,58 +1771,67 @@ var ControlPipeline = class {
|
|
|
1477
1771
|
}
|
|
1478
1772
|
async start() {
|
|
1479
1773
|
log9("starting...", void 0, {
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1774
|
+
F: __dxlog_file10,
|
|
1775
|
+
L: 93,
|
|
1482
1776
|
S: this,
|
|
1483
1777
|
C: (f, a) => f(...a)
|
|
1484
1778
|
});
|
|
1485
1779
|
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
|
-
}
|
|
1780
|
+
void this._consumePipeline(new Context5());
|
|
1523
1781
|
});
|
|
1524
1782
|
await this._pipeline.start();
|
|
1525
1783
|
log9("started", void 0, {
|
|
1526
|
-
F:
|
|
1527
|
-
L:
|
|
1784
|
+
F: __dxlog_file10,
|
|
1785
|
+
L: 99,
|
|
1528
1786
|
S: this,
|
|
1529
1787
|
C: (f, a) => f(...a)
|
|
1530
1788
|
});
|
|
1531
1789
|
}
|
|
1790
|
+
async _consumePipeline(ctx) {
|
|
1791
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1792
|
+
const span = this._usage.beginRecording();
|
|
1793
|
+
this._mutations.inc();
|
|
1794
|
+
try {
|
|
1795
|
+
await this._processMessage(ctx, msg);
|
|
1796
|
+
} catch (err) {
|
|
1797
|
+
log9.catch(err, void 0, {
|
|
1798
|
+
F: __dxlog_file10,
|
|
1799
|
+
L: 111,
|
|
1800
|
+
S: this,
|
|
1801
|
+
C: (f, a) => f(...a)
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
span.end();
|
|
1805
|
+
}
|
|
1806
|
+
}
|
|
1807
|
+
async _processMessage(ctx, msg) {
|
|
1808
|
+
log9("processing", {
|
|
1809
|
+
key: msg.feedKey,
|
|
1810
|
+
seq: msg.seq
|
|
1811
|
+
}, {
|
|
1812
|
+
F: __dxlog_file10,
|
|
1813
|
+
L: 121,
|
|
1814
|
+
S: this,
|
|
1815
|
+
C: (f, a) => f(...a)
|
|
1816
|
+
});
|
|
1817
|
+
if (msg.data.payload.credential) {
|
|
1818
|
+
const timer = tracer2.mark("dxos.echo.pipeline.control");
|
|
1819
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
|
|
1820
|
+
timer.end();
|
|
1821
|
+
if (!result) {
|
|
1822
|
+
log9.warn("processing failed", {
|
|
1823
|
+
msg
|
|
1824
|
+
}, {
|
|
1825
|
+
F: __dxlog_file10,
|
|
1826
|
+
L: 131,
|
|
1827
|
+
S: this,
|
|
1828
|
+
C: (f, a) => f(...a)
|
|
1829
|
+
});
|
|
1830
|
+
} else {
|
|
1831
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1532
1835
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1533
1836
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
|
|
1534
1837
|
this._lastTimeframeSaveTime = Date.now();
|
|
@@ -1537,39 +1840,53 @@ var ControlPipeline = class {
|
|
|
1537
1840
|
}
|
|
1538
1841
|
async stop() {
|
|
1539
1842
|
log9("stopping...", void 0, {
|
|
1540
|
-
F:
|
|
1541
|
-
L:
|
|
1843
|
+
F: __dxlog_file10,
|
|
1844
|
+
L: 149,
|
|
1542
1845
|
S: this,
|
|
1543
1846
|
C: (f, a) => f(...a)
|
|
1544
1847
|
});
|
|
1545
1848
|
await this._pipeline.stop();
|
|
1546
1849
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1547
1850
|
log9("stopped", void 0, {
|
|
1548
|
-
F:
|
|
1549
|
-
L:
|
|
1851
|
+
F: __dxlog_file10,
|
|
1852
|
+
L: 152,
|
|
1550
1853
|
S: this,
|
|
1551
1854
|
C: (f, a) => f(...a)
|
|
1552
1855
|
});
|
|
1553
1856
|
}
|
|
1554
1857
|
async _saveTargetTimeframe(timeframe) {
|
|
1555
|
-
var _a;
|
|
1556
1858
|
try {
|
|
1557
|
-
const newTimeframe = Timeframe4.merge(
|
|
1859
|
+
const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
|
|
1558
1860
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1559
1861
|
this._targetTimeframe = newTimeframe;
|
|
1560
1862
|
} catch (err) {
|
|
1561
1863
|
log9(err, void 0, {
|
|
1562
|
-
F:
|
|
1563
|
-
L:
|
|
1864
|
+
F: __dxlog_file10,
|
|
1865
|
+
L: 161,
|
|
1564
1866
|
S: this,
|
|
1565
1867
|
C: (f, a) => f(...a)
|
|
1566
1868
|
});
|
|
1567
1869
|
}
|
|
1568
1870
|
}
|
|
1569
1871
|
};
|
|
1872
|
+
_ts_decorate6([
|
|
1873
|
+
trace2.metricsCounter()
|
|
1874
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1875
|
+
_ts_decorate6([
|
|
1876
|
+
trace2.metricsCounter()
|
|
1877
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1878
|
+
_ts_decorate6([
|
|
1879
|
+
trace2.span()
|
|
1880
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1881
|
+
_ts_decorate6([
|
|
1882
|
+
trace2.span()
|
|
1883
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1884
|
+
ControlPipeline = _ts_decorate6([
|
|
1885
|
+
trace2.resource()
|
|
1886
|
+
], ControlPipeline);
|
|
1570
1887
|
|
|
1571
1888
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1572
|
-
function
|
|
1889
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1573
1890
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1574
1891
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1575
1892
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1579,14 +1896,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1579
1896
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1580
1897
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1581
1898
|
}
|
|
1582
|
-
var
|
|
1899
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1583
1900
|
var Space = class Space2 {
|
|
1584
1901
|
constructor(params) {
|
|
1585
1902
|
this._addFeedLock = new Lock();
|
|
1586
1903
|
this.onCredentialProcessed = new Callback2();
|
|
1587
1904
|
this.stateUpdate = new Event5();
|
|
1588
1905
|
this._isOpen = false;
|
|
1589
|
-
invariant9(params.spaceKey && params.feedProvider
|
|
1906
|
+
invariant9(params.spaceKey && params.feedProvider, void 0, {
|
|
1907
|
+
F: __dxlog_file11,
|
|
1908
|
+
L: 73,
|
|
1909
|
+
S: this,
|
|
1910
|
+
A: [
|
|
1911
|
+
"params.spaceKey && params.feedProvider",
|
|
1912
|
+
""
|
|
1913
|
+
]
|
|
1914
|
+
});
|
|
1590
1915
|
this._key = params.spaceKey;
|
|
1591
1916
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1592
1917
|
this._feedProvider = params.feedProvider;
|
|
@@ -1621,8 +1946,8 @@ var Space = class Space2 {
|
|
|
1621
1946
|
log10("onCredentialProcessed", {
|
|
1622
1947
|
credential
|
|
1623
1948
|
}, {
|
|
1624
|
-
F:
|
|
1625
|
-
L:
|
|
1949
|
+
F: __dxlog_file11,
|
|
1950
|
+
L: 109,
|
|
1626
1951
|
S: this,
|
|
1627
1952
|
C: (f, a) => f(...a)
|
|
1628
1953
|
});
|
|
@@ -1664,12 +1989,10 @@ var Space = class Space2 {
|
|
|
1664
1989
|
return this._genesisFeedKey;
|
|
1665
1990
|
}
|
|
1666
1991
|
get controlFeedKey() {
|
|
1667
|
-
|
|
1668
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
1992
|
+
return this._controlFeed?.key;
|
|
1669
1993
|
}
|
|
1670
1994
|
get dataFeedKey() {
|
|
1671
|
-
|
|
1672
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
1995
|
+
return this._dataFeed?.key;
|
|
1673
1996
|
}
|
|
1674
1997
|
get spaceState() {
|
|
1675
1998
|
return this._controlPipeline.spaceState;
|
|
@@ -1687,16 +2010,31 @@ var Space = class Space2 {
|
|
|
1687
2010
|
return this._snapshotManager;
|
|
1688
2011
|
}
|
|
1689
2012
|
setControlFeed(feed) {
|
|
1690
|
-
invariant9(!this._controlFeed, "Control feed already set."
|
|
2013
|
+
invariant9(!this._controlFeed, "Control feed already set.", {
|
|
2014
|
+
F: __dxlog_file11,
|
|
2015
|
+
L: 184,
|
|
2016
|
+
S: this,
|
|
2017
|
+
A: [
|
|
2018
|
+
"!this._controlFeed",
|
|
2019
|
+
"'Control feed already set.'"
|
|
2020
|
+
]
|
|
2021
|
+
});
|
|
1691
2022
|
this._controlFeed = feed;
|
|
1692
2023
|
this._controlPipeline.setWriteFeed(feed);
|
|
1693
2024
|
return this;
|
|
1694
2025
|
}
|
|
1695
2026
|
setDataFeed(feed) {
|
|
1696
|
-
|
|
1697
|
-
|
|
2027
|
+
invariant9(!this._dataFeed, "Data feed already set.", {
|
|
2028
|
+
F: __dxlog_file11,
|
|
2029
|
+
L: 191,
|
|
2030
|
+
S: this,
|
|
2031
|
+
A: [
|
|
2032
|
+
"!this._dataFeed",
|
|
2033
|
+
"'Data feed already set.'"
|
|
2034
|
+
]
|
|
2035
|
+
});
|
|
1698
2036
|
this._dataFeed = feed;
|
|
1699
|
-
|
|
2037
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1700
2038
|
return this;
|
|
1701
2039
|
}
|
|
1702
2040
|
/**
|
|
@@ -1711,10 +2049,10 @@ var Space = class Space2 {
|
|
|
1711
2049
|
// getDataFeeds(): FeedInfo[] {
|
|
1712
2050
|
// return this._dataPipeline?.getFeeds();
|
|
1713
2051
|
// }
|
|
1714
|
-
async open() {
|
|
2052
|
+
async open(ctx) {
|
|
1715
2053
|
log10("opening...", void 0, {
|
|
1716
|
-
F:
|
|
1717
|
-
L:
|
|
2054
|
+
F: __dxlog_file11,
|
|
2055
|
+
L: 213,
|
|
1718
2056
|
S: this,
|
|
1719
2057
|
C: (f, a) => f(...a)
|
|
1720
2058
|
});
|
|
@@ -1726,8 +2064,8 @@ var Space = class Space2 {
|
|
|
1726
2064
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1727
2065
|
this._isOpen = true;
|
|
1728
2066
|
log10("opened", void 0, {
|
|
1729
|
-
F:
|
|
1730
|
-
L:
|
|
2067
|
+
F: __dxlog_file11,
|
|
2068
|
+
L: 224,
|
|
1731
2069
|
S: this,
|
|
1732
2070
|
C: (f, a) => f(...a)
|
|
1733
2071
|
});
|
|
@@ -1736,8 +2074,8 @@ var Space = class Space2 {
|
|
|
1736
2074
|
log10("closing...", {
|
|
1737
2075
|
key: this._key
|
|
1738
2076
|
}, {
|
|
1739
|
-
F:
|
|
1740
|
-
L:
|
|
2077
|
+
F: __dxlog_file11,
|
|
2078
|
+
L: 229,
|
|
1741
2079
|
S: this,
|
|
1742
2080
|
C: (f, a) => f(...a)
|
|
1743
2081
|
});
|
|
@@ -1750,37 +2088,48 @@ var Space = class Space2 {
|
|
|
1750
2088
|
await this._controlPipeline.stop();
|
|
1751
2089
|
this._isOpen = false;
|
|
1752
2090
|
log10("closed", void 0, {
|
|
1753
|
-
F:
|
|
1754
|
-
L:
|
|
2091
|
+
F: __dxlog_file11,
|
|
2092
|
+
L: 242,
|
|
1755
2093
|
S: this,
|
|
1756
2094
|
C: (f, a) => f(...a)
|
|
1757
2095
|
});
|
|
1758
2096
|
}
|
|
1759
2097
|
async initializeDataPipeline() {
|
|
1760
2098
|
log10("initializeDataPipeline", void 0, {
|
|
1761
|
-
F:
|
|
1762
|
-
L:
|
|
2099
|
+
F: __dxlog_file11,
|
|
2100
|
+
L: 247,
|
|
1763
2101
|
S: this,
|
|
1764
2102
|
C: (f, a) => f(...a)
|
|
1765
2103
|
});
|
|
1766
|
-
invariant9(this._isOpen, "Space must be open to initialize data pipeline."
|
|
2104
|
+
invariant9(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2105
|
+
F: __dxlog_file11,
|
|
2106
|
+
L: 248,
|
|
2107
|
+
S: this,
|
|
2108
|
+
A: [
|
|
2109
|
+
"this._isOpen",
|
|
2110
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2111
|
+
]
|
|
2112
|
+
});
|
|
1767
2113
|
await this._dataPipeline.open();
|
|
1768
2114
|
}
|
|
1769
2115
|
};
|
|
1770
|
-
|
|
1771
|
-
logInfo
|
|
2116
|
+
_ts_decorate7([
|
|
2117
|
+
logInfo,
|
|
2118
|
+
trace3.info()
|
|
1772
2119
|
], Space.prototype, "key", null);
|
|
1773
|
-
|
|
1774
|
-
synchronized4
|
|
2120
|
+
_ts_decorate7([
|
|
2121
|
+
synchronized4,
|
|
2122
|
+
trace3.span()
|
|
1775
2123
|
], Space.prototype, "open", null);
|
|
1776
|
-
|
|
2124
|
+
_ts_decorate7([
|
|
1777
2125
|
synchronized4
|
|
1778
2126
|
], Space.prototype, "close", null);
|
|
1779
|
-
|
|
2127
|
+
_ts_decorate7([
|
|
1780
2128
|
synchronized4
|
|
1781
2129
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1782
|
-
Space =
|
|
1783
|
-
trackLeaks3("open", "close")
|
|
2130
|
+
Space = _ts_decorate7([
|
|
2131
|
+
trackLeaks3("open", "close"),
|
|
2132
|
+
trace3.resource()
|
|
1784
2133
|
], Space);
|
|
1785
2134
|
|
|
1786
2135
|
// packages/core/echo/echo-pipeline/src/space/space-protocol.ts
|
|
@@ -1792,7 +2141,7 @@ import { Teleport } from "@dxos/teleport";
|
|
|
1792
2141
|
import { BlobSync } from "@dxos/teleport-extension-object-sync";
|
|
1793
2142
|
import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
|
|
1794
2143
|
import { ComplexMap as ComplexMap4 } from "@dxos/util";
|
|
1795
|
-
function
|
|
2144
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1796
2145
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1797
2146
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1798
2147
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1802,7 +2151,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1802
2151
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1803
2152
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1804
2153
|
}
|
|
1805
|
-
var
|
|
2154
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1806
2155
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1807
2156
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1808
2157
|
var SpaceProtocol = class {
|
|
@@ -1832,7 +2181,7 @@ var SpaceProtocol = class {
|
|
|
1832
2181
|
log11("addFeed", {
|
|
1833
2182
|
key: feed.key
|
|
1834
2183
|
}, {
|
|
1835
|
-
F:
|
|
2184
|
+
F: __dxlog_file12,
|
|
1836
2185
|
L: 95,
|
|
1837
2186
|
S: this,
|
|
1838
2187
|
C: (f, a) => f(...a)
|
|
@@ -1854,7 +2203,7 @@ var SpaceProtocol = class {
|
|
|
1854
2203
|
};
|
|
1855
2204
|
await this.blobSync.open();
|
|
1856
2205
|
log11("starting...", void 0, {
|
|
1857
|
-
F:
|
|
2206
|
+
F: __dxlog_file12,
|
|
1858
2207
|
L: 120,
|
|
1859
2208
|
S: this,
|
|
1860
2209
|
C: (f, a) => f(...a)
|
|
@@ -1868,7 +2217,7 @@ var SpaceProtocol = class {
|
|
|
1868
2217
|
label: `Protocol swarm: ${topic}`
|
|
1869
2218
|
});
|
|
1870
2219
|
log11("started", void 0, {
|
|
1871
|
-
F:
|
|
2220
|
+
F: __dxlog_file12,
|
|
1872
2221
|
L: 130,
|
|
1873
2222
|
S: this,
|
|
1874
2223
|
C: (f, a) => f(...a)
|
|
@@ -1878,14 +2227,14 @@ var SpaceProtocol = class {
|
|
|
1878
2227
|
await this.blobSync.close();
|
|
1879
2228
|
if (this._connection) {
|
|
1880
2229
|
log11("stopping...", void 0, {
|
|
1881
|
-
F:
|
|
2230
|
+
F: __dxlog_file12,
|
|
1882
2231
|
L: 137,
|
|
1883
2232
|
S: this,
|
|
1884
2233
|
C: (f, a) => f(...a)
|
|
1885
2234
|
});
|
|
1886
2235
|
await this._connection.close();
|
|
1887
2236
|
log11("stopped", void 0, {
|
|
1888
|
-
F:
|
|
2237
|
+
F: __dxlog_file12,
|
|
1889
2238
|
L: 139,
|
|
1890
2239
|
S: this,
|
|
1891
2240
|
C: (f, a) => f(...a)
|
|
@@ -1909,10 +2258,10 @@ var SpaceProtocol = class {
|
|
|
1909
2258
|
};
|
|
1910
2259
|
}
|
|
1911
2260
|
};
|
|
1912
|
-
|
|
2261
|
+
_ts_decorate8([
|
|
1913
2262
|
logInfo2
|
|
1914
2263
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
1915
|
-
|
|
2264
|
+
_ts_decorate8([
|
|
1916
2265
|
logInfo2
|
|
1917
2266
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
1918
2267
|
var AuthStatus;
|
|
@@ -1951,20 +2300,18 @@ var SpaceProtocolSession = class {
|
|
|
1951
2300
|
provider: this._swarmIdentity.credentialProvider,
|
|
1952
2301
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
1953
2302
|
onAuthSuccess: () => {
|
|
1954
|
-
var _a;
|
|
1955
2303
|
log11("Peer authenticated", void 0, {
|
|
1956
|
-
F:
|
|
2304
|
+
F: __dxlog_file12,
|
|
1957
2305
|
L: 236,
|
|
1958
2306
|
S: this,
|
|
1959
2307
|
C: (f, a) => f(...a)
|
|
1960
2308
|
});
|
|
1961
2309
|
this._authStatus = AuthStatus.SUCCESS;
|
|
1962
|
-
|
|
2310
|
+
this._onSessionAuth?.(this._teleport);
|
|
1963
2311
|
},
|
|
1964
2312
|
onAuthFailure: () => {
|
|
1965
|
-
var _a;
|
|
1966
2313
|
this._authStatus = AuthStatus.FAILURE;
|
|
1967
|
-
|
|
2314
|
+
this._onAuthFailure?.(this._teleport);
|
|
1968
2315
|
}
|
|
1969
2316
|
}));
|
|
1970
2317
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -1974,10 +2321,10 @@ var SpaceProtocolSession = class {
|
|
|
1974
2321
|
await this._teleport.close();
|
|
1975
2322
|
}
|
|
1976
2323
|
};
|
|
1977
|
-
|
|
2324
|
+
_ts_decorate8([
|
|
1978
2325
|
logInfo2
|
|
1979
2326
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
1980
|
-
|
|
2327
|
+
_ts_decorate8([
|
|
1981
2328
|
logInfo2
|
|
1982
2329
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
1983
2330
|
|
|
@@ -1986,9 +2333,9 @@ import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/
|
|
|
1986
2333
|
import { failUndefined as failUndefined2 } from "@dxos/debug";
|
|
1987
2334
|
import { PublicKey as PublicKey6 } from "@dxos/keys";
|
|
1988
2335
|
import { log as log12 } from "@dxos/log";
|
|
1989
|
-
import { trace } from "@dxos/protocols";
|
|
2336
|
+
import { trace as trace4 } from "@dxos/protocols";
|
|
1990
2337
|
import { ComplexMap as ComplexMap5 } from "@dxos/util";
|
|
1991
|
-
function
|
|
2338
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
1992
2339
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1993
2340
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1994
2341
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1998,7 +2345,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
1998
2345
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1999
2346
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2000
2347
|
}
|
|
2001
|
-
var
|
|
2348
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2002
2349
|
var SpaceManager = class SpaceManager2 {
|
|
2003
2350
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2004
2351
|
this._spaces = new ComplexMap5(PublicKey6.hash);
|
|
@@ -2022,11 +2369,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2022
2369
|
].map((space) => space.close()));
|
|
2023
2370
|
}
|
|
2024
2371
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2025
|
-
|
|
2026
|
-
log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
|
|
2372
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.begin({
|
|
2027
2373
|
id: this._instanceId
|
|
2028
2374
|
}), {
|
|
2029
|
-
F:
|
|
2375
|
+
F: __dxlog_file13,
|
|
2030
2376
|
L: 97,
|
|
2031
2377
|
S: this,
|
|
2032
2378
|
C: (f, a) => f(...a)
|
|
@@ -2034,12 +2380,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2034
2380
|
log12("constructing space...", {
|
|
2035
2381
|
spaceKey: metadata.genesisFeedKey
|
|
2036
2382
|
}, {
|
|
2037
|
-
F:
|
|
2383
|
+
F: __dxlog_file13,
|
|
2038
2384
|
L: 98,
|
|
2039
2385
|
S: this,
|
|
2040
2386
|
C: (f, a) => f(...a)
|
|
2041
2387
|
});
|
|
2042
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2388
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
|
|
2043
2389
|
const spaceKey = metadata.key;
|
|
2044
2390
|
const protocol = new SpaceProtocol({
|
|
2045
2391
|
topic: spaceKey,
|
|
@@ -2061,10 +2407,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2061
2407
|
memberKey
|
|
2062
2408
|
});
|
|
2063
2409
|
this._spaces.set(space.key, space);
|
|
2064
|
-
log12.trace("dxos.echo.space-manager.construct-space",
|
|
2410
|
+
log12.trace("dxos.echo.space-manager.construct-space", trace4.end({
|
|
2065
2411
|
id: this._instanceId
|
|
2066
2412
|
}), {
|
|
2067
|
-
F:
|
|
2413
|
+
F: __dxlog_file13,
|
|
2068
2414
|
L: 125,
|
|
2069
2415
|
S: this,
|
|
2070
2416
|
C: (f, a) => f(...a)
|
|
@@ -2072,13 +2418,13 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2072
2418
|
return space;
|
|
2073
2419
|
}
|
|
2074
2420
|
};
|
|
2075
|
-
|
|
2421
|
+
_ts_decorate9([
|
|
2076
2422
|
synchronized5
|
|
2077
2423
|
], SpaceManager.prototype, "open", null);
|
|
2078
|
-
|
|
2424
|
+
_ts_decorate9([
|
|
2079
2425
|
synchronized5
|
|
2080
2426
|
], SpaceManager.prototype, "close", null);
|
|
2081
|
-
SpaceManager =
|
|
2427
|
+
SpaceManager = _ts_decorate9([
|
|
2082
2428
|
trackLeaks4("open", "close")
|
|
2083
2429
|
], SpaceManager);
|
|
2084
2430
|
|
|
@@ -2108,4 +2454,4 @@ export {
|
|
|
2108
2454
|
SpaceProtocolSession,
|
|
2109
2455
|
SpaceManager
|
|
2110
2456
|
};
|
|
2111
|
-
//# sourceMappingURL=chunk-
|
|
2457
|
+
//# sourceMappingURL=chunk-FCDYN74V.mjs.map
|