@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
package/dist/lib/node/index.cjs
CHANGED
|
@@ -71,23 +71,41 @@ var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage"
|
|
|
71
71
|
var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
|
|
72
72
|
|
|
73
73
|
// packages/core/echo/echo-pipeline/src/common/feeds.ts
|
|
74
|
-
var
|
|
74
|
+
var import_invariant = require("@dxos/invariant");
|
|
75
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/common/feeds.ts";
|
|
75
76
|
var createMappedFeedWriter = (mapper, writer) => {
|
|
76
|
-
(0,
|
|
77
|
-
|
|
77
|
+
(0, import_invariant.invariant)(mapper, void 0, {
|
|
78
|
+
F: __dxlog_file,
|
|
79
|
+
L: 16,
|
|
80
|
+
S: void 0,
|
|
81
|
+
A: [
|
|
82
|
+
"mapper",
|
|
83
|
+
""
|
|
84
|
+
]
|
|
85
|
+
});
|
|
86
|
+
(0, import_invariant.invariant)(writer, void 0, {
|
|
87
|
+
F: __dxlog_file,
|
|
88
|
+
L: 17,
|
|
89
|
+
S: void 0,
|
|
90
|
+
A: [
|
|
91
|
+
"writer",
|
|
92
|
+
""
|
|
93
|
+
]
|
|
94
|
+
});
|
|
78
95
|
return {
|
|
79
96
|
write: async (data, options) => await writer.write(await mapper(data), options)
|
|
80
97
|
};
|
|
81
98
|
};
|
|
82
99
|
|
|
83
100
|
// packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts
|
|
84
|
-
var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
|
|
85
101
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
86
102
|
var import_context = require("@dxos/context");
|
|
87
103
|
var import_echo_db = require("@dxos/echo-db");
|
|
104
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
88
105
|
var import_log = require("@dxos/log");
|
|
106
|
+
var import_service = require("@dxos/protocols/proto/dxos/echo/service");
|
|
89
107
|
var import_util = require("@dxos/util");
|
|
90
|
-
var
|
|
108
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service-host.ts";
|
|
91
109
|
var DataServiceHost = class {
|
|
92
110
|
constructor(_itemManager, _itemDemuxer, _writeStream) {
|
|
93
111
|
this._itemManager = _itemManager;
|
|
@@ -113,16 +131,31 @@ var DataServiceHost = class {
|
|
|
113
131
|
objects
|
|
114
132
|
}
|
|
115
133
|
});
|
|
134
|
+
this._itemDemuxer.snapshot.on(ctx, (snapshot) => {
|
|
135
|
+
next({
|
|
136
|
+
action: import_service.EchoEvent.DatabaseAction.RESET,
|
|
137
|
+
batch: {
|
|
138
|
+
objects: snapshot.items
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
});
|
|
116
142
|
this._itemDemuxer.mutation.on(ctx, (message) => {
|
|
117
|
-
var _a;
|
|
118
143
|
const { batch, meta } = message;
|
|
119
|
-
(0,
|
|
144
|
+
(0, import_invariant2.invariant)(!meta.clientTag, "Unexpected client tag in mutation message", {
|
|
145
|
+
F: __dxlog_file2,
|
|
146
|
+
L: 68,
|
|
147
|
+
S: this,
|
|
148
|
+
A: [
|
|
149
|
+
"!(meta as any).clientTag",
|
|
150
|
+
"'Unexpected client tag in mutation message'"
|
|
151
|
+
]
|
|
152
|
+
});
|
|
120
153
|
(0, import_log.log)("message", {
|
|
121
|
-
batch,
|
|
154
|
+
batch: batch.objects?.length,
|
|
122
155
|
meta
|
|
123
156
|
}, {
|
|
124
|
-
F:
|
|
125
|
-
L:
|
|
157
|
+
F: __dxlog_file2,
|
|
158
|
+
L: 69,
|
|
126
159
|
S: this,
|
|
127
160
|
C: (f, a) => f(...a)
|
|
128
161
|
});
|
|
@@ -130,7 +163,7 @@ var DataServiceHost = class {
|
|
|
130
163
|
message.meta.feedKey,
|
|
131
164
|
message.meta.seq
|
|
132
165
|
]);
|
|
133
|
-
|
|
166
|
+
batch.objects?.forEach((object) => {
|
|
134
167
|
(0, import_echo_db.setMetadataOnObject)(object, {
|
|
135
168
|
...meta
|
|
136
169
|
});
|
|
@@ -148,15 +181,30 @@ var DataServiceHost = class {
|
|
|
148
181
|
});
|
|
149
182
|
}
|
|
150
183
|
async write(request) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
184
|
+
(0, import_invariant2.invariant)(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
|
|
185
|
+
F: __dxlog_file2,
|
|
186
|
+
L: 95,
|
|
187
|
+
S: this,
|
|
188
|
+
A: [
|
|
189
|
+
"!this._ctx.disposed",
|
|
190
|
+
"'Cannot write to closed DataServiceHost'"
|
|
191
|
+
]
|
|
192
|
+
});
|
|
193
|
+
(0, import_invariant2.invariant)(this._writeStream, "Cannot write mutations in readonly mode", {
|
|
194
|
+
F: __dxlog_file2,
|
|
195
|
+
L: 96,
|
|
196
|
+
S: this,
|
|
197
|
+
A: [
|
|
198
|
+
"this._writeStream",
|
|
199
|
+
"'Cannot write mutations in readonly mode'"
|
|
200
|
+
]
|
|
201
|
+
});
|
|
154
202
|
(0, import_log.log)("write", {
|
|
155
203
|
clientTag: request.clientTag,
|
|
156
|
-
objectCount:
|
|
204
|
+
objectCount: request.batch.objects?.length ?? 0
|
|
157
205
|
}, {
|
|
158
|
-
F:
|
|
159
|
-
L:
|
|
206
|
+
F: __dxlog_file2,
|
|
207
|
+
L: 98,
|
|
160
208
|
S: this,
|
|
161
209
|
C: (f, a) => f(...a)
|
|
162
210
|
});
|
|
@@ -169,8 +217,8 @@ var DataServiceHost = class {
|
|
|
169
217
|
feedKey: receipt2.feedKey,
|
|
170
218
|
seq: receipt2.seq
|
|
171
219
|
}, {
|
|
172
|
-
F:
|
|
173
|
-
L:
|
|
220
|
+
F: __dxlog_file2,
|
|
221
|
+
L: 107,
|
|
174
222
|
S: this,
|
|
175
223
|
C: (f, a) => f(...a)
|
|
176
224
|
});
|
|
@@ -184,24 +232,18 @@ var DataServiceHost = class {
|
|
|
184
232
|
return receipt;
|
|
185
233
|
}
|
|
186
234
|
};
|
|
187
|
-
var createDataMessage = (batch) => {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
meta: void 0
|
|
200
|
-
};
|
|
201
|
-
})
|
|
202
|
-
}
|
|
203
|
-
};
|
|
204
|
-
};
|
|
235
|
+
var createDataMessage = (batch) => ({
|
|
236
|
+
batch: {
|
|
237
|
+
objects: batch.objects?.map((object) => ({
|
|
238
|
+
...object,
|
|
239
|
+
mutations: object.mutations?.map((mutation) => ({
|
|
240
|
+
...mutation,
|
|
241
|
+
meta: void 0
|
|
242
|
+
})),
|
|
243
|
+
meta: void 0
|
|
244
|
+
}))
|
|
245
|
+
}
|
|
246
|
+
});
|
|
205
247
|
|
|
206
248
|
// packages/core/echo/echo-pipeline/src/db-host/database-host.ts
|
|
207
249
|
var import_echo_db2 = require("@dxos/echo-db");
|
|
@@ -230,15 +272,13 @@ var DatabaseHost = class {
|
|
|
230
272
|
return this._itemDemuxer.createSnapshot();
|
|
231
273
|
}
|
|
232
274
|
createDataServiceHost() {
|
|
233
|
-
|
|
234
|
-
return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
|
|
275
|
+
return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
|
|
235
276
|
}
|
|
236
277
|
};
|
|
237
278
|
|
|
238
279
|
// packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
|
|
239
280
|
var import_async = require("@dxos/async");
|
|
240
281
|
var import_context2 = require("@dxos/context");
|
|
241
|
-
var import_debug = require("@dxos/debug");
|
|
242
282
|
var import_keys = require("@dxos/keys");
|
|
243
283
|
var import_protocols2 = require("@dxos/protocols");
|
|
244
284
|
var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
|
|
@@ -283,9 +323,6 @@ var SnapshotManager = class SnapshotManager2 {
|
|
|
283
323
|
return import_keys.PublicKey.from(id).toHex();
|
|
284
324
|
}
|
|
285
325
|
};
|
|
286
|
-
_ts_decorate([
|
|
287
|
-
(0, import_debug.timed)(1e4)
|
|
288
|
-
], SnapshotManager.prototype, "load", null);
|
|
289
326
|
SnapshotManager = _ts_decorate([
|
|
290
327
|
(0, import_async.trackLeaks)("open", "close")
|
|
291
328
|
], SnapshotManager);
|
|
@@ -337,12 +374,12 @@ var SnapshotStore = class {
|
|
|
337
374
|
};
|
|
338
375
|
|
|
339
376
|
// packages/core/echo/echo-pipeline/src/db-host/data-service.ts
|
|
340
|
-
var
|
|
341
|
-
var
|
|
377
|
+
var import_debug = require("@dxos/debug");
|
|
378
|
+
var import_invariant3 = require("@dxos/invariant");
|
|
342
379
|
var import_keys2 = require("@dxos/keys");
|
|
343
380
|
var import_log2 = require("@dxos/log");
|
|
344
381
|
var import_util2 = require("@dxos/util");
|
|
345
|
-
var
|
|
382
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/db-host/data-service.ts";
|
|
346
383
|
var DataServiceSubscriptions = class {
|
|
347
384
|
constructor() {
|
|
348
385
|
this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
@@ -354,12 +391,20 @@ var DataServiceSubscriptions = class {
|
|
|
354
391
|
(0, import_log2.log)("Registering space", {
|
|
355
392
|
spaceKey
|
|
356
393
|
}, {
|
|
357
|
-
F:
|
|
358
|
-
L:
|
|
394
|
+
F: __dxlog_file3,
|
|
395
|
+
L: 30,
|
|
359
396
|
S: this,
|
|
360
397
|
C: (f, a) => f(...a)
|
|
361
398
|
});
|
|
362
|
-
(0,
|
|
399
|
+
(0, import_invariant3.invariant)(!this._spaces.has(spaceKey), void 0, {
|
|
400
|
+
F: __dxlog_file3,
|
|
401
|
+
L: 31,
|
|
402
|
+
S: this,
|
|
403
|
+
A: [
|
|
404
|
+
"!this._spaces.has(spaceKey)",
|
|
405
|
+
""
|
|
406
|
+
]
|
|
407
|
+
});
|
|
363
408
|
await host.open();
|
|
364
409
|
this._spaces.set(spaceKey, host);
|
|
365
410
|
}
|
|
@@ -367,13 +412,13 @@ var DataServiceSubscriptions = class {
|
|
|
367
412
|
(0, import_log2.log)("Unregistering space", {
|
|
368
413
|
spaceKey
|
|
369
414
|
}, {
|
|
370
|
-
F:
|
|
371
|
-
L:
|
|
415
|
+
F: __dxlog_file3,
|
|
416
|
+
L: 37,
|
|
372
417
|
S: this,
|
|
373
418
|
C: (f, a) => f(...a)
|
|
374
419
|
});
|
|
375
420
|
const host = this._spaces.get(spaceKey);
|
|
376
|
-
await
|
|
421
|
+
await host?.close();
|
|
377
422
|
this._spaces.delete(spaceKey);
|
|
378
423
|
}
|
|
379
424
|
getDataService(spaceKey) {
|
|
@@ -385,16 +430,38 @@ var DataServiceImpl = class {
|
|
|
385
430
|
this._subscriptions = _subscriptions;
|
|
386
431
|
}
|
|
387
432
|
subscribe(request) {
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
433
|
+
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
434
|
+
F: __dxlog_file3,
|
|
435
|
+
L: 56,
|
|
436
|
+
S: this,
|
|
437
|
+
A: [
|
|
438
|
+
"request.spaceKey",
|
|
439
|
+
""
|
|
440
|
+
]
|
|
441
|
+
});
|
|
442
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
391
443
|
return host.subscribe();
|
|
392
444
|
}
|
|
393
445
|
write(request) {
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
446
|
+
(0, import_invariant3.invariant)(request.spaceKey, void 0, {
|
|
447
|
+
F: __dxlog_file3,
|
|
448
|
+
L: 63,
|
|
449
|
+
S: this,
|
|
450
|
+
A: [
|
|
451
|
+
"request.spaceKey",
|
|
452
|
+
""
|
|
453
|
+
]
|
|
454
|
+
});
|
|
455
|
+
(0, import_invariant3.invariant)(request.batch, void 0, {
|
|
456
|
+
F: __dxlog_file3,
|
|
457
|
+
L: 64,
|
|
458
|
+
S: this,
|
|
459
|
+
A: [
|
|
460
|
+
"request.batch",
|
|
461
|
+
""
|
|
462
|
+
]
|
|
463
|
+
});
|
|
464
|
+
const host = this._subscriptions.getDataService(request.spaceKey) ?? (0, import_debug.raise)(new Error(`space not found: ${request.spaceKey}`));
|
|
398
465
|
return host.write(request);
|
|
399
466
|
}
|
|
400
467
|
};
|
|
@@ -450,9 +517,9 @@ var UnknownModelError = class extends DBError {
|
|
|
450
517
|
|
|
451
518
|
// packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
|
|
452
519
|
var import_crc_32 = __toESM(require("crc-32"));
|
|
453
|
-
var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
|
|
454
520
|
var import_async2 = require("@dxos/async");
|
|
455
521
|
var import_errors = require("@dxos/errors");
|
|
522
|
+
var import_invariant4 = require("@dxos/invariant");
|
|
456
523
|
var import_log3 = require("@dxos/log");
|
|
457
524
|
var import_protocols4 = require("@dxos/protocols");
|
|
458
525
|
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
@@ -467,12 +534,12 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
467
534
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
468
535
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
469
536
|
}
|
|
470
|
-
var
|
|
537
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
|
|
471
538
|
var emptyEchoMetadata = () => ({
|
|
472
539
|
version: import_protocols4.STORAGE_VERSION,
|
|
473
540
|
spaces: [],
|
|
474
|
-
created: new Date(),
|
|
475
|
-
updated: new Date()
|
|
541
|
+
created: /* @__PURE__ */ new Date(),
|
|
542
|
+
updated: /* @__PURE__ */ new Date()
|
|
476
543
|
});
|
|
477
544
|
var EchoMetadata = import_protocols4.schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
|
|
478
545
|
var MetadataStore = class {
|
|
@@ -486,22 +553,19 @@ var MetadataStore = class {
|
|
|
486
553
|
return this._metadata;
|
|
487
554
|
}
|
|
488
555
|
get version() {
|
|
489
|
-
|
|
490
|
-
return (_a = this._metadata.version) != null ? _a : 0;
|
|
556
|
+
return this._metadata.version ?? 0;
|
|
491
557
|
}
|
|
492
558
|
/**
|
|
493
559
|
* Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
|
|
494
560
|
* addSpaceFeed functions.
|
|
495
561
|
*/
|
|
496
562
|
get spaces() {
|
|
497
|
-
|
|
498
|
-
return (_a = this._metadata.spaces) != null ? _a : [];
|
|
563
|
+
return this._metadata.spaces ?? [];
|
|
499
564
|
}
|
|
500
565
|
/**
|
|
501
566
|
* Loads metadata from persistent storage.
|
|
502
567
|
*/
|
|
503
568
|
async load() {
|
|
504
|
-
var _a;
|
|
505
569
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
506
570
|
try {
|
|
507
571
|
const { size: fileLength } = await file.stat();
|
|
@@ -514,13 +578,16 @@ var MetadataStore = class {
|
|
|
514
578
|
size: dataSize,
|
|
515
579
|
checksum
|
|
516
580
|
}, {
|
|
517
|
-
F:
|
|
581
|
+
F: __dxlog_file4,
|
|
518
582
|
L: 72,
|
|
519
583
|
S: this,
|
|
520
584
|
C: (f, a) => f(...a)
|
|
521
585
|
});
|
|
522
586
|
if (fileLength < dataSize + 8) {
|
|
523
|
-
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected."
|
|
587
|
+
throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.", {
|
|
588
|
+
fileLength,
|
|
589
|
+
dataSize
|
|
590
|
+
});
|
|
524
591
|
}
|
|
525
592
|
const data = await file.read(8, dataSize);
|
|
526
593
|
const calculatedChecksum = import_crc_32.default.buf(data);
|
|
@@ -528,15 +595,14 @@ var MetadataStore = class {
|
|
|
528
595
|
throw new import_errors.DataCorruptionError("Metadata checksum is invalid.");
|
|
529
596
|
}
|
|
530
597
|
this._metadata = EchoMetadata.decode(data);
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
(_a2 = space.state) != null ? _a2 : space.state = import_services.SpaceState.ACTIVE;
|
|
598
|
+
this._metadata.spaces?.forEach((space) => {
|
|
599
|
+
space.state ??= import_services.SpaceState.ACTIVE;
|
|
534
600
|
});
|
|
535
601
|
} catch (err) {
|
|
536
602
|
import_log3.log.error("failed to load metadata", {
|
|
537
603
|
err
|
|
538
604
|
}, {
|
|
539
|
-
F:
|
|
605
|
+
F: __dxlog_file4,
|
|
540
606
|
L: 92,
|
|
541
607
|
S: this,
|
|
542
608
|
C: (f, a) => f(...a)
|
|
@@ -547,12 +613,11 @@ var MetadataStore = class {
|
|
|
547
613
|
}
|
|
548
614
|
}
|
|
549
615
|
async _save() {
|
|
550
|
-
var _a;
|
|
551
616
|
const data = {
|
|
552
617
|
...this._metadata,
|
|
553
618
|
version: import_protocols4.STORAGE_VERSION,
|
|
554
|
-
created:
|
|
555
|
-
updated: new Date()
|
|
619
|
+
created: this._metadata.created ?? /* @__PURE__ */ new Date(),
|
|
620
|
+
updated: /* @__PURE__ */ new Date()
|
|
556
621
|
};
|
|
557
622
|
this.update.emit(data);
|
|
558
623
|
const file = this._directory.getOrCreateFile("EchoMetadata");
|
|
@@ -568,7 +633,7 @@ var MetadataStore = class {
|
|
|
568
633
|
size: encoded.length,
|
|
569
634
|
checksum
|
|
570
635
|
}, {
|
|
571
|
-
F:
|
|
636
|
+
F: __dxlog_file4,
|
|
572
637
|
L: 124,
|
|
573
638
|
S: this,
|
|
574
639
|
C: (f, a) => f(...a)
|
|
@@ -578,12 +643,19 @@ var MetadataStore = class {
|
|
|
578
643
|
}
|
|
579
644
|
}
|
|
580
645
|
_getSpace(spaceKey) {
|
|
581
|
-
|
|
582
|
-
if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
|
|
646
|
+
if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
|
|
583
647
|
return this._metadata.identity.haloSpace;
|
|
584
648
|
}
|
|
585
649
|
const space = this.spaces.find((space2) => space2.key === spaceKey);
|
|
586
|
-
(0,
|
|
650
|
+
(0, import_invariant4.invariant)(space, "Space not found", {
|
|
651
|
+
F: __dxlog_file4,
|
|
652
|
+
L: 137,
|
|
653
|
+
S: this,
|
|
654
|
+
A: [
|
|
655
|
+
"space",
|
|
656
|
+
"'Space not found'"
|
|
657
|
+
]
|
|
658
|
+
});
|
|
587
659
|
return space;
|
|
588
660
|
}
|
|
589
661
|
/**
|
|
@@ -591,7 +663,7 @@ var MetadataStore = class {
|
|
|
591
663
|
*/
|
|
592
664
|
async clear() {
|
|
593
665
|
(0, import_log3.log)("clearing all metadata", void 0, {
|
|
594
|
-
F:
|
|
666
|
+
F: __dxlog_file4,
|
|
595
667
|
L: 145,
|
|
596
668
|
S: this,
|
|
597
669
|
C: (f, a) => f(...a)
|
|
@@ -603,14 +675,29 @@ var MetadataStore = class {
|
|
|
603
675
|
return this._metadata.identity;
|
|
604
676
|
}
|
|
605
677
|
async setIdentityRecord(record) {
|
|
606
|
-
(0,
|
|
678
|
+
(0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
|
|
679
|
+
F: __dxlog_file4,
|
|
680
|
+
L: 155,
|
|
681
|
+
S: this,
|
|
682
|
+
A: [
|
|
683
|
+
"!this._metadata.identity",
|
|
684
|
+
"'Cannot overwrite existing identity in metadata'"
|
|
685
|
+
]
|
|
686
|
+
});
|
|
607
687
|
this._metadata.identity = record;
|
|
608
688
|
await this._save();
|
|
609
689
|
}
|
|
610
690
|
async addSpace(record) {
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
691
|
+
(0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
|
|
692
|
+
F: __dxlog_file4,
|
|
693
|
+
L: 162,
|
|
694
|
+
S: this,
|
|
695
|
+
A: [
|
|
696
|
+
"!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
|
|
697
|
+
"'Cannot overwrite existing space in metadata'"
|
|
698
|
+
]
|
|
699
|
+
});
|
|
700
|
+
(this._metadata.spaces ??= []).push(record);
|
|
614
701
|
await this._save();
|
|
615
702
|
}
|
|
616
703
|
async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
|
|
@@ -645,32 +732,40 @@ _ts_decorate2([
|
|
|
645
732
|
var fromBytesInt32 = (buf) => buf.readInt32LE(0);
|
|
646
733
|
|
|
647
734
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
648
|
-
var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
|
|
649
735
|
var import_async4 = require("@dxos/async");
|
|
650
736
|
var import_context3 = require("@dxos/context");
|
|
651
|
-
var
|
|
737
|
+
var import_debug3 = require("@dxos/debug");
|
|
652
738
|
var import_feed_store = require("@dxos/feed-store");
|
|
739
|
+
var import_invariant6 = require("@dxos/invariant");
|
|
653
740
|
var import_keys3 = require("@dxos/keys");
|
|
654
741
|
var import_log6 = require("@dxos/log");
|
|
655
742
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
656
743
|
var import_util4 = require("@dxos/util");
|
|
657
744
|
|
|
658
745
|
// packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
|
|
659
|
-
var
|
|
746
|
+
var import_invariant5 = require("@dxos/invariant");
|
|
660
747
|
var import_log4 = require("@dxos/log");
|
|
661
|
-
var
|
|
748
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
|
|
662
749
|
var createMessageSelector = (timeframeClock) => {
|
|
663
750
|
return (messages) => {
|
|
664
751
|
for (let i = 0; i < messages.length; i++) {
|
|
665
752
|
const { data: { timeframe } } = messages[i];
|
|
666
|
-
(0,
|
|
753
|
+
(0, import_invariant5.invariant)(timeframe, void 0, {
|
|
754
|
+
F: __dxlog_file5,
|
|
755
|
+
L: 25,
|
|
756
|
+
S: void 0,
|
|
757
|
+
A: [
|
|
758
|
+
"timeframe",
|
|
759
|
+
""
|
|
760
|
+
]
|
|
761
|
+
});
|
|
667
762
|
if (!timeframeClock.hasGaps(timeframe)) {
|
|
668
763
|
return i;
|
|
669
764
|
}
|
|
670
765
|
}
|
|
671
766
|
(0, import_log4.log)("Skipping...", void 0, {
|
|
672
|
-
F:
|
|
673
|
-
L:
|
|
767
|
+
F: __dxlog_file5,
|
|
768
|
+
L: 33,
|
|
674
769
|
S: void 0,
|
|
675
770
|
C: (f, a) => f(...a)
|
|
676
771
|
});
|
|
@@ -679,7 +774,7 @@ var createMessageSelector = (timeframeClock) => {
|
|
|
679
774
|
|
|
680
775
|
// packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
|
|
681
776
|
var import_async3 = require("@dxos/async");
|
|
682
|
-
var
|
|
777
|
+
var import_debug2 = require("@dxos/debug");
|
|
683
778
|
var import_log5 = require("@dxos/log");
|
|
684
779
|
var import_timeframe = require("@dxos/timeframe");
|
|
685
780
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
@@ -692,7 +787,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
692
787
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
693
788
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
694
789
|
}
|
|
695
|
-
var
|
|
790
|
+
var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
|
|
696
791
|
var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
|
|
697
792
|
feedKey,
|
|
698
793
|
index
|
|
@@ -751,7 +846,7 @@ var TimeframeClock = class {
|
|
|
751
846
|
target,
|
|
752
847
|
current: this._timeframe
|
|
753
848
|
}, {
|
|
754
|
-
F:
|
|
849
|
+
F: __dxlog_file6,
|
|
755
850
|
L: 73,
|
|
756
851
|
S: this,
|
|
757
852
|
C: (f, a) => f(...a)
|
|
@@ -762,7 +857,7 @@ var TimeframeClock = class {
|
|
|
762
857
|
current: this._timeframe,
|
|
763
858
|
deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
|
|
764
859
|
}, {
|
|
765
|
-
F:
|
|
860
|
+
F: __dxlog_file6,
|
|
766
861
|
L: 75,
|
|
767
862
|
S: this,
|
|
768
863
|
C: (f, a) => f(...a)
|
|
@@ -772,7 +867,7 @@ var TimeframeClock = class {
|
|
|
772
867
|
}
|
|
773
868
|
};
|
|
774
869
|
_ts_decorate3([
|
|
775
|
-
(0,
|
|
870
|
+
(0, import_debug2.timed)(5e3)
|
|
776
871
|
], TimeframeClock.prototype, "waitUntilReached", null);
|
|
777
872
|
|
|
778
873
|
// packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
|
|
@@ -786,7 +881,7 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
786
881
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
787
882
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
788
883
|
}
|
|
789
|
-
var
|
|
884
|
+
var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
|
|
790
885
|
var PipelineState = class {
|
|
791
886
|
// prettier-ignore
|
|
792
887
|
constructor(_feeds, _timeframeClock) {
|
|
@@ -837,18 +932,17 @@ var PipelineState = class {
|
|
|
837
932
|
* @param timeout Timeout in milliseconds to specify the maximum wait time.
|
|
838
933
|
*/
|
|
839
934
|
async waitUntilReachedTargetTimeframe({ ctx = new import_context3.Context(), timeout, breakOnStall = true } = {}) {
|
|
840
|
-
var _a;
|
|
841
935
|
(0, import_log6.log)("waitUntilReachedTargetTimeframe", {
|
|
842
936
|
timeout,
|
|
843
937
|
current: this.timeframe,
|
|
844
938
|
target: this.targetTimeframe
|
|
845
939
|
}, {
|
|
846
|
-
F:
|
|
847
|
-
L:
|
|
940
|
+
F: __dxlog_file7,
|
|
941
|
+
L: 125,
|
|
848
942
|
S: this,
|
|
849
943
|
C: (f, a) => f(...a)
|
|
850
944
|
});
|
|
851
|
-
|
|
945
|
+
this._reachedTargetPromise ??= Promise.race([
|
|
852
946
|
this._timeframeClock.update.waitForCondition(() => {
|
|
853
947
|
return import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
|
|
854
948
|
}),
|
|
@@ -874,8 +968,8 @@ var PipelineState = class {
|
|
|
874
968
|
target: this.targetTimeframe,
|
|
875
969
|
dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
|
|
876
970
|
}, {
|
|
877
|
-
F:
|
|
878
|
-
L:
|
|
971
|
+
F: __dxlog_file7,
|
|
972
|
+
L: 152,
|
|
879
973
|
S: this,
|
|
880
974
|
C: (f, a) => f(...a)
|
|
881
975
|
});
|
|
@@ -895,16 +989,26 @@ var Pipeline = class {
|
|
|
895
989
|
// Waits for the message consumer to process the message and yield control back to the pipeline.
|
|
896
990
|
this._processingTrigger = new import_async4.Trigger().wake();
|
|
897
991
|
this._pauseTrigger = new import_async4.Trigger().wake();
|
|
992
|
+
// Pending downloads.
|
|
993
|
+
this._downloads = new import_util4.ComplexMap((value) => import_keys3.PublicKey.hash(value.key));
|
|
898
994
|
this._isStopping = false;
|
|
899
995
|
this._isStarted = false;
|
|
900
|
-
this.
|
|
996
|
+
this._isBeingConsumed = false;
|
|
901
997
|
this._isPaused = false;
|
|
902
998
|
}
|
|
903
999
|
get state() {
|
|
904
1000
|
return this._state;
|
|
905
1001
|
}
|
|
906
1002
|
get writer() {
|
|
907
|
-
(0,
|
|
1003
|
+
(0, import_invariant6.invariant)(this._writer, "Writer not set.", {
|
|
1004
|
+
F: __dxlog_file7,
|
|
1005
|
+
L: 233,
|
|
1006
|
+
S: this,
|
|
1007
|
+
A: [
|
|
1008
|
+
"this._writer",
|
|
1009
|
+
"'Writer not set.'"
|
|
1010
|
+
]
|
|
1011
|
+
});
|
|
908
1012
|
return this._writer;
|
|
909
1013
|
}
|
|
910
1014
|
hasFeed(feedKey) {
|
|
@@ -920,20 +1024,47 @@ var Pipeline = class {
|
|
|
920
1024
|
if (this._feedSetIterator) {
|
|
921
1025
|
await this._feedSetIterator.addFeed(feed);
|
|
922
1026
|
}
|
|
923
|
-
this.
|
|
1027
|
+
if (this._isStarted && !this._isPaused) {
|
|
1028
|
+
this._setFeedDownloadState(feed);
|
|
1029
|
+
}
|
|
924
1030
|
}
|
|
925
1031
|
setWriteFeed(feed) {
|
|
926
|
-
(0,
|
|
927
|
-
|
|
1032
|
+
(0, import_invariant6.invariant)(!this._writer, "Writer already set.", {
|
|
1033
|
+
F: __dxlog_file7,
|
|
1034
|
+
L: 260,
|
|
1035
|
+
S: this,
|
|
1036
|
+
A: [
|
|
1037
|
+
"!this._writer",
|
|
1038
|
+
"'Writer already set.'"
|
|
1039
|
+
]
|
|
1040
|
+
});
|
|
1041
|
+
(0, import_invariant6.invariant)(feed.properties.writable, "Feed must be writable.", {
|
|
1042
|
+
F: __dxlog_file7,
|
|
1043
|
+
L: 261,
|
|
1044
|
+
S: this,
|
|
1045
|
+
A: [
|
|
1046
|
+
"feed.properties.writable",
|
|
1047
|
+
"'Feed must be writable.'"
|
|
1048
|
+
]
|
|
1049
|
+
});
|
|
928
1050
|
this._writer = createMappedFeedWriter((payload) => ({
|
|
929
1051
|
timeframe: this._timeframeClock.timeframe,
|
|
930
1052
|
payload
|
|
931
1053
|
}), feed.createFeedWriter());
|
|
932
1054
|
}
|
|
933
1055
|
async start() {
|
|
1056
|
+
(0, import_invariant6.invariant)(!this._isStarted, "Pipeline is already started.", {
|
|
1057
|
+
F: __dxlog_file7,
|
|
1058
|
+
L: 274,
|
|
1059
|
+
S: this,
|
|
1060
|
+
A: [
|
|
1061
|
+
"!this._isStarted",
|
|
1062
|
+
"'Pipeline is already started.'"
|
|
1063
|
+
]
|
|
1064
|
+
});
|
|
934
1065
|
(0, import_log6.log)("starting...", void 0, {
|
|
935
|
-
F:
|
|
936
|
-
L:
|
|
1066
|
+
F: __dxlog_file7,
|
|
1067
|
+
L: 275,
|
|
937
1068
|
S: this,
|
|
938
1069
|
C: (f, a) => f(...a)
|
|
939
1070
|
});
|
|
@@ -941,30 +1072,38 @@ var Pipeline = class {
|
|
|
941
1072
|
await this._feedSetIterator.open();
|
|
942
1073
|
this._isStarted = true;
|
|
943
1074
|
(0, import_log6.log)("started", void 0, {
|
|
944
|
-
F:
|
|
945
|
-
L:
|
|
1075
|
+
F: __dxlog_file7,
|
|
1076
|
+
L: 279,
|
|
946
1077
|
S: this,
|
|
947
1078
|
C: (f, a) => f(...a)
|
|
948
1079
|
});
|
|
1080
|
+
if (!this._isPaused) {
|
|
1081
|
+
for (const feed of this._feeds.values()) {
|
|
1082
|
+
this._setFeedDownloadState(feed);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
949
1085
|
}
|
|
950
1086
|
async stop() {
|
|
951
|
-
var _a;
|
|
952
1087
|
(0, import_log6.log)("stopping...", void 0, {
|
|
953
|
-
F:
|
|
954
|
-
L:
|
|
1088
|
+
F: __dxlog_file7,
|
|
1089
|
+
L: 290,
|
|
955
1090
|
S: this,
|
|
956
1091
|
C: (f, a) => f(...a)
|
|
957
1092
|
});
|
|
958
1093
|
this._isStopping = true;
|
|
959
|
-
|
|
1094
|
+
for (const [feed, handle] of this._downloads.entries()) {
|
|
1095
|
+
feed.undownload(handle);
|
|
1096
|
+
}
|
|
1097
|
+
this._downloads.clear();
|
|
1098
|
+
await this._feedSetIterator?.close();
|
|
960
1099
|
await this._processingTrigger.wait();
|
|
961
1100
|
await this._state._ctx.dispose();
|
|
962
1101
|
this._state._ctx = new import_context3.Context();
|
|
963
1102
|
this._state._reachedTargetPromise = void 0;
|
|
964
1103
|
this._isStarted = false;
|
|
965
1104
|
(0, import_log6.log)("stopped", void 0, {
|
|
966
|
-
F:
|
|
967
|
-
L:
|
|
1105
|
+
F: __dxlog_file7,
|
|
1106
|
+
L: 302,
|
|
968
1107
|
S: this,
|
|
969
1108
|
C: (f, a) => f(...a)
|
|
970
1109
|
});
|
|
@@ -974,12 +1113,17 @@ var Pipeline = class {
|
|
|
974
1113
|
* The pipeline will start processing messages AFTER this timeframe.
|
|
975
1114
|
*/
|
|
976
1115
|
async setCursor(timeframe) {
|
|
977
|
-
(0,
|
|
1116
|
+
(0, import_invariant6.invariant)(!this._isStarted || this._isPaused, "Invalid state.", {
|
|
1117
|
+
F: __dxlog_file7,
|
|
1118
|
+
L: 311,
|
|
1119
|
+
S: this,
|
|
1120
|
+
A: [
|
|
1121
|
+
"!this._isStarted || this._isPaused",
|
|
1122
|
+
"'Invalid state.'"
|
|
1123
|
+
]
|
|
1124
|
+
});
|
|
978
1125
|
this._state._startTimeframe = timeframe;
|
|
979
1126
|
this._timeframeClock.setTimeframe(timeframe);
|
|
980
|
-
for (const feed of this._feeds.values()) {
|
|
981
|
-
this._setFeedDownloadState(feed);
|
|
982
|
-
}
|
|
983
1127
|
if (this._feedSetIterator) {
|
|
984
1128
|
await this._feedSetIterator.close();
|
|
985
1129
|
await this._initIterator();
|
|
@@ -990,7 +1134,6 @@ var Pipeline = class {
|
|
|
990
1134
|
* Calling pause while processing will cause a deadlock.
|
|
991
1135
|
*/
|
|
992
1136
|
async pause() {
|
|
993
|
-
(0, import_tiny_invariant6.default)(this._isStarted, "Pipeline is not open.");
|
|
994
1137
|
if (this._isPaused) {
|
|
995
1138
|
return;
|
|
996
1139
|
}
|
|
@@ -999,31 +1142,65 @@ var Pipeline = class {
|
|
|
999
1142
|
this._isPaused = true;
|
|
1000
1143
|
}
|
|
1001
1144
|
async unpause() {
|
|
1002
|
-
(0,
|
|
1003
|
-
|
|
1145
|
+
(0, import_invariant6.invariant)(this._isPaused, "Pipeline is not paused.", {
|
|
1146
|
+
F: __dxlog_file7,
|
|
1147
|
+
L: 340,
|
|
1148
|
+
S: this,
|
|
1149
|
+
A: [
|
|
1150
|
+
"this._isPaused",
|
|
1151
|
+
"'Pipeline is not paused.'"
|
|
1152
|
+
]
|
|
1153
|
+
});
|
|
1004
1154
|
this._pauseTrigger.wake();
|
|
1005
1155
|
this._isPaused = false;
|
|
1156
|
+
for (const feed of this._feeds.values()) {
|
|
1157
|
+
this._setFeedDownloadState(feed);
|
|
1158
|
+
}
|
|
1006
1159
|
}
|
|
1007
1160
|
/**
|
|
1008
1161
|
* Starts to iterate over the ordered messages from the added feeds.
|
|
1009
1162
|
* Updates the timeframe clock after the message has bee processed.
|
|
1010
1163
|
*/
|
|
1011
1164
|
async *consume() {
|
|
1012
|
-
(0,
|
|
1013
|
-
|
|
1014
|
-
|
|
1165
|
+
(0, import_invariant6.invariant)(!this._isBeingConsumed, "Pipeline is already being consumed.", {
|
|
1166
|
+
F: __dxlog_file7,
|
|
1167
|
+
L: 355,
|
|
1168
|
+
S: this,
|
|
1169
|
+
A: [
|
|
1170
|
+
"!this._isBeingConsumed",
|
|
1171
|
+
"'Pipeline is already being consumed.'"
|
|
1172
|
+
]
|
|
1173
|
+
});
|
|
1174
|
+
this._isBeingConsumed = true;
|
|
1175
|
+
(0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
|
|
1176
|
+
F: __dxlog_file7,
|
|
1177
|
+
L: 358,
|
|
1178
|
+
S: this,
|
|
1179
|
+
A: [
|
|
1180
|
+
"this._feedSetIterator",
|
|
1181
|
+
"'Iterator not initialized.'"
|
|
1182
|
+
]
|
|
1183
|
+
});
|
|
1015
1184
|
let lastFeedSetIterator = this._feedSetIterator;
|
|
1016
1185
|
let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1017
1186
|
while (!this._isStopping) {
|
|
1018
1187
|
await this._pauseTrigger.wait();
|
|
1019
1188
|
if (lastFeedSetIterator !== this._feedSetIterator) {
|
|
1020
|
-
(0,
|
|
1189
|
+
(0, import_invariant6.invariant)(this._feedSetIterator, "Iterator not initialized.", {
|
|
1190
|
+
F: __dxlog_file7,
|
|
1191
|
+
L: 367,
|
|
1192
|
+
S: this,
|
|
1193
|
+
A: [
|
|
1194
|
+
"this._feedSetIterator",
|
|
1195
|
+
"'Iterator not initialized.'"
|
|
1196
|
+
]
|
|
1197
|
+
});
|
|
1021
1198
|
lastFeedSetIterator = this._feedSetIterator;
|
|
1022
1199
|
iterable = lastFeedSetIterator[Symbol.asyncIterator]();
|
|
1023
1200
|
}
|
|
1024
1201
|
const { done, value } = await iterable.next();
|
|
1025
1202
|
if (!done) {
|
|
1026
|
-
const block = value
|
|
1203
|
+
const block = value ?? (0, import_debug3.failUndefined)();
|
|
1027
1204
|
this._processingTrigger.reset();
|
|
1028
1205
|
this._timeframeClock.updatePendingTimeframe(import_keys3.PublicKey.from(block.feedKey), block.seq);
|
|
1029
1206
|
yield block;
|
|
@@ -1031,33 +1208,42 @@ var Pipeline = class {
|
|
|
1031
1208
|
this._timeframeClock.updateTimeframe();
|
|
1032
1209
|
}
|
|
1033
1210
|
}
|
|
1034
|
-
this.
|
|
1211
|
+
this._isBeingConsumed = false;
|
|
1035
1212
|
}
|
|
1036
1213
|
_setFeedDownloadState(feed) {
|
|
1037
|
-
|
|
1214
|
+
let handle = this._downloads.get(feed);
|
|
1215
|
+
if (handle) {
|
|
1216
|
+
feed.undownload(handle);
|
|
1217
|
+
}
|
|
1038
1218
|
const timeframe = this._state._startTimeframe;
|
|
1039
|
-
const seq =
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1219
|
+
const seq = timeframe.get(feed.key) ?? -1;
|
|
1220
|
+
(0, import_log6.log)("download", {
|
|
1221
|
+
feed: feed.key.truncate(),
|
|
1222
|
+
seq,
|
|
1223
|
+
length: feed.length
|
|
1224
|
+
}, {
|
|
1225
|
+
F: __dxlog_file7,
|
|
1226
|
+
L: 396,
|
|
1227
|
+
S: this,
|
|
1228
|
+
C: (f, a) => f(...a)
|
|
1047
1229
|
});
|
|
1048
|
-
feed.download({
|
|
1230
|
+
handle = feed.download({
|
|
1049
1231
|
start: seq + 1,
|
|
1050
1232
|
linear: true
|
|
1051
|
-
}
|
|
1052
|
-
(
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1233
|
+
}, (err, data) => {
|
|
1234
|
+
if (err) {
|
|
1235
|
+
} else {
|
|
1236
|
+
import_log6.log.info("downloaded", {
|
|
1237
|
+
data
|
|
1238
|
+
}, {
|
|
1239
|
+
F: __dxlog_file7,
|
|
1240
|
+
L: 401,
|
|
1241
|
+
S: this,
|
|
1242
|
+
C: (f, a) => f(...a)
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1060
1245
|
});
|
|
1246
|
+
this._downloads.set(feed, handle);
|
|
1061
1247
|
}
|
|
1062
1248
|
async _initIterator() {
|
|
1063
1249
|
this._feedSetIterator = new import_feed_store.FeedSetIterator(createMessageSelector(this._timeframeClock), {
|
|
@@ -1066,8 +1252,8 @@ var Pipeline = class {
|
|
|
1066
1252
|
});
|
|
1067
1253
|
this._feedSetIterator.stalled.on((iterator) => {
|
|
1068
1254
|
import_log6.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
|
|
1069
|
-
F:
|
|
1070
|
-
L:
|
|
1255
|
+
F: __dxlog_file7,
|
|
1256
|
+
L: 415,
|
|
1071
1257
|
S: this,
|
|
1072
1258
|
C: (f, a) => f(...a)
|
|
1073
1259
|
});
|
|
@@ -1095,14 +1281,14 @@ _ts_decorate4([
|
|
|
1095
1281
|
], Pipeline.prototype, "unpause", null);
|
|
1096
1282
|
|
|
1097
1283
|
// packages/core/echo/echo-pipeline/src/space/auth.ts
|
|
1098
|
-
var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
|
|
1099
1284
|
var import_async5 = require("@dxos/async");
|
|
1100
1285
|
var import_context4 = require("@dxos/context");
|
|
1101
1286
|
var import_crypto2 = require("@dxos/crypto");
|
|
1287
|
+
var import_invariant7 = require("@dxos/invariant");
|
|
1102
1288
|
var import_log7 = require("@dxos/log");
|
|
1103
1289
|
var import_protocols5 = require("@dxos/protocols");
|
|
1104
1290
|
var import_teleport = require("@dxos/teleport");
|
|
1105
|
-
var
|
|
1291
|
+
var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
|
|
1106
1292
|
var AuthExtension = class extends import_teleport.RpcExtension {
|
|
1107
1293
|
constructor(_authParams) {
|
|
1108
1294
|
super({
|
|
@@ -1118,8 +1304,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1118
1304
|
this._ctx = new import_context4.Context({
|
|
1119
1305
|
onError: (err) => {
|
|
1120
1306
|
import_log7.log.catch(err, void 0, {
|
|
1121
|
-
F:
|
|
1122
|
-
L:
|
|
1307
|
+
F: __dxlog_file8,
|
|
1308
|
+
L: 28,
|
|
1123
1309
|
S: this,
|
|
1124
1310
|
C: (f, a) => f(...a)
|
|
1125
1311
|
});
|
|
@@ -1140,8 +1326,8 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1140
1326
|
};
|
|
1141
1327
|
} catch (err) {
|
|
1142
1328
|
import_log7.log.error("failed to generate auth credentials", err, {
|
|
1143
|
-
F:
|
|
1144
|
-
L:
|
|
1329
|
+
F: __dxlog_file8,
|
|
1330
|
+
L: 55,
|
|
1145
1331
|
S: this,
|
|
1146
1332
|
C: (f, a) => f(...a)
|
|
1147
1333
|
});
|
|
@@ -1159,14 +1345,30 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1159
1345
|
const { credential } = await this.rpc.AuthService.authenticate({
|
|
1160
1346
|
challenge
|
|
1161
1347
|
});
|
|
1162
|
-
(0,
|
|
1348
|
+
(0, import_invariant7.invariant)(credential?.length > 0, "invalid credential", {
|
|
1349
|
+
F: __dxlog_file8,
|
|
1350
|
+
L: 69,
|
|
1351
|
+
S: this,
|
|
1352
|
+
A: [
|
|
1353
|
+
"credential?.length > 0",
|
|
1354
|
+
"'invalid credential'"
|
|
1355
|
+
]
|
|
1356
|
+
});
|
|
1163
1357
|
const success = await this._authParams.verifier(challenge, credential);
|
|
1164
|
-
(0,
|
|
1358
|
+
(0, import_invariant7.invariant)(success, "credential not verified", {
|
|
1359
|
+
F: __dxlog_file8,
|
|
1360
|
+
L: 71,
|
|
1361
|
+
S: this,
|
|
1362
|
+
A: [
|
|
1363
|
+
"success",
|
|
1364
|
+
"'credential not verified'"
|
|
1365
|
+
]
|
|
1366
|
+
});
|
|
1165
1367
|
(0, import_async5.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
|
|
1166
1368
|
} catch (err) {
|
|
1167
1369
|
(0, import_log7.log)("auth failed", err, {
|
|
1168
|
-
F:
|
|
1169
|
-
L:
|
|
1370
|
+
F: __dxlog_file8,
|
|
1371
|
+
L: 74,
|
|
1170
1372
|
S: this,
|
|
1171
1373
|
C: (f, a) => f(...a)
|
|
1172
1374
|
});
|
|
@@ -1182,25 +1384,40 @@ var AuthExtension = class extends import_teleport.RpcExtension {
|
|
|
1182
1384
|
};
|
|
1183
1385
|
|
|
1184
1386
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1185
|
-
var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
|
|
1186
1387
|
var import_async7 = require("@dxos/async");
|
|
1388
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
1187
1389
|
var import_log10 = require("@dxos/log");
|
|
1188
1390
|
var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1391
|
+
var import_tracing3 = require("@dxos/tracing");
|
|
1189
1392
|
var import_util7 = require("@dxos/util");
|
|
1190
1393
|
|
|
1191
1394
|
// packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
|
|
1395
|
+
var import_context5 = require("@dxos/context");
|
|
1192
1396
|
var import_credentials = require("@dxos/credentials");
|
|
1193
1397
|
var import_keys4 = require("@dxos/keys");
|
|
1194
1398
|
var import_log8 = require("@dxos/log");
|
|
1195
1399
|
var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
1196
1400
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
1401
|
+
var import_tracing = require("@dxos/tracing");
|
|
1197
1402
|
var import_util5 = require("@dxos/util");
|
|
1198
|
-
|
|
1403
|
+
function _ts_decorate5(decorators, target, key, desc) {
|
|
1404
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1405
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1406
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
1407
|
+
else
|
|
1408
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
1409
|
+
if (d = decorators[i])
|
|
1410
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1411
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1412
|
+
}
|
|
1413
|
+
var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
|
|
1199
1414
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
|
|
1200
|
-
var ControlPipeline = class {
|
|
1415
|
+
var ControlPipeline = class ControlPipeline2 {
|
|
1201
1416
|
constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
|
|
1202
1417
|
this._lastTimeframeSaveTime = Date.now();
|
|
1203
1418
|
this.onFeedAdmitted = new import_util5.Callback();
|
|
1419
|
+
this._usage = new import_tracing.TimeUsageCounter();
|
|
1420
|
+
this._mutations = new import_tracing.TimeSeriesCounter();
|
|
1204
1421
|
this._spaceKey = spaceKey;
|
|
1205
1422
|
this._metadata = metadataStore;
|
|
1206
1423
|
this._pipeline = new Pipeline();
|
|
@@ -1210,8 +1427,8 @@ var ControlPipeline = class {
|
|
|
1210
1427
|
(0, import_log8.log)("feed admitted", {
|
|
1211
1428
|
key: info.key
|
|
1212
1429
|
}, {
|
|
1213
|
-
F:
|
|
1214
|
-
L:
|
|
1430
|
+
F: __dxlog_file9,
|
|
1431
|
+
L: 61,
|
|
1215
1432
|
S: this,
|
|
1216
1433
|
C: (f, a) => f(...a)
|
|
1217
1434
|
});
|
|
@@ -1221,8 +1438,8 @@ var ControlPipeline = class {
|
|
|
1221
1438
|
await this._pipeline.addFeed(feed);
|
|
1222
1439
|
} catch (err) {
|
|
1223
1440
|
import_log8.log.catch(err, void 0, {
|
|
1224
|
-
F:
|
|
1225
|
-
L:
|
|
1441
|
+
F: __dxlog_file9,
|
|
1442
|
+
L: 69,
|
|
1226
1443
|
S: this,
|
|
1227
1444
|
C: (f, a) => f(...a)
|
|
1228
1445
|
});
|
|
@@ -1244,57 +1461,66 @@ var ControlPipeline = class {
|
|
|
1244
1461
|
}
|
|
1245
1462
|
async start() {
|
|
1246
1463
|
(0, import_log8.log)("starting...", void 0, {
|
|
1247
|
-
F:
|
|
1248
|
-
L:
|
|
1464
|
+
F: __dxlog_file9,
|
|
1465
|
+
L: 93,
|
|
1249
1466
|
S: this,
|
|
1250
1467
|
C: (f, a) => f(...a)
|
|
1251
1468
|
});
|
|
1252
1469
|
setTimeout(async () => {
|
|
1253
|
-
|
|
1254
|
-
try {
|
|
1255
|
-
(0, import_log8.log)("processing", {
|
|
1256
|
-
key: msg.feedKey,
|
|
1257
|
-
seq: msg.seq
|
|
1258
|
-
}, {
|
|
1259
|
-
F: __dxlog_file8,
|
|
1260
|
-
L: 88,
|
|
1261
|
-
S: this,
|
|
1262
|
-
C: (f, a) => f(...a)
|
|
1263
|
-
});
|
|
1264
|
-
if (msg.data.payload.credential) {
|
|
1265
|
-
const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
|
|
1266
|
-
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
|
|
1267
|
-
timer.end();
|
|
1268
|
-
if (!result) {
|
|
1269
|
-
import_log8.log.warn("processing failed", {
|
|
1270
|
-
msg
|
|
1271
|
-
}, {
|
|
1272
|
-
F: __dxlog_file8,
|
|
1273
|
-
L: 98,
|
|
1274
|
-
S: this,
|
|
1275
|
-
C: (f, a) => f(...a)
|
|
1276
|
-
});
|
|
1277
|
-
} else {
|
|
1278
|
-
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1279
|
-
}
|
|
1280
|
-
}
|
|
1281
|
-
} catch (err) {
|
|
1282
|
-
import_log8.log.catch(err, void 0, {
|
|
1283
|
-
F: __dxlog_file8,
|
|
1284
|
-
L: 104,
|
|
1285
|
-
S: this,
|
|
1286
|
-
C: (f, a) => f(...a)
|
|
1287
|
-
});
|
|
1288
|
-
}
|
|
1289
|
-
}
|
|
1470
|
+
void this._consumePipeline(new import_context5.Context());
|
|
1290
1471
|
});
|
|
1291
1472
|
await this._pipeline.start();
|
|
1292
1473
|
(0, import_log8.log)("started", void 0, {
|
|
1293
|
-
F:
|
|
1294
|
-
L:
|
|
1474
|
+
F: __dxlog_file9,
|
|
1475
|
+
L: 99,
|
|
1476
|
+
S: this,
|
|
1477
|
+
C: (f, a) => f(...a)
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
async _consumePipeline(ctx) {
|
|
1481
|
+
for await (const msg of this._pipeline.consume()) {
|
|
1482
|
+
const span = this._usage.beginRecording();
|
|
1483
|
+
this._mutations.inc();
|
|
1484
|
+
try {
|
|
1485
|
+
await this._processMessage(ctx, msg);
|
|
1486
|
+
} catch (err) {
|
|
1487
|
+
import_log8.log.catch(err, void 0, {
|
|
1488
|
+
F: __dxlog_file9,
|
|
1489
|
+
L: 111,
|
|
1490
|
+
S: this,
|
|
1491
|
+
C: (f, a) => f(...a)
|
|
1492
|
+
});
|
|
1493
|
+
}
|
|
1494
|
+
span.end();
|
|
1495
|
+
}
|
|
1496
|
+
}
|
|
1497
|
+
async _processMessage(ctx, msg) {
|
|
1498
|
+
(0, import_log8.log)("processing", {
|
|
1499
|
+
key: msg.feedKey,
|
|
1500
|
+
seq: msg.seq
|
|
1501
|
+
}, {
|
|
1502
|
+
F: __dxlog_file9,
|
|
1503
|
+
L: 121,
|
|
1295
1504
|
S: this,
|
|
1296
1505
|
C: (f, a) => f(...a)
|
|
1297
1506
|
});
|
|
1507
|
+
if (msg.data.payload.credential) {
|
|
1508
|
+
const timer = import_util5.tracer.mark("dxos.echo.pipeline.control");
|
|
1509
|
+
const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
|
|
1510
|
+
timer.end();
|
|
1511
|
+
if (!result) {
|
|
1512
|
+
import_log8.log.warn("processing failed", {
|
|
1513
|
+
msg
|
|
1514
|
+
}, {
|
|
1515
|
+
F: __dxlog_file9,
|
|
1516
|
+
L: 131,
|
|
1517
|
+
S: this,
|
|
1518
|
+
C: (f, a) => f(...a)
|
|
1519
|
+
});
|
|
1520
|
+
} else {
|
|
1521
|
+
await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1298
1524
|
}
|
|
1299
1525
|
async _noteTargetStateIfNeeded(timeframe) {
|
|
1300
1526
|
if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL) {
|
|
@@ -1304,48 +1530,63 @@ var ControlPipeline = class {
|
|
|
1304
1530
|
}
|
|
1305
1531
|
async stop() {
|
|
1306
1532
|
(0, import_log8.log)("stopping...", void 0, {
|
|
1307
|
-
F:
|
|
1308
|
-
L:
|
|
1533
|
+
F: __dxlog_file9,
|
|
1534
|
+
L: 149,
|
|
1309
1535
|
S: this,
|
|
1310
1536
|
C: (f, a) => f(...a)
|
|
1311
1537
|
});
|
|
1312
1538
|
await this._pipeline.stop();
|
|
1313
1539
|
await this._saveTargetTimeframe(this._pipeline.state.timeframe);
|
|
1314
1540
|
(0, import_log8.log)("stopped", void 0, {
|
|
1315
|
-
F:
|
|
1316
|
-
L:
|
|
1541
|
+
F: __dxlog_file9,
|
|
1542
|
+
L: 152,
|
|
1317
1543
|
S: this,
|
|
1318
1544
|
C: (f, a) => f(...a)
|
|
1319
1545
|
});
|
|
1320
1546
|
}
|
|
1321
1547
|
async _saveTargetTimeframe(timeframe) {
|
|
1322
|
-
var _a;
|
|
1323
1548
|
try {
|
|
1324
|
-
const newTimeframe = import_timeframe3.Timeframe.merge(
|
|
1549
|
+
const newTimeframe = import_timeframe3.Timeframe.merge(this._targetTimeframe ?? new import_timeframe3.Timeframe(), timeframe);
|
|
1325
1550
|
await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
|
|
1326
1551
|
this._targetTimeframe = newTimeframe;
|
|
1327
1552
|
} catch (err) {
|
|
1328
1553
|
(0, import_log8.log)(err, void 0, {
|
|
1329
|
-
F:
|
|
1330
|
-
L:
|
|
1554
|
+
F: __dxlog_file9,
|
|
1555
|
+
L: 161,
|
|
1331
1556
|
S: this,
|
|
1332
1557
|
C: (f, a) => f(...a)
|
|
1333
1558
|
});
|
|
1334
1559
|
}
|
|
1335
1560
|
}
|
|
1336
1561
|
};
|
|
1562
|
+
_ts_decorate5([
|
|
1563
|
+
import_tracing.trace.metricsCounter()
|
|
1564
|
+
], ControlPipeline.prototype, "_usage", void 0);
|
|
1565
|
+
_ts_decorate5([
|
|
1566
|
+
import_tracing.trace.metricsCounter()
|
|
1567
|
+
], ControlPipeline.prototype, "_mutations", void 0);
|
|
1568
|
+
_ts_decorate5([
|
|
1569
|
+
import_tracing.trace.span()
|
|
1570
|
+
], ControlPipeline.prototype, "_consumePipeline", null);
|
|
1571
|
+
_ts_decorate5([
|
|
1572
|
+
import_tracing.trace.span()
|
|
1573
|
+
], ControlPipeline.prototype, "_processMessage", null);
|
|
1574
|
+
ControlPipeline = _ts_decorate5([
|
|
1575
|
+
import_tracing.trace.resource()
|
|
1576
|
+
], ControlPipeline);
|
|
1337
1577
|
|
|
1338
1578
|
// packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
|
|
1339
|
-
var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
|
|
1340
1579
|
var import_async6 = require("@dxos/async");
|
|
1341
|
-
var
|
|
1580
|
+
var import_context6 = require("@dxos/context");
|
|
1342
1581
|
var import_credentials3 = require("@dxos/credentials");
|
|
1343
1582
|
var import_echo_db3 = require("@dxos/echo-db");
|
|
1344
1583
|
var import_errors2 = require("@dxos/errors");
|
|
1584
|
+
var import_invariant8 = require("@dxos/invariant");
|
|
1345
1585
|
var import_log9 = require("@dxos/log");
|
|
1346
1586
|
var import_timeframe4 = require("@dxos/timeframe");
|
|
1587
|
+
var import_tracing2 = require("@dxos/tracing");
|
|
1347
1588
|
var import_util6 = require("@dxos/util");
|
|
1348
|
-
function
|
|
1589
|
+
function _ts_decorate6(decorators, target, key, desc) {
|
|
1349
1590
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1350
1591
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1351
1592
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1355,14 +1596,14 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
1355
1596
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1356
1597
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1357
1598
|
}
|
|
1358
|
-
var
|
|
1599
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
|
|
1359
1600
|
var MESSAGES_PER_SNAPSHOT = 10;
|
|
1360
1601
|
var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
|
|
1361
1602
|
var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
|
|
1362
1603
|
var DataPipeline = class DataPipeline2 {
|
|
1363
1604
|
constructor(_params) {
|
|
1364
1605
|
this._params = _params;
|
|
1365
|
-
this._ctx = new
|
|
1606
|
+
this._ctx = new import_context6.Context();
|
|
1366
1607
|
this._pipeline = void 0;
|
|
1367
1608
|
this._targetTimeframe = void 0;
|
|
1368
1609
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
|
|
@@ -1370,6 +1611,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1370
1611
|
this._lastTimeframeSaveTime = 0;
|
|
1371
1612
|
this._lastSnapshotSaveTime = 0;
|
|
1372
1613
|
this._lastProcessedEpoch = -1;
|
|
1614
|
+
this._usage = new import_tracing2.TimeUsageCounter();
|
|
1615
|
+
this._mutations = new import_tracing2.TimeSeriesCounter();
|
|
1373
1616
|
this.currentEpoch = void 0;
|
|
1374
1617
|
this.appliedEpoch = void 0;
|
|
1375
1618
|
this.onNewEpoch = new import_async6.Event();
|
|
@@ -1381,13 +1624,11 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1381
1624
|
return this._pipeline;
|
|
1382
1625
|
}
|
|
1383
1626
|
get pipelineState() {
|
|
1384
|
-
|
|
1385
|
-
return (_a = this._pipeline) == null ? void 0 : _a.state;
|
|
1627
|
+
return this._pipeline?.state;
|
|
1386
1628
|
}
|
|
1387
1629
|
setTargetTimeframe(timeframe) {
|
|
1388
|
-
var _a;
|
|
1389
1630
|
this._targetTimeframe = timeframe;
|
|
1390
|
-
|
|
1631
|
+
this._pipeline?.state.setTargetTimeframe(timeframe);
|
|
1391
1632
|
}
|
|
1392
1633
|
async processCredential(credential) {
|
|
1393
1634
|
if (!(0, import_credentials3.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
@@ -1404,15 +1645,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1404
1645
|
}
|
|
1405
1646
|
this._pipeline = new Pipeline();
|
|
1406
1647
|
await this._params.onPipelineCreated(this._pipeline);
|
|
1407
|
-
await this._pipeline.start();
|
|
1408
1648
|
await this._pipeline.pause();
|
|
1649
|
+
await this._pipeline.start();
|
|
1409
1650
|
if (this._targetTimeframe) {
|
|
1410
1651
|
this._pipeline.state.setTargetTimeframe(this._targetTimeframe);
|
|
1411
1652
|
}
|
|
1412
1653
|
const feedWriter = {
|
|
1413
1654
|
write: (data, options) => {
|
|
1414
|
-
(0,
|
|
1415
|
-
|
|
1655
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1656
|
+
F: __dxlog_file10,
|
|
1657
|
+
L: 154,
|
|
1658
|
+
S: this,
|
|
1659
|
+
A: [
|
|
1660
|
+
"this._pipeline",
|
|
1661
|
+
"'Pipeline is not initialized.'"
|
|
1662
|
+
]
|
|
1663
|
+
});
|
|
1664
|
+
(0, import_invariant8.invariant)(this.currentEpoch, "Epoch is not initialized.", {
|
|
1665
|
+
F: __dxlog_file10,
|
|
1666
|
+
L: 155,
|
|
1667
|
+
S: this,
|
|
1668
|
+
A: [
|
|
1669
|
+
"this.currentEpoch",
|
|
1670
|
+
"'Epoch is not initialized.'"
|
|
1671
|
+
]
|
|
1672
|
+
});
|
|
1416
1673
|
return this._pipeline.writer.write({
|
|
1417
1674
|
data
|
|
1418
1675
|
}, options);
|
|
@@ -1427,19 +1684,18 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1427
1684
|
this._isOpen = true;
|
|
1428
1685
|
}
|
|
1429
1686
|
async close() {
|
|
1430
|
-
var _a, _b, _c;
|
|
1431
1687
|
if (!this._isOpen) {
|
|
1432
1688
|
return;
|
|
1433
1689
|
}
|
|
1434
1690
|
(0, import_log9.log)("close", void 0, {
|
|
1435
|
-
F:
|
|
1436
|
-
L:
|
|
1691
|
+
F: __dxlog_file10,
|
|
1692
|
+
L: 179,
|
|
1437
1693
|
S: this,
|
|
1438
1694
|
C: (f, a) => f(...a)
|
|
1439
1695
|
});
|
|
1440
1696
|
this._isOpen = false;
|
|
1441
1697
|
await this._ctx.dispose();
|
|
1442
|
-
await
|
|
1698
|
+
await this._pipeline?.stop();
|
|
1443
1699
|
try {
|
|
1444
1700
|
await this._saveCache();
|
|
1445
1701
|
if (this._pipeline) {
|
|
@@ -1447,15 +1703,15 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1447
1703
|
}
|
|
1448
1704
|
} catch (err) {
|
|
1449
1705
|
import_log9.log.catch(err, void 0, {
|
|
1450
|
-
F:
|
|
1451
|
-
L:
|
|
1706
|
+
F: __dxlog_file10,
|
|
1707
|
+
L: 192,
|
|
1452
1708
|
S: this,
|
|
1453
1709
|
C: (f, a) => f(...a)
|
|
1454
1710
|
});
|
|
1455
1711
|
}
|
|
1456
|
-
await
|
|
1457
|
-
await
|
|
1458
|
-
this._ctx = new
|
|
1712
|
+
await this.databaseHost?.close();
|
|
1713
|
+
await this.itemManager?.destroy();
|
|
1714
|
+
this._ctx = new import_context6.Context();
|
|
1459
1715
|
this._pipeline = void 0;
|
|
1460
1716
|
this._targetTimeframe = void 0;
|
|
1461
1717
|
this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
|
|
@@ -1470,15 +1726,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1470
1726
|
await this._processEpochInSeparateTask(this.currentEpoch);
|
|
1471
1727
|
await waitForOneEpoch;
|
|
1472
1728
|
}
|
|
1473
|
-
(0,
|
|
1729
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1730
|
+
F: __dxlog_file10,
|
|
1731
|
+
L: 215,
|
|
1732
|
+
S: this,
|
|
1733
|
+
A: [
|
|
1734
|
+
"this._pipeline",
|
|
1735
|
+
"'Pipeline is not initialized.'"
|
|
1736
|
+
]
|
|
1737
|
+
});
|
|
1474
1738
|
for await (const msg of this._pipeline.consume()) {
|
|
1739
|
+
const span = this._usage.beginRecording();
|
|
1740
|
+
this._mutations.inc();
|
|
1475
1741
|
const { feedKey, seq, data } = msg;
|
|
1476
1742
|
(0, import_log9.log)("processing message", {
|
|
1477
1743
|
feedKey,
|
|
1478
1744
|
seq
|
|
1479
1745
|
}, {
|
|
1480
|
-
F:
|
|
1481
|
-
L:
|
|
1746
|
+
F: __dxlog_file10,
|
|
1747
|
+
L: 221,
|
|
1482
1748
|
S: this,
|
|
1483
1749
|
C: (f, a) => f(...a)
|
|
1484
1750
|
});
|
|
@@ -1489,8 +1755,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1489
1755
|
import_log9.log.warn("Could not find feed", {
|
|
1490
1756
|
feedKey
|
|
1491
1757
|
}, {
|
|
1492
|
-
F:
|
|
1493
|
-
L:
|
|
1758
|
+
F: __dxlog_file10,
|
|
1759
|
+
L: 227,
|
|
1494
1760
|
S: this,
|
|
1495
1761
|
C: (f, a) => f(...a)
|
|
1496
1762
|
});
|
|
@@ -1512,8 +1778,8 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1512
1778
|
seq,
|
|
1513
1779
|
spaceKey: this._params.spaceKey.toHex()
|
|
1514
1780
|
}, {
|
|
1515
|
-
F:
|
|
1516
|
-
L:
|
|
1781
|
+
F: __dxlog_file10,
|
|
1782
|
+
L: 244,
|
|
1517
1783
|
S: this,
|
|
1518
1784
|
C: (f, a) => f(...a)
|
|
1519
1785
|
});
|
|
@@ -1521,16 +1787,25 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1521
1787
|
}
|
|
1522
1788
|
} catch (err) {
|
|
1523
1789
|
import_log9.log.catch(err, void 0, {
|
|
1524
|
-
F:
|
|
1525
|
-
L:
|
|
1790
|
+
F: __dxlog_file10,
|
|
1791
|
+
L: 254,
|
|
1526
1792
|
S: this,
|
|
1527
1793
|
C: (f, a) => f(...a)
|
|
1528
1794
|
});
|
|
1529
1795
|
}
|
|
1796
|
+
span.end();
|
|
1530
1797
|
}
|
|
1531
1798
|
}
|
|
1532
1799
|
_createSnapshot() {
|
|
1533
|
-
(0,
|
|
1800
|
+
(0, import_invariant8.invariant)(this.databaseHost, "Database backend is not initialized.", {
|
|
1801
|
+
F: __dxlog_file10,
|
|
1802
|
+
L: 262,
|
|
1803
|
+
S: this,
|
|
1804
|
+
A: [
|
|
1805
|
+
"this.databaseHost",
|
|
1806
|
+
"'Database backend is not initialized.'"
|
|
1807
|
+
]
|
|
1808
|
+
});
|
|
1534
1809
|
return {
|
|
1535
1810
|
spaceKey: this._params.spaceKey.asUint8Array(),
|
|
1536
1811
|
timeframe: this._pipeline.state.timeframe,
|
|
@@ -1538,26 +1813,22 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1538
1813
|
};
|
|
1539
1814
|
}
|
|
1540
1815
|
async _saveTargetTimeframe(timeframe) {
|
|
1541
|
-
|
|
1542
|
-
const newTimeframe = import_timeframe4.Timeframe.merge((_a = this._targetTimeframe) != null ? _a : new import_timeframe4.Timeframe(), timeframe);
|
|
1816
|
+
const newTimeframe = import_timeframe4.Timeframe.merge(this._targetTimeframe ?? new import_timeframe4.Timeframe(), timeframe);
|
|
1543
1817
|
await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
|
|
1544
1818
|
this._targetTimeframe = newTimeframe;
|
|
1545
1819
|
}
|
|
1546
1820
|
async _saveCache() {
|
|
1547
|
-
var _a;
|
|
1548
1821
|
const cache = {};
|
|
1549
1822
|
try {
|
|
1550
|
-
const propertiesItem = this.itemManager.items.find((item) =>
|
|
1551
|
-
|
|
1552
|
-
return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = (0, import_echo_db3.getStateMachineFromItem)(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
|
|
1553
|
-
});
|
|
1823
|
+
const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
|
|
1824
|
+
((0, import_echo_db3.getStateMachineFromItem)(item)?.snapshot()).type === import_echo_db3.TYPE_PROPERTIES);
|
|
1554
1825
|
if (propertiesItem) {
|
|
1555
|
-
cache.properties = (
|
|
1826
|
+
cache.properties = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)?.snapshot();
|
|
1556
1827
|
}
|
|
1557
1828
|
} catch (err) {
|
|
1558
1829
|
import_log9.log.warn("Failed to cache properties", err, {
|
|
1559
|
-
F:
|
|
1560
|
-
L:
|
|
1830
|
+
F: __dxlog_file10,
|
|
1831
|
+
L: 291,
|
|
1561
1832
|
S: this,
|
|
1562
1833
|
C: (f, a) => f(...a)
|
|
1563
1834
|
});
|
|
@@ -1574,24 +1845,23 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1574
1845
|
}
|
|
1575
1846
|
}
|
|
1576
1847
|
async _processEpochInSeparateTask(epoch) {
|
|
1577
|
-
var _a;
|
|
1578
1848
|
if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
|
|
1579
1849
|
return;
|
|
1580
1850
|
}
|
|
1581
|
-
await
|
|
1582
|
-
const ctx = new
|
|
1851
|
+
await this._epochCtx?.dispose();
|
|
1852
|
+
const ctx = new import_context6.Context({
|
|
1583
1853
|
onError: (err) => {
|
|
1584
1854
|
if (err instanceof import_errors2.CancelledError) {
|
|
1585
1855
|
(0, import_log9.log)("Epoch processing cancelled.", void 0, {
|
|
1586
|
-
F:
|
|
1587
|
-
L:
|
|
1856
|
+
F: __dxlog_file10,
|
|
1857
|
+
L: 323,
|
|
1588
1858
|
S: this,
|
|
1589
1859
|
C: (f, a) => f(...a)
|
|
1590
1860
|
});
|
|
1591
1861
|
} else {
|
|
1592
1862
|
import_log9.log.catch(err, void 0, {
|
|
1593
|
-
F:
|
|
1594
|
-
L:
|
|
1863
|
+
F: __dxlog_file10,
|
|
1864
|
+
L: 325,
|
|
1595
1865
|
S: this,
|
|
1596
1866
|
C: (f, a) => f(...a)
|
|
1597
1867
|
});
|
|
@@ -1603,28 +1873,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1603
1873
|
if (!this._isOpen) {
|
|
1604
1874
|
return;
|
|
1605
1875
|
}
|
|
1606
|
-
(0, import_log9.log)("process epoch", {
|
|
1607
|
-
epoch
|
|
1608
|
-
}, {
|
|
1609
|
-
F: __dxlog_file9,
|
|
1610
|
-
L: 322,
|
|
1611
|
-
S: this,
|
|
1612
|
-
C: (f, a) => f(...a)
|
|
1613
|
-
});
|
|
1614
1876
|
await this._processEpoch(ctx, epoch.subject.assertion);
|
|
1615
1877
|
this.appliedEpoch = epoch;
|
|
1616
1878
|
this.onNewEpoch.emit(epoch);
|
|
1617
1879
|
});
|
|
1618
1880
|
}
|
|
1619
1881
|
async _processEpoch(ctx, epoch) {
|
|
1620
|
-
(0,
|
|
1621
|
-
|
|
1882
|
+
(0, import_invariant8.invariant)(this._isOpen, "Space is closed.", {
|
|
1883
|
+
F: __dxlog_file10,
|
|
1884
|
+
L: 344,
|
|
1885
|
+
S: this,
|
|
1886
|
+
A: [
|
|
1887
|
+
"this._isOpen",
|
|
1888
|
+
"'Space is closed.'"
|
|
1889
|
+
]
|
|
1890
|
+
});
|
|
1891
|
+
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1892
|
+
F: __dxlog_file10,
|
|
1893
|
+
L: 345,
|
|
1894
|
+
S: this,
|
|
1895
|
+
A: [
|
|
1896
|
+
"this._pipeline",
|
|
1897
|
+
""
|
|
1898
|
+
]
|
|
1899
|
+
});
|
|
1622
1900
|
this._lastProcessedEpoch = epoch.number;
|
|
1623
|
-
(0, import_log9.log)("
|
|
1624
|
-
epoch
|
|
1901
|
+
(0, import_log9.log)("processing", {
|
|
1902
|
+
epoch: (0, import_log9.omit)(epoch, "proof")
|
|
1625
1903
|
}, {
|
|
1626
|
-
F:
|
|
1627
|
-
L:
|
|
1904
|
+
F: __dxlog_file10,
|
|
1905
|
+
L: 348,
|
|
1628
1906
|
S: this,
|
|
1629
1907
|
C: (f, a) => f(...a)
|
|
1630
1908
|
});
|
|
@@ -1632,9 +1910,9 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1632
1910
|
const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
|
|
1633
1911
|
this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
|
|
1634
1912
|
}
|
|
1635
|
-
(0, import_log9.log)("restarting pipeline
|
|
1636
|
-
F:
|
|
1637
|
-
L:
|
|
1913
|
+
(0, import_log9.log)("restarting pipeline from epoch", void 0, {
|
|
1914
|
+
F: __dxlog_file10,
|
|
1915
|
+
L: 354,
|
|
1638
1916
|
S: this,
|
|
1639
1917
|
C: (f, a) => f(...a)
|
|
1640
1918
|
});
|
|
@@ -1643,12 +1921,36 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1643
1921
|
await this._pipeline.unpause();
|
|
1644
1922
|
}
|
|
1645
1923
|
async waitUntilTimeframe(timeframe) {
|
|
1646
|
-
(0,
|
|
1924
|
+
(0, import_invariant8.invariant)(this._pipeline, "Pipeline is not initialized.", {
|
|
1925
|
+
F: __dxlog_file10,
|
|
1926
|
+
L: 361,
|
|
1927
|
+
S: this,
|
|
1928
|
+
A: [
|
|
1929
|
+
"this._pipeline",
|
|
1930
|
+
"'Pipeline is not initialized.'"
|
|
1931
|
+
]
|
|
1932
|
+
});
|
|
1647
1933
|
await this._pipeline.state.waitUntilTimeframe(timeframe);
|
|
1648
1934
|
}
|
|
1649
1935
|
async createEpoch() {
|
|
1650
|
-
(0,
|
|
1651
|
-
|
|
1936
|
+
(0, import_invariant8.invariant)(this._pipeline, void 0, {
|
|
1937
|
+
F: __dxlog_file10,
|
|
1938
|
+
L: 367,
|
|
1939
|
+
S: this,
|
|
1940
|
+
A: [
|
|
1941
|
+
"this._pipeline",
|
|
1942
|
+
""
|
|
1943
|
+
]
|
|
1944
|
+
});
|
|
1945
|
+
(0, import_invariant8.invariant)(this.currentEpoch, void 0, {
|
|
1946
|
+
F: __dxlog_file10,
|
|
1947
|
+
L: 368,
|
|
1948
|
+
S: this,
|
|
1949
|
+
A: [
|
|
1950
|
+
"this.currentEpoch",
|
|
1951
|
+
""
|
|
1952
|
+
]
|
|
1953
|
+
});
|
|
1652
1954
|
await this._pipeline.pause();
|
|
1653
1955
|
const snapshot = await this._createSnapshot();
|
|
1654
1956
|
const snapshotCid = await this._params.snapshotManager.store(snapshot);
|
|
@@ -1665,24 +1967,31 @@ var DataPipeline = class DataPipeline2 {
|
|
|
1665
1967
|
await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
|
|
1666
1968
|
}
|
|
1667
1969
|
};
|
|
1668
|
-
|
|
1970
|
+
_ts_decorate6([
|
|
1971
|
+
import_tracing2.trace.metricsCounter()
|
|
1972
|
+
], DataPipeline.prototype, "_usage", void 0);
|
|
1973
|
+
_ts_decorate6([
|
|
1974
|
+
import_tracing2.trace.metricsCounter()
|
|
1975
|
+
], DataPipeline.prototype, "_mutations", void 0);
|
|
1976
|
+
_ts_decorate6([
|
|
1669
1977
|
import_async6.synchronized
|
|
1670
1978
|
], DataPipeline.prototype, "open", null);
|
|
1671
|
-
|
|
1979
|
+
_ts_decorate6([
|
|
1672
1980
|
import_async6.synchronized
|
|
1673
1981
|
], DataPipeline.prototype, "close", null);
|
|
1674
|
-
|
|
1982
|
+
_ts_decorate6([
|
|
1675
1983
|
import_async6.synchronized
|
|
1676
1984
|
], DataPipeline.prototype, "_processEpoch", null);
|
|
1677
|
-
|
|
1985
|
+
_ts_decorate6([
|
|
1678
1986
|
import_async6.synchronized
|
|
1679
1987
|
], DataPipeline.prototype, "createEpoch", null);
|
|
1680
|
-
DataPipeline =
|
|
1681
|
-
(0, import_async6.trackLeaks)("open", "close")
|
|
1988
|
+
DataPipeline = _ts_decorate6([
|
|
1989
|
+
(0, import_async6.trackLeaks)("open", "close"),
|
|
1990
|
+
import_tracing2.trace.resource()
|
|
1682
1991
|
], DataPipeline);
|
|
1683
1992
|
|
|
1684
1993
|
// packages/core/echo/echo-pipeline/src/space/space.ts
|
|
1685
|
-
function
|
|
1994
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
1686
1995
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1687
1996
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1688
1997
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1692,14 +2001,22 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
1692
2001
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1693
2002
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1694
2003
|
}
|
|
1695
|
-
var
|
|
2004
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
|
|
1696
2005
|
var Space = class Space2 {
|
|
1697
2006
|
constructor(params) {
|
|
1698
2007
|
this._addFeedLock = new import_async7.Lock();
|
|
1699
2008
|
this.onCredentialProcessed = new import_util7.Callback();
|
|
1700
2009
|
this.stateUpdate = new import_async7.Event();
|
|
1701
2010
|
this._isOpen = false;
|
|
1702
|
-
(0,
|
|
2011
|
+
(0, import_invariant9.invariant)(params.spaceKey && params.feedProvider, void 0, {
|
|
2012
|
+
F: __dxlog_file11,
|
|
2013
|
+
L: 73,
|
|
2014
|
+
S: this,
|
|
2015
|
+
A: [
|
|
2016
|
+
"params.spaceKey && params.feedProvider",
|
|
2017
|
+
""
|
|
2018
|
+
]
|
|
2019
|
+
});
|
|
1703
2020
|
this._key = params.spaceKey;
|
|
1704
2021
|
this._genesisFeedKey = params.genesisFeed.key;
|
|
1705
2022
|
this._feedProvider = params.feedProvider;
|
|
@@ -1734,8 +2051,8 @@ var Space = class Space2 {
|
|
|
1734
2051
|
(0, import_log10.log)("onCredentialProcessed", {
|
|
1735
2052
|
credential
|
|
1736
2053
|
}, {
|
|
1737
|
-
F:
|
|
1738
|
-
L:
|
|
2054
|
+
F: __dxlog_file11,
|
|
2055
|
+
L: 109,
|
|
1739
2056
|
S: this,
|
|
1740
2057
|
C: (f, a) => f(...a)
|
|
1741
2058
|
});
|
|
@@ -1777,12 +2094,10 @@ var Space = class Space2 {
|
|
|
1777
2094
|
return this._genesisFeedKey;
|
|
1778
2095
|
}
|
|
1779
2096
|
get controlFeedKey() {
|
|
1780
|
-
|
|
1781
|
-
return (_a = this._controlFeed) == null ? void 0 : _a.key;
|
|
2097
|
+
return this._controlFeed?.key;
|
|
1782
2098
|
}
|
|
1783
2099
|
get dataFeedKey() {
|
|
1784
|
-
|
|
1785
|
-
return (_a = this._dataFeed) == null ? void 0 : _a.key;
|
|
2100
|
+
return this._dataFeed?.key;
|
|
1786
2101
|
}
|
|
1787
2102
|
get spaceState() {
|
|
1788
2103
|
return this._controlPipeline.spaceState;
|
|
@@ -1800,16 +2115,31 @@ var Space = class Space2 {
|
|
|
1800
2115
|
return this._snapshotManager;
|
|
1801
2116
|
}
|
|
1802
2117
|
setControlFeed(feed) {
|
|
1803
|
-
(0,
|
|
2118
|
+
(0, import_invariant9.invariant)(!this._controlFeed, "Control feed already set.", {
|
|
2119
|
+
F: __dxlog_file11,
|
|
2120
|
+
L: 184,
|
|
2121
|
+
S: this,
|
|
2122
|
+
A: [
|
|
2123
|
+
"!this._controlFeed",
|
|
2124
|
+
"'Control feed already set.'"
|
|
2125
|
+
]
|
|
2126
|
+
});
|
|
1804
2127
|
this._controlFeed = feed;
|
|
1805
2128
|
this._controlPipeline.setWriteFeed(feed);
|
|
1806
2129
|
return this;
|
|
1807
2130
|
}
|
|
1808
2131
|
setDataFeed(feed) {
|
|
1809
|
-
|
|
1810
|
-
|
|
2132
|
+
(0, import_invariant9.invariant)(!this._dataFeed, "Data feed already set.", {
|
|
2133
|
+
F: __dxlog_file11,
|
|
2134
|
+
L: 191,
|
|
2135
|
+
S: this,
|
|
2136
|
+
A: [
|
|
2137
|
+
"!this._dataFeed",
|
|
2138
|
+
"'Data feed already set.'"
|
|
2139
|
+
]
|
|
2140
|
+
});
|
|
1811
2141
|
this._dataFeed = feed;
|
|
1812
|
-
|
|
2142
|
+
this._dataPipeline.pipeline?.setWriteFeed(feed);
|
|
1813
2143
|
return this;
|
|
1814
2144
|
}
|
|
1815
2145
|
/**
|
|
@@ -1824,10 +2154,10 @@ var Space = class Space2 {
|
|
|
1824
2154
|
// getDataFeeds(): FeedInfo[] {
|
|
1825
2155
|
// return this._dataPipeline?.getFeeds();
|
|
1826
2156
|
// }
|
|
1827
|
-
async open() {
|
|
2157
|
+
async open(ctx) {
|
|
1828
2158
|
(0, import_log10.log)("opening...", void 0, {
|
|
1829
|
-
F:
|
|
1830
|
-
L:
|
|
2159
|
+
F: __dxlog_file11,
|
|
2160
|
+
L: 213,
|
|
1831
2161
|
S: this,
|
|
1832
2162
|
C: (f, a) => f(...a)
|
|
1833
2163
|
});
|
|
@@ -1839,8 +2169,8 @@ var Space = class Space2 {
|
|
|
1839
2169
|
await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
|
|
1840
2170
|
this._isOpen = true;
|
|
1841
2171
|
(0, import_log10.log)("opened", void 0, {
|
|
1842
|
-
F:
|
|
1843
|
-
L:
|
|
2172
|
+
F: __dxlog_file11,
|
|
2173
|
+
L: 224,
|
|
1844
2174
|
S: this,
|
|
1845
2175
|
C: (f, a) => f(...a)
|
|
1846
2176
|
});
|
|
@@ -1849,8 +2179,8 @@ var Space = class Space2 {
|
|
|
1849
2179
|
(0, import_log10.log)("closing...", {
|
|
1850
2180
|
key: this._key
|
|
1851
2181
|
}, {
|
|
1852
|
-
F:
|
|
1853
|
-
L:
|
|
2182
|
+
F: __dxlog_file11,
|
|
2183
|
+
L: 229,
|
|
1854
2184
|
S: this,
|
|
1855
2185
|
C: (f, a) => f(...a)
|
|
1856
2186
|
});
|
|
@@ -1863,42 +2193,53 @@ var Space = class Space2 {
|
|
|
1863
2193
|
await this._controlPipeline.stop();
|
|
1864
2194
|
this._isOpen = false;
|
|
1865
2195
|
(0, import_log10.log)("closed", void 0, {
|
|
1866
|
-
F:
|
|
1867
|
-
L:
|
|
2196
|
+
F: __dxlog_file11,
|
|
2197
|
+
L: 242,
|
|
1868
2198
|
S: this,
|
|
1869
2199
|
C: (f, a) => f(...a)
|
|
1870
2200
|
});
|
|
1871
2201
|
}
|
|
1872
2202
|
async initializeDataPipeline() {
|
|
1873
2203
|
(0, import_log10.log)("initializeDataPipeline", void 0, {
|
|
1874
|
-
F:
|
|
1875
|
-
L:
|
|
2204
|
+
F: __dxlog_file11,
|
|
2205
|
+
L: 247,
|
|
1876
2206
|
S: this,
|
|
1877
2207
|
C: (f, a) => f(...a)
|
|
1878
2208
|
});
|
|
1879
|
-
(0,
|
|
2209
|
+
(0, import_invariant9.invariant)(this._isOpen, "Space must be open to initialize data pipeline.", {
|
|
2210
|
+
F: __dxlog_file11,
|
|
2211
|
+
L: 248,
|
|
2212
|
+
S: this,
|
|
2213
|
+
A: [
|
|
2214
|
+
"this._isOpen",
|
|
2215
|
+
"'Space must be open to initialize data pipeline.'"
|
|
2216
|
+
]
|
|
2217
|
+
});
|
|
1880
2218
|
await this._dataPipeline.open();
|
|
1881
2219
|
}
|
|
1882
2220
|
};
|
|
1883
|
-
|
|
1884
|
-
import_log10.logInfo
|
|
2221
|
+
_ts_decorate7([
|
|
2222
|
+
import_log10.logInfo,
|
|
2223
|
+
import_tracing3.trace.info()
|
|
1885
2224
|
], Space.prototype, "key", null);
|
|
1886
|
-
|
|
1887
|
-
import_async7.synchronized
|
|
2225
|
+
_ts_decorate7([
|
|
2226
|
+
import_async7.synchronized,
|
|
2227
|
+
import_tracing3.trace.span()
|
|
1888
2228
|
], Space.prototype, "open", null);
|
|
1889
|
-
|
|
2229
|
+
_ts_decorate7([
|
|
1890
2230
|
import_async7.synchronized
|
|
1891
2231
|
], Space.prototype, "close", null);
|
|
1892
|
-
|
|
2232
|
+
_ts_decorate7([
|
|
1893
2233
|
import_async7.synchronized
|
|
1894
2234
|
], Space.prototype, "initializeDataPipeline", null);
|
|
1895
|
-
Space =
|
|
1896
|
-
(0, import_async7.trackLeaks)("open", "close")
|
|
2235
|
+
Space = _ts_decorate7([
|
|
2236
|
+
(0, import_async7.trackLeaks)("open", "close"),
|
|
2237
|
+
import_tracing3.trace.resource()
|
|
1897
2238
|
], Space);
|
|
1898
2239
|
|
|
1899
2240
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
1900
2241
|
var import_async8 = require("@dxos/async");
|
|
1901
|
-
var
|
|
2242
|
+
var import_debug4 = require("@dxos/debug");
|
|
1902
2243
|
var import_keys6 = require("@dxos/keys");
|
|
1903
2244
|
var import_log12 = require("@dxos/log");
|
|
1904
2245
|
var import_protocols6 = require("@dxos/protocols");
|
|
@@ -1913,7 +2254,7 @@ var import_teleport2 = require("@dxos/teleport");
|
|
|
1913
2254
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
1914
2255
|
var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
|
|
1915
2256
|
var import_util8 = require("@dxos/util");
|
|
1916
|
-
function
|
|
2257
|
+
function _ts_decorate8(decorators, target, key, desc) {
|
|
1917
2258
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1918
2259
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
1919
2260
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -1923,7 +2264,7 @@ function _ts_decorate7(decorators, target, key, desc) {
|
|
|
1923
2264
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1924
2265
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1925
2266
|
}
|
|
1926
|
-
var
|
|
2267
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
|
|
1927
2268
|
var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
|
|
1928
2269
|
var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
|
|
1929
2270
|
var SpaceProtocol = class {
|
|
@@ -1953,8 +2294,8 @@ var SpaceProtocol = class {
|
|
|
1953
2294
|
(0, import_log11.log)("addFeed", {
|
|
1954
2295
|
key: feed.key
|
|
1955
2296
|
}, {
|
|
1956
|
-
F:
|
|
1957
|
-
L:
|
|
2297
|
+
F: __dxlog_file12,
|
|
2298
|
+
L: 96,
|
|
1958
2299
|
S: this,
|
|
1959
2300
|
C: (f, a) => f(...a)
|
|
1960
2301
|
});
|
|
@@ -1963,6 +2304,7 @@ var SpaceProtocol = class {
|
|
|
1963
2304
|
session.replicator.addFeed(feed);
|
|
1964
2305
|
}
|
|
1965
2306
|
}
|
|
2307
|
+
// TODO(burdon): Rename open? Common open/close interfaces for all services?
|
|
1966
2308
|
async start() {
|
|
1967
2309
|
if (this._connection) {
|
|
1968
2310
|
return;
|
|
@@ -1975,8 +2317,8 @@ var SpaceProtocol = class {
|
|
|
1975
2317
|
};
|
|
1976
2318
|
await this.blobSync.open();
|
|
1977
2319
|
(0, import_log11.log)("starting...", void 0, {
|
|
1978
|
-
F:
|
|
1979
|
-
L:
|
|
2320
|
+
F: __dxlog_file12,
|
|
2321
|
+
L: 122,
|
|
1980
2322
|
S: this,
|
|
1981
2323
|
C: (f, a) => f(...a)
|
|
1982
2324
|
});
|
|
@@ -1986,11 +2328,11 @@ var SpaceProtocol = class {
|
|
|
1986
2328
|
peerId: this._swarmIdentity.peerKey,
|
|
1987
2329
|
topic,
|
|
1988
2330
|
topology: new import_network_manager.MMSTTopology(topologyConfig),
|
|
1989
|
-
label: `
|
|
2331
|
+
label: `space swarm ${topic.truncate()}`
|
|
1990
2332
|
});
|
|
1991
2333
|
(0, import_log11.log)("started", void 0, {
|
|
1992
|
-
F:
|
|
1993
|
-
L:
|
|
2334
|
+
F: __dxlog_file12,
|
|
2335
|
+
L: 132,
|
|
1994
2336
|
S: this,
|
|
1995
2337
|
C: (f, a) => f(...a)
|
|
1996
2338
|
});
|
|
@@ -1999,15 +2341,15 @@ var SpaceProtocol = class {
|
|
|
1999
2341
|
await this.blobSync.close();
|
|
2000
2342
|
if (this._connection) {
|
|
2001
2343
|
(0, import_log11.log)("stopping...", void 0, {
|
|
2002
|
-
F:
|
|
2003
|
-
L:
|
|
2344
|
+
F: __dxlog_file12,
|
|
2345
|
+
L: 139,
|
|
2004
2346
|
S: this,
|
|
2005
2347
|
C: (f, a) => f(...a)
|
|
2006
2348
|
});
|
|
2007
2349
|
await this._connection.close();
|
|
2008
2350
|
(0, import_log11.log)("stopped", void 0, {
|
|
2009
|
-
F:
|
|
2010
|
-
L:
|
|
2351
|
+
F: __dxlog_file12,
|
|
2352
|
+
L: 141,
|
|
2011
2353
|
S: this,
|
|
2012
2354
|
C: (f, a) => f(...a)
|
|
2013
2355
|
});
|
|
@@ -2030,10 +2372,10 @@ var SpaceProtocol = class {
|
|
|
2030
2372
|
};
|
|
2031
2373
|
}
|
|
2032
2374
|
};
|
|
2033
|
-
|
|
2375
|
+
_ts_decorate8([
|
|
2034
2376
|
import_log11.logInfo
|
|
2035
2377
|
], SpaceProtocol.prototype, "_topic", void 0);
|
|
2036
|
-
|
|
2378
|
+
_ts_decorate8([
|
|
2037
2379
|
import_log11.logInfo
|
|
2038
2380
|
], SpaceProtocol.prototype, "_ownPeerKey", null);
|
|
2039
2381
|
var AuthStatus;
|
|
@@ -2072,20 +2414,18 @@ var SpaceProtocolSession = class {
|
|
|
2072
2414
|
provider: this._swarmIdentity.credentialProvider,
|
|
2073
2415
|
verifier: this._swarmIdentity.credentialAuthenticator,
|
|
2074
2416
|
onAuthSuccess: () => {
|
|
2075
|
-
var _a;
|
|
2076
2417
|
(0, import_log11.log)("Peer authenticated", void 0, {
|
|
2077
|
-
F:
|
|
2078
|
-
L:
|
|
2418
|
+
F: __dxlog_file12,
|
|
2419
|
+
L: 238,
|
|
2079
2420
|
S: this,
|
|
2080
2421
|
C: (f, a) => f(...a)
|
|
2081
2422
|
});
|
|
2082
2423
|
this._authStatus = AuthStatus.SUCCESS;
|
|
2083
|
-
|
|
2424
|
+
this._onSessionAuth?.(this._teleport);
|
|
2084
2425
|
},
|
|
2085
2426
|
onAuthFailure: () => {
|
|
2086
|
-
var _a;
|
|
2087
2427
|
this._authStatus = AuthStatus.FAILURE;
|
|
2088
|
-
|
|
2428
|
+
this._onAuthFailure?.(this._teleport);
|
|
2089
2429
|
}
|
|
2090
2430
|
}));
|
|
2091
2431
|
this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
|
|
@@ -2095,15 +2435,15 @@ var SpaceProtocolSession = class {
|
|
|
2095
2435
|
await this._teleport.close();
|
|
2096
2436
|
}
|
|
2097
2437
|
};
|
|
2098
|
-
|
|
2438
|
+
_ts_decorate8([
|
|
2099
2439
|
import_log11.logInfo
|
|
2100
2440
|
], SpaceProtocolSession.prototype, "_wireParams", void 0);
|
|
2101
|
-
|
|
2441
|
+
_ts_decorate8([
|
|
2102
2442
|
import_log11.logInfo
|
|
2103
2443
|
], SpaceProtocolSession.prototype, "authStatus", null);
|
|
2104
2444
|
|
|
2105
2445
|
// packages/core/echo/echo-pipeline/src/space/space-manager.ts
|
|
2106
|
-
function
|
|
2446
|
+
function _ts_decorate9(decorators, target, key, desc) {
|
|
2107
2447
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2108
2448
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
2109
2449
|
r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -2113,7 +2453,7 @@ function _ts_decorate8(decorators, target, key, desc) {
|
|
|
2113
2453
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
2114
2454
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2115
2455
|
}
|
|
2116
|
-
var
|
|
2456
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
|
|
2117
2457
|
var SpaceManager = class SpaceManager2 {
|
|
2118
2458
|
constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
|
|
2119
2459
|
this._spaces = new import_util9.ComplexMap(import_keys6.PublicKey.hash);
|
|
@@ -2137,11 +2477,10 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2137
2477
|
].map((space) => space.close()));
|
|
2138
2478
|
}
|
|
2139
2479
|
async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
|
|
2140
|
-
var _a;
|
|
2141
2480
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
|
|
2142
2481
|
id: this._instanceId
|
|
2143
2482
|
}), {
|
|
2144
|
-
F:
|
|
2483
|
+
F: __dxlog_file13,
|
|
2145
2484
|
L: 97,
|
|
2146
2485
|
S: this,
|
|
2147
2486
|
C: (f, a) => f(...a)
|
|
@@ -2149,12 +2488,12 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2149
2488
|
(0, import_log12.log)("constructing space...", {
|
|
2150
2489
|
spaceKey: metadata.genesisFeedKey
|
|
2151
2490
|
}, {
|
|
2152
|
-
F:
|
|
2491
|
+
F: __dxlog_file13,
|
|
2153
2492
|
L: 98,
|
|
2154
2493
|
S: this,
|
|
2155
2494
|
C: (f, a) => f(...a)
|
|
2156
2495
|
});
|
|
2157
|
-
const genesisFeed = await this._feedStore.openFeed(
|
|
2496
|
+
const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? (0, import_debug4.failUndefined)());
|
|
2158
2497
|
const spaceKey = metadata.key;
|
|
2159
2498
|
const protocol = new SpaceProtocol({
|
|
2160
2499
|
topic: spaceKey,
|
|
@@ -2179,21 +2518,21 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2179
2518
|
import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
|
|
2180
2519
|
id: this._instanceId
|
|
2181
2520
|
}), {
|
|
2182
|
-
F:
|
|
2183
|
-
L:
|
|
2521
|
+
F: __dxlog_file13,
|
|
2522
|
+
L: 126,
|
|
2184
2523
|
S: this,
|
|
2185
2524
|
C: (f, a) => f(...a)
|
|
2186
2525
|
});
|
|
2187
2526
|
return space;
|
|
2188
2527
|
}
|
|
2189
2528
|
};
|
|
2190
|
-
|
|
2529
|
+
_ts_decorate9([
|
|
2191
2530
|
import_async8.synchronized
|
|
2192
2531
|
], SpaceManager.prototype, "open", null);
|
|
2193
|
-
|
|
2532
|
+
_ts_decorate9([
|
|
2194
2533
|
import_async8.synchronized
|
|
2195
2534
|
], SpaceManager.prototype, "close", null);
|
|
2196
|
-
SpaceManager =
|
|
2535
|
+
SpaceManager = _ts_decorate9([
|
|
2197
2536
|
(0, import_async8.trackLeaks)("open", "close")
|
|
2198
2537
|
], SpaceManager);
|
|
2199
2538
|
// Annotate the CommonJS export names for ESM import in node:
|